Skip to content

Instantly share code, notes, and snippets.

@ryenbeatty
Last active November 17, 2015 05:22
Show Gist options
  • Select an option

  • Save ryenbeatty/74ac0f7933784476c726 to your computer and use it in GitHub Desktop.

Select an option

Save ryenbeatty/74ac0f7933784476c726 to your computer and use it in GitHub Desktop.
import fs from 'fs'
import data from 'rdio_collection.json'
import { split, replace, compose, map, uniq, pick } from 'ramda'
import { Map } from 'immutable'
const d = data.collection;
const out = './artists_albums.json';
const log = (x) => { console.log(x); return x; }
// getArtists :: Object -> Map
const getArtists = (x) => {
let map = Map({artist: x.artist, album: x.albumUrl})
let st = split('/', x.albumUrl)[4]
return map.set('album', st)
}
// formatAlbum :: Map -> new Map
const formatAlbum = (map) => {
let strippedTitle = replace(/[_%0-9]/g, '', map.get('album'))
let newMap = map.set('album', strippedTitle)
return newMap.toJS()
}
// app :: func func -> func
const app = compose(map(formatAlbum), map(getArtists))
// res :: Array -> Array
const res = uniq(app(d))
fs.writeFile(out, JSON.stringify(res, null, 4), (err) => {
try {
log(res.length + ' artists saved to ' + out)
} catch (err) {
log(err)
}
});
@ryenbeatty
Copy link
Author

babel rdio.js --out-file rdio-compiled.js
node rdio-compiled.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment