Created
March 11, 2018 22:53
-
-
Save gn-spawn/8aaa61fe99ddd47624b41bbe91b16c7b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const plist = require('plist'); | |
const fuzzy = require('fuzzy'); | |
const xml = plist.parse(fs.readFileSync('3PM.xml', 'utf8')) | |
let playlists = [] | |
get_playlist(xml).forEach(song => { | |
playlists.push(`${song['Name']} / ${song['Artist']}`) | |
console.log(`${song['Name']} / ${song['Artist']}`) | |
}) | |
let results = fuzzy.filter('linkin park', playlists) | |
let matches = results.map(function(el) { return el.string; }); | |
console.log(matches) | |
function get_playlist(xml) { | |
const tracks = xml.Tracks | |
const playlist = xml.Playlists[0]['Playlist Items'] | |
const setori = [] | |
playlist.forEach(track => { | |
const id = track['Track ID'] | |
setori.push(tracks[id]) | |
}); | |
return setori | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment