Skip to content

siebert/Unofficial-Google-Music-API

 
 

Repository files navigation

gmusicapi: an unofficial Python API for Google Play Music

This project allows control of Google Music from Python.

from gmusicapi import Api
api = Api()
api.login('user@gmail.com', 'my-password')
# => True

library = api.get_all_songs()
sweet_tracks = [track for track in library if track['artist'] == 'The Cat Empire']

playlist_id = api.create_playlist('Rad muzak')
api.change_playlist(playlist_id, sweet_tracks)

This project is not supported nor endorsed by Google. Use common sense (protocol compliance, reasonable load, etc) and don't ruin the fun for everyone else.

For those looking to use the api, see the installation and usage sections below. Documentation is hosted at Read the Docs.

For those looking to port or contribute, see the porting section below. There's also an out of date code overview on the wiki.

For bugs reports, feature requests, and contributions, go ahead and open an issue.

Feel free to drop by #gmusicapi on Freenode with general questions.

Also, check out these nifty projects that use gmusicapi:

Features

See HISTORY.rst for changes by version.

Feature Overview:

  • Getting library information:
    • all song metadata
    • all user playlist titles and ids
    • songs from a specific playlist
  • Song streaming and downloading
  • Song uploading/scan-and-match of all Google-supported file formats
  • Playlist manipulation:
    • creation
    • name modification
    • song deletion, addition, and reordering
  • Song manipulation:
    • metadata modification (be sure to read the documentation)
    • removal from library
  • Searching for songs, artists, and albums.

Coming soon:

  • album art manipulation (issues #52 and #38)
  • library download support

Usage

The API has been tested on Python 2.7.{2,3} on Linux and Windows. It is not currently compatible with other Python versions, though 2.6 support is in the works (issue #84).

Installation

Use pip: pip install gmusicapi will grab all the source dependencies. I would recommend against using easy_install.

If you want to make changes to gmusicapi, see the guidance in the contributing doc.

To upload filetypes other than mp3, you're going to need Libav's avconv installed and in your system path, along with at least libmp3lame. For Ubuntu users: sudo apt-get install libav-tools ubuntu-restricted-extras. Windows users, get the most recent static binaries and then edit your path to include the directory that contains avconv.exe. If you need to install from source, be sure to use ./configure --enable-gpl --enable-nonfree --enable-libmp3lame. mediabuntu and deb-multimedia might be useful.

To check that everything is set up correctly, you can run the test suite: python -m gmusicapi.test.integration_test_api. If something goes wrong during testing, there is the chance that you'll end up with an extra playlist or test song in your library, but it should never destructively modify your library. If there is an error during testing, please open an issue to let me know about it.

Getting Started

gmusicapi.api.Api is the user-facing interface. The provided example.py should be enough to get you started. For complete information, see the documentation. The testing code might also be useful.

Ports

Here are the ports I'm currently aware of:

Porting Information for Developers

Get in touch if you're working on a port. Even if I can't contribute, I might know people who'd like to.

The current implementation uses the same interface that a web browser does, and a code overview can be found on the wiki. Darryl Pogue is worked on a more durable implementation by emulating Google's Android app. His work is here, and may easier to port. More information this alternative protocol is here.

Either way, you'll probably want to ignore anything related to Music Manager; that's just for uploading. If uploading interests you, more information is here.

Lastly, keep the license in mind, and, again, be sure to respect Google.

Notes

Debug logging is enabled by default. All logging is done to gmusicapi.log in your working directory, with warnings and above printed to the console. Nothing related to authenticated gets logged aside from "logged in" and "logged out" messages.

Copyright 2012 Simon Weber. Licensed under the 3-clause BSD. See COPYING.

https://cruel-carlota.pagodabox.com/68a92ecf6b6590372f435fb2674d072e

About

An unofficial api for Google Music.

Resources

License

Stars

Watchers

Forks

Packages

No packages published