Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Latest commit

 

History

History
83 lines (56 loc) · 2.26 KB

usage.rst

File metadata and controls

83 lines (56 loc) · 2.26 KB

Usage

Installation

Use pip: $ pip install gmusicapi. This will grab all the source dependencies. Avoid using easy_install.

If you're upgrading from a date-versioned release (eg 2013.03.04), do $ pip uninstall gmusicapi; pip install gmusicapi instead.

To upload anything other than mp3s, you're going to need Libav's avconv installed and in your system path, along with at least libmp3lame.

If you need to install avconv from source, be sure to use $ ./configure --enable-gpl --enable-nonfree --enable-libmp3lame.

Quickstart

If you're not going to be uploading music, use the :pyMobileclient. This requires plaintext auth, so your code might look something like:

from gmusicapi import Mobileclient

api = Mobileclient()
logged_in = api.login('user@gmail.com', 'my-password')
# logged_in is True if login was successful

Note that 2-factor users will need to setup and provide an app-specific password.

If you're going to upload Music, you want the :pyMusicmanager. It uses OAuth2 and does not require plaintext credentials.

Instead, you'll need to authorize your account once before logging in. The easiest way is to run:

from gmusicapi import Musicmanager

mm = Musicmanager()
mm.perform_oauth()

If successful, this will save your credentials to disk. Then, future runs can start with:

from gmusicapi import Musicmanager

mm = Musicmanager()
mm.login()

# mm.upload('foo.mp3')
# ...

If you need both library management and uploading, just create one of each type of client.

The reference section has complete information on both clients:

reference/api