page=page, limit=LFM_PER_PAGE).json() # for song in r['tracks']['track']: # songname = song['name'] # artist = song['artist']['name'] # print songname, artist # break if not r['tracks']['track']: PB_PARAMS['title'] = 'Null! - ' + PB_PARAMS['title'] break for track in r['tracks']['track']: if track['name'] and track['artist']['name']: info = track_info(mbid=track['mbid'], songname=track['name'], artist=track['artist']['name']) # Dump data to disk! if info: data = { 'lfm': info[0], 'enest': info[1], } with open('%s/%s' % (folder, track['mbid']), 'w') as output: json.dump(data, output) count_files += 1 # Send progress to Pushbullet! if (count_files % PB_NOTIFY_WHEN) == 0: PB_PARAMS['body'] = PB_PARAMS['body'].format(count=count_files)
# Keep track of files dumped count_files = 0 # Let's get some data for page in LFM_PAGES: r = lastfm.get(LFM_KEY, method='tag.getTopTracks', tag='electronic', page=page, limit=LFM_PER_PAGE).json() if not r['tracks']['track']: PB_PARAMS['title'] = 'Null! - ' + PB_PARAMS['title'] break for track in r['tracks']['track']: if track['mbid']: info = track_info(mbid=track['mbid']) # Dump data to disk! if info: data = { 'lfm': info[0], 'ab_high': info[1], 'ab_low': info[2], } with open('%s/%s' % (folder, track['mbid']), 'w') as output: json.dump(data, output) count_files += 1 # Send progress to Pushbullet! if (count_files % PB_NOTIFY_WHEN) == 0:
# Let's get some data for page in LFM_PAGES: r = lastfm.get(LFM_KEY, method='tag.getTopTracks', tag='electronic', page=page, limit=LFM_PER_PAGE).json() if not r['tracks']['track']: PB_PARAMS['title'] = 'Null! - ' + PB_PARAMS['title'] break for track in r['tracks']['track']: if track['mbid']: info = track_info(mbid=track['mbid']) # Dump data to disk! if info: data = { 'lfm': info[0], 'ab_high': info[1], 'ab_low': info[2], } with open('%s/%s' % (folder, track['mbid']), 'w') as output: json.dump(data, output) count_files += 1 # Send progress to Pushbullet! if (count_files % PB_NOTIFY_WHEN) == 0: