Last active
December 14, 2015 03:29
-
-
Save markpasc/5021252 to your computer and use it in GitHub Desktop.
new “collection” command in https://github.com/markpasc/rdio-cli
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
$ bin/rdio collection --json collection.json | |
WARNING: Downloading collection of 674 albums (this will take a while) | |
100% |#########################################################################| | |
$ head collection.json | |
[ | |
{ | |
"albumKey": "a1522320", | |
"albumUrl": "/artist/alt-J/album/An_Awesome_Wave/", | |
"artist": "alt-J", | |
"artistKey": "rl1809209|67377", | |
"artistUrl": "/artist/alt-J/", | |
"baseIcon": "album/0/9/a/0000000000173a90/4/square-200.jpg", | |
"canSample": true, | |
"canStream": true, | |
$ python | |
Python 2.7.2 (default, Jun 20 2012, 16:23:33) | |
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import json | |
>>> with open('collection.json', 'r') as f: | |
... obj = json.load(f) | |
... | |
>>> len(obj) | |
1780 | |
>>> albums = [x for x in obj if x['type'] == 'al'] | |
>>> len(albums) | |
353 | |
>>> longest = max(albums, key=lambda x: len(x['trackKeys'])) | |
>>> longest['name'], longest['artist'], len(longest['trackKeys']) | |
(u'Arkeology', u'World Party', 70) | |
>>> singles = [x for x in albums if len(x['trackKeys']) == 1] | |
>>> len(singles) | |
17 | |
>>> [(x['name'], x['artist']) for x in singles] | |
[(u'O Come, All Ye Faithful', u'Abandon Kansas'), (u'Carol Of The Bells', u'The | |
Bird and the Bee'), (u'Stay Positive', u'The Hold Steady'), (u'Candy Cane', | |
u'The Jigsaw Seen'), (u'The Blizzard', u'Camera Obscura'), (u'Norberg', u'Tim | |
Hecker'), (u'Carol Of The Meows', u'Guster'), (u'The Golden Age', u'The | |
Asteroids Galaxy Tour'), (u'She Wolf', u'Shakira'), (u'Make Her Say', u'Kid | |
Cudi'), (u"Day 'N' Nite", u'Kid Cudi'), (u'Yours Truly, The Commuter', u'Jason | |
Lytle'), (u'Christmas, Christmas', u'Mojo Nixon'), (u'Empire', u'Kasabian'), | |
(u'Empire', u'Kasabian'), (u'Empire', u'Kasabian'), (u'I And Love And You', | |
u'The Avett Brothers')] | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment