Documentation ¶
Overview ¶
Package musicmanager implements a client for managing Google Play Music libraries.
Index ¶
Constants ¶
const Scope = "https://www.googleapis.com/auth/musicmanager"
Scope is the OAuth scope used by this API.
Variables ¶
This section is empty.
Functions ¶
func CheckImportResponse ¶
CheckImportResponse checks the response to an HTTP request sent to a URL returned by Client.ImportTracks. It returns the server ID of the track to which resp is a response, or an error if the response is erroneous in some way. The error will be of type *textproto.Error if the response has a non-2xx status code. CheckImportResponse closes resp.Body.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a Music Manager client.
func NewClient ¶
NewClient creates a new Music Manager client with the given device ID and underlying HTTP client. The supplied client must be capable of authenticating requests with the OAuth scope Scope.
func (*Client) ExportTrack ¶
ExportTrack returns a short-lived download URL for the given track, identified by its server ID. Downloading the track from this URL requires no authentication. The Content-Disposition and Content-Length headers of the response contain the name and size of the track respectively.
func (*Client) ImportTracks ¶
ImportTracks returns short-lived upload URLs for the given tracks. MP3 audio data can be PUT or POSTed to these URLs without authentication. Individual tracks can fail, in which case errs[i] contains the reason why importing tracks[i] failed.
The Title field of a track to be imported cannot be empty. The server also uses the ClientId field to identify which tracks have already been uploaded, so trying to import a track with a client ID that has already been uploaded will fail. Leaving the ClientId field empty appears to bypass this server-side check; however, the implementation of ImportTracks cannot handle two tracks in a batch with the same client ID, even if they are both empty.
A response to a request sent to a URL returned from this function can report failure through means other than the status code. Use CheckImportResponse to verify that the request succeeded.
func (*Client) ListTracks ¶
func (c *Client) ListTracks(purchasedOnly bool, updatedMin int64, pageToken string) (*TrackList, error)
ListTracks lists the user's tracks from least to most recently accessed. It can optionally filter for purchased or promotional tracks only, or for tracks last modified after a given Unix timestamp (microsecond precision). Long responses may be returned in chunks, in which case the PageToken field of the TrackList object should be given to a new ListTracks call.
func (*Client) Register ¶
Register registers the client as a device with the given name under the user's Play Music library. A client must be registered before the other method calls can succeed. Re-registering a client can be used to change its name. Note that there are limits to how many devices one account can have registered at a time, with how many accounts one device can be registered, and how many devices a user can deregister in a year, so be judicious in using this call.
type ImportError ¶
type ImportError int32
An ImportError is returned by Client.ImportTracks if the server rejects a track based on its metadata or audio sample.
const ( ErrMatched ImportError = 1 + iota ErrInvalidSignature ErrAlreadyExists ErrTransientImport ErrPermanentImport ErrTrackCountLimitReached ErrRejectStoreTrack ErrRejectStoreTrackByLabel ErrRejectDrmTrack )
func (ImportError) Error ¶
func (e ImportError) Error() string
type ListError ¶
type ListError int32
A ListError is returned by Client.ListTracks if the server refuses to list the tracks for some reason.
type RegisterError ¶
type RegisterError int32
A RegisterError is returned by Client.Register if the server refuses to register the client for some reason.
const ( ErrMaxLimitReached RegisterError = 9 + iota ErrClientBoundToOtherAccount ErrClientNotAuthorized ErrMaxPerMachineUsersExceeded ErrClientPleaseRetry ErrNotSubscribed ErrInvalidRequest ErrUpgradeMusicManager )
func (RegisterError) Error ¶
func (e RegisterError) Error() string
type Track ¶
type Track struct { // There fields are present inside a TrackList. Id string Title string Artist string Album string AlbumArtist string TrackNumber int TrackSize int64 // Additional fields that can be given on import. ClientId string Composer string Genre string Comment string Year int TotalTrackCount int DiscNumber int TotalDiscCount int PlayCount int BeatsPerMinute int Channels TrackChannels Rating TrackRating TrackType TrackType // BitRate is the bitrate of the track in kbps, or 0 if don't // care. BitRate int // SampleFunc can be optionally used to provide the server with // a 128kbps MP3 sample of the track if requested. It takes the // start and length of the desired sample in milliseconds. If // SampleFunc is nil, an empty sample is sent. SampleFunc func(start, duration int) []byte }
A Track represents metadata about a track. When in a TrackList, only a subset of the fields are populated.
type TrackChannels ¶
type TrackChannels int
TrackChannels represents the number of channels a Track can have.
const ( Mono TrackChannels = 1 Stereo TrackChannels = 2 )
type TrackList ¶
type TrackList struct { // The actual page of tracks. Items []*Track `convert:"/DownloadTrackInfo"` // Page token for the next page of tracks. PageToken string `convert:"/ContinuationToken"` // The last time one of the tracks in the list was modified, // expressed as a Unix timestamp in microseconds. UpdatedMin int64 `convert:"/UpdatedMin"` // Whether this listing contains only purchased or promotional // tracks. PurchasedOnly bool `convert:"-"` }
A TrackList is one page of a track listing.
type TrackRating ¶
type TrackRating int
TrackRating represents the rating of a track.
const ( NoRating TrackRating = 1 + iota OneStar // thumbs down TwoStars ThreeStars FourStars FiveStars // thumbs up )
Notes ¶
Bugs ¶
Exporting tracks has been known to fail if the device ID of the client is not sufficiently "MAC address-like". The exact threshold is unknown; perhaps the server only looks for a colon in the ID.
Client.ImportTracks does not activate the upload progress tracker on https://play.google.com/music.
Album art cannot be uploaded.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
gmusic
Gmusic is a toy command line client for managing Google Play Music libraries.
|
Gmusic is a toy command line client for managing Google Play Music libraries. |
internal
|
|
convert
Package convert uses reflection to deep convert between arbitrary value hierarchies.
|
Package convert uses reflection to deep convert between arbitrary value hierarchies. |
download_proto/data
Package google_musicmanager_v0 is a generated protocol buffer package.
|
Package google_musicmanager_v0 is a generated protocol buffer package. |
download_proto/service
Package google_musicmanager_v0 is a generated protocol buffer package.
|
Package google_musicmanager_v0 is a generated protocol buffer package. |
locker_proto/data
Package google_musicmanager_v0 is a generated protocol buffer package.
|
Package google_musicmanager_v0 is a generated protocol buffer package. |
locker_proto/service
Package google_musicmanager_v0 is a generated protocol buffer package.
|
Package google_musicmanager_v0 is a generated protocol buffer package. |
session_json
Package json describes the interface of the JSON calls of Google's Music Manager service.
|
Package json describes the interface of the JSON calls of Google's Music Manager service. |
uits_proto/data
Package google_musicmanager_v0 is a generated protocol buffer package.
|
Package google_musicmanager_v0 is a generated protocol buffer package. |
upload_proto/data
Package google_musicmanager_v0 is a generated protocol buffer package.
|
Package google_musicmanager_v0 is a generated protocol buffer package. |
upload_proto/service
Package google_musicmanager_v0 is a generated protocol buffer package.
|
Package google_musicmanager_v0 is a generated protocol buffer package. |