musicmanager.calls — Music Manager API call classes

Example of making an HTTP request using the requests library:

# Assuming an authenticated session called 'session'.
>>> from google_music_proto.musicmanager.calls import ExportIds
>>> call = ExportIds(<uploader_id>)
>>> response = session.request(
        call.method, call.url, params=call.params, headers=call.headers,
        data=call.body, allow_redirects=call.follow_redirects
    )

Attributes

Call classes have the following attributes:

body

Binary-encoded body of the HTTP request.

follow_redirects

Boolean to enable/disable request redirects.

headers

Headers to send with the HTTP request.

method

Method for the HTTP request.

params

Dict of parameters to send in the query string of the HTTP request.

url

URL for the HTTP request.

Classes

class ClientState(uploader_id)[source]

Get information about the state of a Google Music account.

Note

This provides things like the quota for uploaded songs.

Parameters

uploader_id (str) – A unique ID given as a MAC address. Only one Music Manager client may use a given uploader ID.

class Export(uploader_id, song_id)[source]

Download a song from a Google Music library.

Parameters
  • uploader_id (str) – A unique ID given as a MAC address. Only one Music Manager client may use a given uploader ID.

  • song_id (str) – A song ID.

class ExportIDs(uploader_id, continuation_token=None, export_type=1, updated_min=-1)[source]

Get a listing of uploaded and purchased library tracks.

Note

The track list is paged. Getting all tracks will require looping through all pages.

Parameters
  • uploader_id (str) – A unique ID given as a MAC address. Only one Music Manager client may use a given uploader ID.

  • continuation_token (str, Optional) – The token of the page to return. Default: Not sent to get first page.

  • export_type (int, Optional) – The type of tracks to return: 1 for all tracks, 2 for promotional and purchased. Default: 1

  • updated_min (int, Optional) – List changes since the given Unix epoch time in microseconds. Default lists all changes.

class GetJobs(uploader_id)[source]

Get a listing of pending upload jobs.

Parameters

uploader_id (str) – A unique ID given as a MAC address. Only one Music Manager client may use a given uploader ID.

class Metadata(uploader_id, tracks)[source]

Send upload track metadata to Google Music.

Parameters
  • uploader_id (str) – A unique ID given as a MAC address. Only one Music Manager client may use a given uploader ID.

  • tracks (list) – A list of tracks in the form of locker_pb2.Track. Use Metadata.get_track_info to generate locker tracks from audio files.

static get_track_info(song)[source]

Create a locker track from an audio file.

Parameters

song (os.PathLike or str or audio_metadata.Format) – The path to an audio file or an instance of audio_metadata.Format.

Returns

A locker track of the given audio file.

Return type

locker_pb2.Track

class Sample(uploader_id, track_samples)[source]

Send samples of audio files to Google Music.

Parameters
  • uploader_id (str) – A unique ID given as a MAC address. Only one Music Manager client may use a given uploader ID.

  • track_samples (list) – A list of track samples in the form of upload_pb2.TrackSample. Use Sample.generate_sample to generate a track sample from an audio file.

static generate_sample(song, track, sample_request, *, external_art=None, no_sample=False)[source]

Generate a track sample from an audio file.

Parameters
  • track (locker_pb2.Track) – A locker track of the audio file as created by Metadata.get_track_info.

  • sample_request (upload_pb2.SignedChallengeInfo) – The 'signed_challenge_info' portion for the audio file from the Metadata response.

  • external_art (bytes, Optional) – The binary data of an external album art image. If not provided, embedded album art will be used, if present.

  • no_sample (bool, Optional) – Don’t generate an audio sample from song; send empty audio sample. Default: Create an audio sample using ffmpeg/avconv.

class ScottyAgentPost(uploader_id, server_track_id, track, song, external_art=None, total_song_count=1, total_uploaded_count=0)[source]

Request an upload URL for a track from Google Music.

Parameters
  • uploader_id (str) – A unique ID given as a MAC address. Only one Music Manager client may use a given uploader ID.

  • server_track_id (str) – The server ID of the audio file to upload as given in the response of Metadata or Sample.

  • track (locker_pb2.Track) – A locker track of the audio file as created by Metadata.get_track_info.

  • song (os.PathLike or str or audio_metadata.Format) – The path to an audio file or an instance of audio_metadata.Format.

  • external_art (bytes, Optional) – The binary data of an external album art image. If not provided, embedded album art will be used, if present.

  • total_song_count (int, Optional) – Total number of songs to be uploaded in this session. Default: 1

  • total_uploaded_count (int, Optional) – Number of songs uploaded in this session. Default: 0

class ScottyAgentPut(upload_url, audio_file, content_type='audio/mpeg')[source]

Upload a file to a Google Music library.

Parameters
  • upload_url (str) – The upload URL given by ScottyAgentPost response.

  • audio_file (os.PathLike or str or bytes) – An audio file as os.PathLike, a file/bytes-like object, or binary data.

  • content_type (str) – The mime type to be sent in the ContentType header field. Default: 'audio/mpeg'

class UpAuth(uploader_id, uploader_name)[source]

Authenticate device as a Music Manager uploader.

Parameters
  • uploader_id (str) – A unique ID given as a MAC address. Only one Music Manager client may use a given uploader ID.

  • uploader_name (str) – The name given to the device in the Google Music device listing.

class UploadState(uploader_id, state)[source]

Notify Google Music of the state of an upload.

Parameters
  • uploader_id (str) – A unique ID given as a MAC address. Only one Music Manager client may use a given uploader ID.

  • state (str) – Can be one of 'START', 'PAUSED', 'STOPPED'. Will be uppercased if lowercase is given.