app.put('/file',function(req,res) { console.log(req.body); ff.write(req.body.file,req.body.metadata,function() { res.send('ok'); }); });
function saveID3(songData){ // did we successfully load the ffmetadata library if (ffmetadata) { // only commit the fields ffmpeg will honor: http://wiki.multimedia.cx/index.php?title=FFmpeg_Metadata#MP3 var data = { title: songData.title, author: songData.artist, album: songData.album, year: songData.year, genre: songData.genre }; // add the cover art if available var options = {}; if (songData.cover_location) { // assign it in array format with 1 element options.attachments = [path.join(app.get('root') + '/dbs/covers/' + songData.cover_location)]; } var destinationFile = path.join(app.get('config').music_dir, songData.location); // write the to the id3 tags on the file ffmetadata.write(destinationFile, data, options, function(err) { if (err) { console.log('Error writing id3 tags to file: ' + err); } else { console.log('Successfully wrote id3 tags to file: ' + destinationFile); } }); } }
function writeBeatportData(originalTrack ,data) { var artist = data[0], title = data[1], label = data[2], genre = data[3], bpm = data[4], release = data[5], newCover = data[6]; var ffmetadata = require("ffmetadata"), fs = require("fs"); ffmetadata.write( originalTrack , newCover , { artist: artist, albumartist: artist, title: title, album: release, BPM: bpm, genre: genre, label: label, }, function(err) { if (err) { alert("Error writing metadata" + err); }else{ alert("Data written"); var resetTable = $( "#beatport-table" ).children(); $(resetTable).remove(); $(".active-track").remove(); $("#confirm-btn").attr("disabled", "disabled"); } }); }
var addid3 = function(song, callback) { if (!song.url) return callback(null); var id3 = {}; id3.artist = song.artist; id3.title = song.title; id3.album = song.albumtitle; id3.date = song.public_time; id3.year = song.public_time; id3.publisher = song.company; ffmetadata.write(song.url, id3, callback); };
.on('close', function() { console.log('download completed'); // write metadata ffmetadata.write(filePath, data, function(err) { if (err) { // error while write metadata throw 'error while writing metadata'; } else { // send success http respons res.json({"empty":"response"}); next(); } }); })
function addid3(song, callback) { if (!song.url) return callback(null); var id3 = {}; id3.artist = song.artist; id3.title = song.title; id3.album = song.albumtitle; id3.date = song.public_time; id3.year = song.public_time; id3.publisher = song.company; ffmetadata.write(song.url, id3, function(err) { if (!err) consoler.success('√ ' + id3.title); if (err) consoler.error('X ' + id3.title); callback(null); }); }
downloader._downloadCover(track, function() { var options = { attachments: [path.join(downloader.baseDirectory, track.getFilefriendlyAlbumtext(), track.getFilefriendlyName() + '.jpg')] }; ffmetadata.write(path.join(downloader.baseDirectory, track.getFilefriendlyAlbumtext(), track.getFilefriendlyName() + '.mp3'), {}, options, function(err) { if (err) console.log('Error writing cover art : ' + track.getName()); // Remove the cover-art file fs.unlink(path.join(downloader.baseDirectory, track.getFilefriendlyAlbumtext(), track.getFilefriendlyName() + '.jpg')); // Download is finished req.io.emit('down-finish', { id: conversionID, name: track.getName() }); // Download complete callback if (callback) callback(); }); });
fs.writeFile(fichero_destino, body, function (err) { if (err) throw err; var data = { artist: tags.artist, title: tags.title, album: tags.album }; if(downloadinfo.tipo == "playlist"){ data.album = downloadinfo.playlist; } ffmetadata.write(fichero_destino, data, function(err) { if (err) console.error("Error writing metadata" + err); else{ fs.readFile(fichero_destino, function (err, data) { if (err) throw err; io.sockets.emit("tdownloaded",{total:totaldownloaded}); io.to(socket.id).emit('blob', { status:data, filename:"/music/" + falbum + '-'+ trackname.replace(/[^a-zA-Z0-9 -_]/g,'') + ".mp3", next_socket : socket.id, }); }); } }); });