Created
May 20, 2014 21:23
-
-
Save abarreir/ebc9328cc594743231c3 to your computer and use it in GitHub Desktop.
Get some data about gmusic-api tracks with multiple artist ids
This file contains 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
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