Skip to content

Instantly share code, notes, and snippets.

@abarreir
Created May 20, 2014 21:23
Show Gist options
  • Save abarreir/ebc9328cc594743231c3 to your computer and use it in GitHub Desktop.
Save abarreir/ebc9328cc594743231c3 to your computer and use it in GitHub Desktop.
Get some data about gmusic-api tracks with multiple artist ids
from gmusicapi import Mobileclient
username = u''
password = u''
mul_artist_ids = 0
first_is_the_one = 0
first_isnt_the_one = []
api = Mobileclient()
api.login(username, password)
all_songs = api.get_all_songs()
nb_songs = len(all_songs)
progress = 0.
for song in all_songs:
progress += 1.
print progress/nb_songs
try:
if len(song['artistId']) > 1:
mul_artist_ids += 1.
# Check first artist id name against the song artist name
artist_info = api.get_artist_info(song['artistId'][0], include_albums=False, max_top_tracks=0, max_rel_artist=0)
if artist_info['name'] == song['artist']:
first_is_the_one += 1.
else:
first_isnt_the_one.append((artist_info['name'], song['artist']))
except KeyError:
continue
print first_is_the_one/mul_artist_ids
print mul_artist_ids/nb_songs
print first_isnt_the_one
api.logout()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment