Skip to content

Instantly share code, notes, and snippets.

@beaugunderson
Created April 6, 2015 02:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beaugunderson/d29560af5d725c1c20f5 to your computer and use it in GitHub Desktop.
Save beaugunderson/d29560af5d725c1c20f5 to your computer and use it in GitHub Desktop.
'use strict';
var fs = require('fs');
var parse = require('csv-parse');
// from https://www.amazon.com/clientbuddy/compartments/playlists/handlers/syncPlaylists
// post-processed with jq:
// jq .playlists[0].tracks[].trackId.objectId < ./syncPlaylists.json
var playlistTracks = require('./track-ids.json');
// from https://www.amazon.com/cirrus/v3/getTracksById
var someTracks = require('./getTracksById.json').trackList;
// from https://cirrus-full-snapshots-track-csv-v1-0-na-prod.s3.amazonaws.com/
var csvData = fs.readFileSync('./tracks.csv');
parse(csvData, {columns: true}, function (err, csvTracks) {
if (err) {
return console.log('Error:', err);
}
playlistTracks.forEach(function (a) {
var found = false;
someTracks.forEach(function (b) {
if (a === b.trackId) {
found = true;
console.log(b.metadata.artistName + ' - ' + b.metadata.title);
}
});
csvTracks.forEach(function (b) {
if (a === b.objectId) {
found = true;
console.log(b.artistName + ' - ' + b.title);
}
});
if (!found) {
console.log('Not found:', a);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment