MusicManager
— Music Manager API client¶
-
class
MusicManager
(username=None, uploader_id=None, *, session=None, token=None, token_handler=<class 'google_music.token_handlers.FileTokenHandler'>, token_handler_kwargs=None)[source]¶ API wrapper class to access Google Music Music Manager functionality.
>>> from google_music import MusicManager >>> mm = MusicManager('username')
- Parameters
username (str, Optional) – Your Google Music username. Used to store OAuth tokens for multiple accounts separately.
uploader_id (str, Optional) – A unique uploader ID. Default: MAC address and username used.
session (
GoogleMusicSession
, Optional) – A session compatible withGoogleMusicSession
.token (dict, Optional) – An OAuth token compatible with
oauthlib
.token_handler (
TokenHandler
, Optional) – A token handler class compatible withTokenHandler
for dumping and loading the OAuth token.token_handler_kwargs (dict, Optional) – Keyword arguments to pass to the
token_handler
class. These become attributes on the class instance.
-
property
uploader_id
¶ The uploader ID of the
MusicManager
instance.
-
property
uploader_name
¶ The uploader name of the
MusicManager
instance.
-
quota
()[source]¶ Get the uploaded track count and allowance.
- Returns
Number of uploaded tracks, number of tracks allowed.
- Return type
-
songs
(*, uploaded=True, purchased=True)[source]¶ Get a listing of Music Library songs.
- Returns
Song dicts.
- Return type
-
songs_iter
(*, continuation_token=None, export_type=1)[source]¶ Get a paged iterator of Music Library songs.
-
upload
(song, *, album_art_path=None, no_sample=False)[source]¶ Upload a song to a Google Music library.
- Parameters
song (os.PathLike or str or audio_metadata.Format) – The path to an audio file or an instance of
audio_metadata.Format
.album_art_path (os.PathLike or str, Optional) – The relative filename or absolute filepath to external album art.
no_sample (bool, Optional) – Don’t generate an audio sample from song; send empty audio sample. Default: Create an audio sample using ffmpeg/avconv.
- Returns
A result dict with keys:
'filepath'
,'success'
,'reason'
, and'song_id'
(if successful).- Return type