-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewplaylists.py
33 lines (27 loc) · 982 Bytes
/
viewplaylists.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from gmusicapi import Mobileclient
import json
import requests
import sys
from clusters2list import *
#import pandas as pd
requests.packages.urllib3.disable_warnings()
api = Mobileclient()
logged_in = api.login('[email protected]', 'musicatyourspeed')
pid = sys.argv[1]
#playlists = api.get_all_playlists()
#print json.dumps(playlists, indent=4, separators=(',', ': '))
plsongs = api.get_all_user_playlist_contents()
#print json.dumps(plsongs, indent=4, separators=(',', ': '))
#data = pd.read_csv("/home/drew/gpmusic_fixed.csv")
allpls = {"playlists": []}
for pi, plst in enumerate(plsongs):
ret = {'name': "",'songs': []}
if plst['id'] == pid or pid == "all":
ret['name'] = plsongs[pi]['name']
for i,v in enumerate(plsongs[pi]['tracks']):
for i2,v2 in enumerate(allsongs):
if v2['id'] == v['trackId']:
ret['songs'].append(v2)
break
allpls['playlists'].append(ret)
print json.dumps(allpls, indent=4, separators=(',', ': '))