Package: gmusicapi
gmusicapi allows control ofGoogle Musicwith Python.fromgmusicapiimportMobileclientapi=Mobileclient()# after running api.perform_oauth() once:api.oauth_login('<a previously-registered device id>')# => Truelibrary=api.get_all_songs()sweet_track_ids=[track['id']fortrackinlibraryiftrack['artist']=='The Cat Empire']playlist_id=api.create_playlist('Rad muzak')api.add_songs_to_playlist(playlist_id,sweet_track_ids)gmusicapi is not supported nor endorsed by Google.That said, it’s actively maintained, and powers a bunch of cool projects:alternate clients, includingone designed for the visually impaired,a web-based jukebox which ships with its own server,command lineclients,a FUSE filesystem,
andan Alexa skilllibrary management tools forsyncing tracks,syncing playlists,
andmigrating to a different accountproxies for media players, such asgmusicproxyandgmusicprocurator,
as well as plugins forMopidy,SqueezeboxandTizonia.enhancements likeautoplaylists / smart playlistsGetting startedStart withthe usage docs, which will guide you through installation and the available apis.Once you’re up and running, you can explore the rest of the docs athttp://unofficial-google-music-api.readthedocs.io.If the documentation doesn’t answer your questions, or you just want to get
in touch, eitherdrop by #gmusicapi on Freenodeor shoot me an email.Status and updatesJanuary 2020: Python 2 support dropped.November 2018: proper OAuth support for the mobileclient.February 2016: Python 3 support!September 2015: Google switched to a new music uploading endpoint, breaking uploading for outdated versions of gmusicapi.June 2015: Full mobileclient and webclient functionality was restored.May 2015: Limited mobileclient functionality was restored.April 2015: Google deprecated clientlogin, breaking both the webclient and mobileclient.November 2013: I started working fulltime at Venmo, meaning this project is back to night and weekend development.For fine-grained development updates, follow me on Twitter:@simonmweber.HistoryAs of 1.0.0,semantic versioningis used.13.0.0released 2020-03-27breaking: drop Python 2 supportfix an album name schema failure12.1.1released 2019-07-13open default log file as utf-8 to avoid windows encoding problems12.1.0released 2019-04-20deprecate Mobileclient.get_promoted_songs in favor of Mobileclient.get_top_songs to clarify its behavior. Functionality remains the same.12.0.0released 2019-01-08breaking: remove gmusicapi.clients.OAUTH_FILEPATH. Use Musicmanager.OAUTH_FILEPATH instead.11.1.1released 2018-12-04add back gmusicapi.clients.OAUTH_FILEPATH after it was removed in 11.1.0 (a breaking change)deprecate gmusicapi.clients.OAUTH_FILEPATH in favor of Musicmanager.OAUTH_FILEPATH11.1.0released 2018-11-30add Mobileclient OAuth support (perform_oauthandoauth_login) and deprecate email/password auth, which Google now often rejects.
It works the same way as the Musicmanager; seethe docsfor an example.update Mobileclient.search schema11.0.4released 2018-11-19fix a number of bugs with Mobileclient.search11.0.3released 2018-09-19fix an “__init__() takes at most 4…” warning coming from oauth2client11.0.2released 2018-09-09fix validation of “ios:…” format device idsadd inLibrary field to station docs11.0.1released 2018-03-18update schemas11.0.0released 2017-12-09breaking: list calls now default to max_results=None, increasing the default number of results from 100 to 999add updated_after param to song/playlist listing to support differential updatesadd support for free radio stationsadd filepath+extension to unsupported file exception messagefix “I’m Feeling Lucky” station never refreshing its seedfix crashes caused by some 503s during uploadingfix gmtools forhttps://github.com/simon-weber/Google-Music-Playlist-Importerfix AAC and ALAC content type upload detectionblacklist requests 2.8.2improve id documentationupdate schemas10.1.2released 2017-04-03validate device ids to prevent 403s during streamingfix LocalUnboundError during login for some environmentsupdate schemas10.1.1released 2017-02-10deprecate include_deleted param to greatly speed up responses for Mobileclient.get_all_*Mobileclient.search now works on non-subscription accountsfix logging IOError on read-only filesystemsfix problems caused by broken requests IDNA support10.1.0released 2016-10-31deprecate the Webclientadd podcast support to Mobileclient:get_all_podcast_seriesget_all_podcast_episodesadd_podcast_seriesdelete_podcast_seriesedit_podcast_seriesget_podcast_episode_stream_urlget_podcast_episode_infoget_podcast_series_infoget_browse_podcast_hierarchyget_browse_podcast_seriesadd Mobileclient.add_store_tracksadd Mobileclient.rate_songsadd Musicmanager.get_quotafix get_all_user_playlist_contents hanging for large playlistsfix is_authenticated status after uploader_id exceptionsfix upload progress tracker remaining after uploadvarious internal improvements and schema updates10.0.1released 2016-06-04switch to pycryptodomexminor schema adjustments10.0.0released 2016-05-01breaking: Mobileclient.search_all_access is now Mobileclient.searchbreaking: Mobileclient.add_aa_track is now Mobileclient.add_store_trackadd situation_hits and video_hits to Mobclient.searchadd methods Mobileclient.deauthorize_device, .get_listen_now_items, and .get_listen_now_situationsadd property Mobileclient.is_subscribedadd playlists and curated stations as station seedsadd params locale and subscription to Mobileclient.loginadd param enable_transcoding to Musicmanager.uploadupdate to newer Google apis, returning more data in responsesreduce memory usage during uploadingfix a variety of bugs, mostly python2/3 type errors9.0.0released 2016-03-05breaking: attempting to reupload a file after changing only its tags will result in a rejection as a duplicate upload (it used to upload successfully)fix webclient login after Google changesfix'str' object has no attribute 'refresh'prevent upstream protobufs TypeError by locking versiona ‘matched’ value may be returned even if matching is not enabled if we were unable to disallow matching8.0.0released 2016-02-08breaking: drop support for python < 2.7.9add (experimental) python 3 support!add Musicmanager.get_purchased_songsadd station_hits to search_all_access resultsadd disc_number and total_disc_count to Musicmanager.get_uploaded_songsadd a prompt for device id in testsupgrade gpsoauth, removing dependency on pycryptodeprecate Webclient.create_playlist and Webclient.get_registered_devicesfix various packaging problemsfix KeyError in Mobileclient.get_station_tracksfix a TypeError from requestsfix various bits of the docs7.0.0released 2015-09-19breaking: python 2.6 is no longer supportedbreaking: webclient.get_registered_devices has a slightly different schemafix Webclient authentication and get_stream_urlsfix MusicManager uploading: Google shut down the rupio endpointfix certificate validationfix album artist metadata not being upload6.0.0released 2015-06-20fix creation of multiple android devices from android_id=None; support creating device ids from mac address.android_id is now optional for mobileclient.get_stream_url, defaulting to android_id from login()5.0.0released 2015-06-02breaking: Webclient.login temporarily broken after clientlogin deprecationbreaking: Mobileclient.get_thumbs_up_songs renamed to mobileclient.get_promoted_songsbreaking: Mobileclient.change_playlist_name is now edit_playlistfix Mobileclient.login breakage due to clientlogin deprecationfix Mobileclient.get_genres: return a list and handle invalid parent genresadd support for filtering out recently played station tracks to Mobileclient.get_station_tracksadd public playlist results to Mobileclient.search_all_accessadd Mobileclient.get_registered_devicesadd quality option to Mobileclient.get_stream_urladd support for public playlist creation to Mobileclient.create_playlistmake optional description param for Webclient.create_playlistbetter handle locating mp3 transcoder4.0.0released 2014-06-08breaking: remove webclient.change_song_metadata; use mobileclient.change_song_metadata insteadbreaking: remove webclient.get_all_songs; use mobileclient.get_all_songs insteadbreaking: remove webclient.get_playlist_songs; use mobileclient.get_all_user_playlist_contents insteadbreaking: remove webclient.get_all_playlist_ids; use mobileclient.get_all_user_playlists insteadbreaking: webclient.upload_album_art now returns a url to the uploaded imagebreaking: due to backend changes, mobileclient.change_song_metadata can only change ratingsadd mobileclient.get_thumbs_up_songsadd mobileclient.increment_song_playcountadd webclient.create_playlist, which is capable of creating public playlistsadd webclient.get_shared_playlist_info3.1.0released 2014-01-20add verify_ssl option to client initgreatly loosen dependency version requirements3.0.1released 2013-12-11remove extraneous logging introduced in 3.0.0 – this could have logged auth details, so it’s recommended to delete old logs3.0.0released 2013-11-03Musicmanager.get_all_songs is now Musicmanager.get_uploaded_songsMobileclient.get_all_playlist_contents is now Mobileclient.get_all_user_playlist_contents, and will no longer return results for subscribed playlistsadd Mobileclient.get_shared_playlist_contentsadd Mobileclient.reorder_playlist_entryadd Mobileclient.change_song_metadataadd Mobileclient.get_album_infoadd Mobileclient.get_track_infoadd Mobileclient.get_genrescompatibility fixes2.0.0released 2013-08-01remove broken Webclient.{create_playlist, change_playlist, copy_playlist, search, change_playlist_name}add Mobileclient; this will slowly replace most of the Webclient, so prefer it when possibleadd support for streaming All Access songsadd Webclient.get_registered_devicesadd a toggle to turn off validation per clientraise an exception when a song dictionary is passed instead of an id1.2.0released 2013-05-16add support for listing/downloading songs with the Musicmanager.
When possible, this should be preferred to the Webclient’s method, since
it does not have a download quota.fix a bug where the string representing a machine’s mac
was not properly formed for use as an uploader_id.
This will cause another machine to be registered for some users;
the old device can be identified from its lack of a version number.verify user-provided uploader_ids1.1.0released 2013-04-19get_all_songs can optionally return a generatorcompatibility updates for AddPlaylist calllog to appdirs.user_log_dir by defaultadd open_browser param to perform_oauth1.0.0released 2013-04-02breaking: Api has been split into Webclient and Musicmanagerbreaking: semantic versioning (previous versions removed from PyPi)Music Manager OAuth supportfaster uploading when matching is disabledfaster login2013.03.04add artistMatchedId to metadatatests are no longer a mess2013.02.27add support for uploading album art (docs)add support for .m4b filesadd CancelUploadJobs call (not exposed in api yet)Python 2.6 compatibilityreduced peak memory usage when uploadinglogging improvementsimproved error messages when uploading2013.02.15user now controls logging (docs)documentation overhaul2013.02.14fix international logins2013.02.12fix packaging issues2013.02.11improve handling of strange metadata when uploadingadd a dependency ondateutil2013.02.09breaking: upload returns a 3-tuple (docs)breaking: get_all_playlist_ids always returns lists of ids; remove always_id_lists option
(docs)breaking: remove suppress_failure option in Api.__init__breaking: copy_playlistorig_idargument renamed toplaylist_id(docs)new: report_incorrect_match (only useful for Music Manager uploads) (docs)uploading fixedavconv replaces ffmpegscan and match is supportedhuge code improvements2013.01.05compatibility update for playlist mutationvarious metadata compatibility updates2012.11.09bugfix: support for uploading uppercase filenames (Tom Graham)bugfix: fix typo in multidownload validation, and add test2012.08.31metadata compatibility updates (storeId, lastPlayed)fix uploading of unicode filenames without tags2012.05.04update allowed rating values to 1-5 (David Dooling)update metajamId to matchedId (David Dooling)fix broken expectation about disc/track numbering metadata2012.04.03change to the 3-clause BSD licenseadd Kevin Kwok to AUTHORS2012.04.01improve code in example.pysupport uploading of all Google-supported formats: m4a, ogg, flac, wma, mp3. Non-mp3 are transcoded to 320kbs abr mp3 using ffmpegintroduce dependency on ffmpeg. for non-mp3 uploading, it needs to be in path and have the needed transcoders availableget_playlists is now get_all_playlist_ids, and is fasteradd an exception CallFailure. Api functions raise it if the server says their request failedadd suppress_failure (default False) option to Api.__init__()change_playlist now returns the changed playlistId (pid)change_song_metadata now returns a list of changed songIds (sids)create_playlist now returns the new piddelete_playlist now returns the deleted piddelete_songs now returns a list of deleted sidschange_playlist now returns the pid of the playlist - which may differ from the one passed inadd_songs_to_playlist now returns a list of (sid, new playlistEntryId aka eid) tuples of added songsremove_songs_from_playlist now returns a list of removed (sid, eid) pairssearch dictionary is now flattened, without the “results” key. see documentation for example2012.03.27package for pip/pypiadd AUTHORS fileremove session.py; the sessions are now just api.PlaySession (Darryl Pogue)protocol.Metadata_Expectations.get_expectation will return UnknownExpectation when queried for unknown keys; this should prevent future problemsadd immutable ‘subjectToCuration’ and ‘metajamId’ fields - use unknown2012.03.16add change_playlist for playlist modificationsget_playlists supports multiple playlists of the same name by returning lists of playlist ids. By default, it will return a single string (the id) for unique playlist names; see the always_id_lists parameter.api.login now attempts to bump Music Manager authentication first, bypassing browser emulation. This allows for much faster authentication.urls updated for the change to Google Play Musicremove_songs_from_playlist now takes (playlist_id, song_ids), for consistency with other playlist mutations2012.03.04change name to gmusicapi to avoid ambiguitychange delete_song and remove_song_from_playlist to delete_songs and remove_songs_from_playlist, for consistency with other functionsadd verification of WC json responsessetup a sane branch model. seehttp://nvie.com/posts/a-successful-git-branching-model/improve logging