Skip to content

Metadata Not Viewable in Media Players #14

@TimeTravelersHackedMe

Description

@TimeTravelersHackedMe

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);
  }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions