fixed networking and added handling for currently playing

This commit is contained in:
aj 2019-03-24 22:51:11 +00:00
parent f4415ec867
commit 7d23f6302d
2 changed files with 9 additions and 5 deletions

View File

@ -13,8 +13,8 @@ def exportScrobbles(scrobbles, path):
writer.writeheader() writer.writeheader()
for track in scrobbles: for track in scrobbles:
if '@attr' not in track:
trackdict = { trackdict = {
'track':track['name'].replace(';', '_').replace(',', '_'), 'track':track['name'].replace(';', '_').replace(',', '_'),
'album':track['album']['#text'].replace(';', '_').replace(',', '_'), 'album':track['album']['#text'].replace(';', '_').replace(',', '_'),
'artist':track['artist']['#text'].replace(';', '_').replace(',', '_'), 'artist':track['artist']['#text'].replace(';', '_').replace(',', '_'),
@ -23,4 +23,4 @@ def exportScrobbles(scrobbles, path):
'album id':track['album']['mbid'], 'album id':track['album']['mbid'],
'artist id':track['artist']['mbid']} 'artist id':track['artist']['mbid']}
writer.writerow(trackdict) writer.writerow(trackdict)

View File

@ -21,11 +21,15 @@ class User:
} }
data.update(extra) data.update(extra)
req = requests.post('http://ws.audioscrobbler.com/2.0/', data = data) req = requests.get('http://ws.audioscrobbler.com/2.0/', params = data)
if req.status_code < 200 or req.status_code > 299: if req.status_code < 200 or req.status_code > 299:
raise ValueError('HTTP Error Raised: ' + str(req.json()['error']) + ' ' + req.json()['message']) if req.json()['error'] == 8:
print('ERROR: retrying call ' + method)
return __makeRequest(method, extra, page)
else:
raise ValueError('HTTP Error Raised: ' + str(req.json()['error']) + ' ' + req.json()['message'])
return req.json() return req.json()