Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata Not Viewable in Media Players #14

Open
TimeTravelersHackedMe opened this issue Oct 29, 2016 · 0 comments
Open

Metadata Not Viewable in Media Players #14

TimeTravelersHackedMe opened this issue Oct 29, 2016 · 0 comments

Comments

@TimeTravelersHackedMe
Copy link

Hi, I would really love this plugin if I could get it to work. I'm able to write and successfully read the metadata of an mp3 but the changes don't reflect in any media players. I'm using the latest release of FFmpeg on Windows 10 (downloaded the EXEs and added them to Path). I tried with and without the idv2.3 option.:

node -v: v4.5.0
npm -v: 2.15.9

I tried viewing the Artist/Title in Microsoft Groove Music player and VLC.

var request = require("request");
var request = request.defaults({ jar: true });
var rp = require('request-promise');
var cheerio = require("cheerio");
var fs = require('fs');
var ffmetadata = require("ffmetadata");
var url = 'http://hypem.com/weirdpolice';
var musicDir = './Music';

// Create Music folder if it doesn't exist
if (!fs.existsSync(musicDir)) {
  fs.mkdirSync(musicDir);
}

function downloadSong(id, key, artist, title) {
  request('http://hypem.com/serve/source/' + id + '/' + key, function (error, response, body) {
    if (!error) {
      var downloadLink = JSON.parse(body).url;
      var fileLocation = artist + ' - ' + title + '1.mp3';
      var stream = rp.get(downloadLink)
        .on('error', function (error) {
          console.log('Problem downloading ' + title + ' by ' + artist + ' from SoundCloud');
        })
        .pipe(fs.createWriteStream('1.mp3'));
      stream.on('finish', function () {
        setTimeout(function () {
          writeMeta(artist, title, '1.mp3');
        }, 10000)
      });
    } else {
      console.log("Problem finding SoundCloud download link: " + error);
    }
  });
}

function writeMeta(artist, title, fileLocation) {
  var data = {
    artist: artist,
    title: title
  }
  var options = {
    'idv2.3': true
  }
  ffmetadata.write('1.mp3', data, options, function (error) {
    if (error) {
      console.log('Error writing metadata for ' + title + ' by ' + artist);
    } else {
      console.log('Successfully wrote metadata for ' + title + ' by ' + artist);
      ffmetadata.read('1.mp3', function (err, data) {
        if (err) console.error("Error reading metadata", err);
        else console.log(data);
      });
    }
  });
}

request(url, function (error, response, body) {
  if (!error) {
    var $ = cheerio.load(body);
    var songs = JSON.parse($("#displayList-data").html()).tracks;
    downloadSong(songs[0].id, songs[0].key, songs[0].artist, songs[0].song);
  } else {
    console.log("Problem opening HypeM.com page: " + error);
  }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant