package module
v0.0.1 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2016 License: MIT Imports: 11 Imported by: 0


Google Music Unofficial API



Package gmusic provides methods to list and play music from Google Play Music.



View Source
const (
	TRACK_TYPE    = "1"
	ARTIST_TYPE   = "2"
	ALBUM_TYPE    = "3"


This section is empty.


This section is empty.


type Album

type Album struct {
	Kind                   string                 `json:"kind"`
	Name                   string                 `json:"name"`
	AlbumArtist            string                 `json:"albumArtist"`
	AlbumArtRef            string                 `json:"albumArtRef"`
	AlbumID                string                 `json:"albumId"`
	Artist                 string                 `json:"artist"`
	ArtistID               []string               `json:"artistId"`
	DescriptionAttribution DescriptionAttribution `json:"description_attribution"`
	Year                   int                    `json:"year"`
	ExplicitType           string                 `json:"explicitType"`

JSON example:

  "kind": "sj#album",
  "name": "2014 S/S",
  "albumArtist": "WINNER",
  "albumArtRef": "",
  "albumId": "Bsdo22syyl2p2s5jqasgexmgph4",
  "artist": "WINNER",
  "artistId": [
  "description_attribution": {
    "kind": "sj#attribution",
    "source_title": "Wikipedia",
    "source_url": "",
    "license_title": "Creative Commons Attribution CC-BY-SA 4.0",
    "license_url": ""
  "year": 2014,
  "explicitType": "2"

type ArtRefs

type ArtRefs struct {
	Kind        string `json:"kind"`
	URL         string `json:"url"`
	AspectRatio string `json:"aspectRatio"`
	AutoGen     bool   `json:"autogen"`

type Artist

type Artist struct {
	ID                   string               `json:"artistId"`
	Name                 string               `json:"name"`
	ArtistArtRef         string               `json:"artistArtRef"`
	ArtistArtRefs        []ArtRefs            `json:"artRefs"`
	ArtistBioAttribution ArtistBioAttribution `json:"artist_bio_attribution"`
	TopTracks            []Track              `json:"topTracks"`

JSON example:

  "kind": "sj#artist",
  "name": "WINNER",
  "artistArtRef": "",
  "artistArtRefs": [
      "kind": "sj#imageRef",
      "url": "",
      "aspectRatio": "2",
      "autogen": false
  "artistId": "Aglg43ajc3toter3svcvwjp3vky",
  "artist_bio_attribution": {
    "kind": "sj#attribution",
    "source_title": "artist representative"

type ArtistBioAttribution

type ArtistBioAttribution struct {
	Kind        string `json:"kind"`
	SourceTitle string `json:"source_title"`

type ArtistInfoParams

type ArtistInfoParams struct {
	ID            string `url:"nid"`
	IncludeAlbums bool   `url:"include-albums"`
	MaxTopTracts  int    `url:"num-top-tracks"`
	MaxRelArtist  int    `url:"num-related-artists"`
	Alt           string `url:"alt"`

type CreateMutations

type CreateMutations struct {
	Mutations []map[string]interface{} `json:"mutations"`

type CreatePlaylistParams

type CreatePlaylistParams struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Public      bool   `json:"-"`

type DescriptionAttribution

type DescriptionAttribution struct {
	Kind         string `json:"kind"`
	SourceTitle  string `json:"source_title"`
	SourceURL    string `json:"source_url"`
	LicenseTitle string `json:"license_title"`
	LicenseURL   string `json:"license_url"`

type GMusic

type GMusic struct {
	DeviceID string
	Auth     string

func Login

func Login(username, password string) (*GMusic, error)

Login logs in with a username and password and androidID from a MAC address of the machine.

func LoginAndroid

func LoginAndroid(username, password, androidID string) (*GMusic, error)

LoginAndroid logs in with a username and password and given androidID.

func (*GMusic) AddSongsToPlaylist

func (g *GMusic) AddSongsToPlaylist(pid string, trackIds []string) (PlaylistMutateResponse, error)

* Response example:

  "mutate_response": [
      "id": "dd2197a2-3f19-3668-874f-512760f84a62",
      "client_id": "39a55b1c-403a-4cc1-a0a0-aace50ca2d2e",
      "response_code": "OK"
      "id": "b30bebd8-fc23-36e8-8c41-45f127f49baa",
      "client_id": "26690b16-b6fb-41fa-becb-cfa6ef90f358",
      "response_code": "OK"
      "id": "4e7154c9-3eda-3bf1-b62b-d98c43094c7e",
      "client_id": "dffb83f1-a42e-4ed8-8180-1197c75fc7df",
      "response_code": "OK"
      "id": "2f6cbcd3-a233-31e9-9989-1f4f26e69515",
      "client_id": "d3d81efc-1561-429e-aab6-544ce8ae1e92",
      "response_code": "OK"
      "id": "6dd36f02-681f-37a3-bad3-f18d7c9aae8f",
      "client_id": "c2913f61-ca98-4599-863a-0de9f7b53fdb",
      "response_code": "OK"

func (*GMusic) CreatePlaylist

func (g *GMusic) CreatePlaylist(cparams CreatePlaylistParams) (PlaylistMutateResponse, error)

Params example:

	"name": "playlist name",
	"description": "playlist description",
	"sharedState": "PRIVATE | PUBLIC",
	"creationTimestamp": 0,
	"deleted": false,
	"lastModifiedTimestamp": -1,
	"type": "USER_GENERATED",

Response example:

  "mutate_response": [
      "id": "24e6e72e-0565-40a6-8523-12e1c9090241",
      "client_id": "",
      "response_code": "OK"

func (*GMusic) GetArtistInfo

func (g *GMusic) GetArtistInfo(params ArtistInfoParams) (Artist, error)

func (*GMusic) ListPlaylistEntries

func (g *GMusic) ListPlaylistEntries() ([]*PlaylistEntry, error)

func (*GMusic) ListPlaylists

func (g *GMusic) ListPlaylists() ([]*Playlist, error)

func (*GMusic) ListTracks

func (g *GMusic) ListTracks() ([]*Track, error)

func (*GMusic) Search

func (g *GMusic) Search(opts SearchParams) (SearchResponse, error)

type ListPlaylistEntries

type ListPlaylistEntries struct {
	Data struct {
		Items []*PlaylistEntry `json:"items"`
	} `json:"data"`
	Kind          string `json:"kind"`
	NextPageToken string `json:"nextPageToken"`

type ListPlaylists

type ListPlaylists struct {
	Data struct {
		Items []*Playlist `json:"items"`
	} `json:"data"`
	Kind string `json:"kind"`

type ListTracks

type ListTracks struct {
	Data struct {
		Items []*Track `json:"items"`
	} `json:"data"`
	Kind          string `json:"kind"`
	NextPageToken string `json:"nextPageToken"`

type Playlist

type Playlist struct {
	AccessControlled      bool   `json:"accessControlled"`
	CreationTimestamp     string `json:"creationTimestamp"`
	Deleted               bool   `json:"deleted"`
	ID                    string `json:"id"`
	Kind                  string `json:"kind"`
	LastModifiedTimestamp string `json:"lastModifiedTimestamp"`
	Name                  string `json:"name"`
	OwnerName             string `json:"ownerName"`
	OwnerProfilePhotoUrl  string `json:"ownerProfilePhotoUrl"`
	RecentTimestamp       string `json:"recentTimestamp"`
	ShareToken            string `json:"shareToken"`
	Type                  string `json:"type"`

type PlaylistEntry

type PlaylistEntry struct {
	AbsolutePosition      string `json:"absolutePosition"`
	ClientId              string `json:"clientId"`
	CreationTimestamp     string `json:"creationTimestamp"`
	Deleted               bool   `json:"deleted"`
	ID                    string `json:"id"`
	Kind                  string `json:"kind"`
	LastModifiedTimestamp string `json:"lastModifiedTimestamp"`
	PlaylistId            string `json:"playlistId"`
	Source                string `json:"source"`
	TrackId               string `json:"trackId"`

type PlaylistMutateResponse

type PlaylistMutateResponse struct {
	ID           string `json:"id"`
	ClientID     string `json:"client_id"`
	ResponseCode string `json:"response_code"`

type SearchEntriesResponse

type SearchEntriesResponse struct {
	Type               string   `json:"type"`
	Artist             Artist   `json:"artist,omitempty"`
	Album              Album    `json:"album,omitempty"`
	Track              Track    `json:"track,omitempty"`
	Playlist           Playlist `json:"playlist,omitempty"`
	BestResult         bool     `json:"best_result"`
	NavigationalResult bool     `json:"navigational_result"`

type SearchParams

type SearchParams struct {
	Term       string `url:"q"`
	MaxResults int    `url:"max-results"`

type SearchResponse

type SearchResponse struct {
	Kind    string                  `json:"kind"`
	Entries []SearchEntriesResponse `json:"entries"`

type Settings

type Settings struct {
	EntitlementInfo struct {
		ExpirationMillis int  `json:"expirationMillis"`
		IsCanceled       bool `json:"isCanceled"`
		IsSubscription   bool `json:"isSubscription"`
		IsTrial          bool `json:"isTrial"`
	} `json:"entitlementInfo"`
	Lab []struct {
		Description    string `json:"description"`
		DisplayName    string `json:"displayName"`
		Enabled        bool   `json:"enabled"`
		ExperimentName string `json:"experimentName"`
	} `json:"lab"`
	MaxUploadedTracks      int  `json:"maxUploadedTracks"`
	SubscriptionNewsletter bool `json:"subscriptionNewsletter"`
	UploadDevice           []struct {
		DeviceType             int    `json:"deviceType"`
		ID                     string `json:"id"`
		LastAccessedFormatted  string `json:"lastAccessedFormatted"`
		LastAccessedTimeMillis int    `json:"lastAccessedTimeMillis"`
		LastEventTimeMillis    int    `json:"lastEventTimeMillis"`
		Name                   string `json:"name"`
	} `json:"uploadDevice"`

type SettingsData

type SettingsData struct {
	Settings Settings `json:"settings"`

type Track

type Track struct {
	Album       string `json:"album"`
	AlbumArtRef []struct {
		URL string `json:"url"`
	} `json:"albumArtRef"`
	AlbumArtist  string `json:"albumArtist"`
	AlbumId      string `json:"albumId"`
	Artist       string `json:"artist"`
	ArtistArtRef []struct {
		URL string `json:"url"`
	} `json:"artistArtRef"`
	ArtistId              []string `json:"artistId"`
	ClientId              string   `json:"clientId"`
	CreationTimestamp     string   `json:"creationTimestamp"`
	Deleted               bool     `json:"deleted"`
	DiscNumber            int      `json:"discNumber"`
	DurationMillis        string   `json:"durationMillis"`
	EstimatedSize         string   `json:"estimatedSize"`
	ID                    string   `json:"id"`
	Kind                  string   `json:"kind"`
	LastModifiedTimestamp string   `json:"lastModifiedTimestamp"`
	Nid                   string   `json:"nid"`
	PlayCount             int      `json:"playCount"`
	RecentTimestamp       string   `json:"recentTimestamp"`
	StoreId               string   `json:"storeId"`
	Title                 string   `json:"title"`
	TrackNumber           int      `json:"trackNumber"`
	TrackType             string   `json:"trackType"`
	Year                  int      `json:"year"`


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL