Skip to content

Instantly share code, notes, and snippets.

@nickgartmann
Last active August 29, 2015 14:14
Show Gist options
  • Save nickgartmann/cca42c9ff5a5c897ac91 to your computer and use it in GitHub Desktop.
Save nickgartmann/cca42c9ff5a5c897ac91 to your computer and use it in GitHub Desktop.
setPlaylist: function( tracks, icd_id, callback ) {
//use track to find album and track number
//all tracks on album with higher track number than
//this should be added to `media_playlist` table
//( maybe clear `media_playlist` out first? )
// console.log( 'AudioRepository.setPlaylist(): not yet implemented!!' );
var q = squel.delete().from( 'media_playlist' ).where("ecms_id=" + icd_id);
this._delete( q.toString(), function( result ) {
var i = 0;
async.eachSeries( tracks, function( track, done ) {
var filename = track.id;
if ( filename && filename.split )
filename = filename.split( '%20' ).join( ' ' ).split( '%2F' ).join( '/' );
q = squel.insert().into( 'media_playlist' )
.set( 'fn_count', i++ )
.set( 'ecms_id', icd_id )
.set( 'display_name', this._clean( track.id ) )
.set( 'fq_filename', this._clean( filename ) )
.set( 'mplayer', 1 )
.set( 'web_server', 1 );
this._save( q.toString(), function( result ) {
done();
});
}.bind( this ), function( err ) {
callback && callback( true );
});
}.bind( this ));
setPlaylist: function( tracks, icd_id, callback ) {
//use track to find album and track number
//all tracks on album with higher track number than
//this should be added to `media_playlist` table
//( maybe clear `media_playlist` out first? )
// console.log( 'AudioRepository.setPlaylist(): not yet implemented!!' );
var q = squel.delete().from( 'media_playlist' ).where("ecms_id=" + icd_id);
this._delete( q.toString(), function( result ) {
var i = 0;
async.eachSeries( tracks, function( track, done ) {
var filename = track.id;
if ( filename && filename.split )
filename = filename.split( '%20' ).join( ' ' ).split( '%2F' ).join( '/' );
q = squel.insert().into( 'media_playlist' )
.set( 'fn_count', i++ )
.set( 'ecms_id', icd_id )
.set( 'display_name', this._clean( track.id ) )
.set( 'fq_filename', this._clean( filename ) )
.set( 'mplayer', 1 )
.set( 'web_server', 1 );
this._save( q.toString(), function( result ) {
done();
});
}.bind( this ), function( err ) {
callback && callback( true );
});
}.bind( this ));
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment