gopiano

package module
v0.0.0-...-72f656e Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2025 License: BSD-2-Clause Imports: 13 Imported by: 0

README

Pandora.com API Wrapper Client

A very thin wrapper around Pandora.com's JSON API.

Usage and Hacking

First create or set a $GOPATH, then use go get.

go get github.com/cellofellow/gopiano

You can then import this into your own code with

import "github.com/cellofellow/gopiano"

Or if you like you hack on it cd $GOPATH/src/github.com/cellofellow/gopiano. I'm very much in need of someone with Go experience to vet my code, and some specific things still need doing:

  • Proper tests.
  • Proper error handling.

This is alpha quality code, use at your own risk.

Documentation

Overview

Package gopiano provides a thin wrapper library around the Pandora.com client API.

This client API has been reverse engineered and documentation is available at http://pan-do-ra-api.wikia.com/wiki/Json/5.

The package provides a Client struct with a myriad of methods which interact with the Pandora JSON API's own methods. Each method returns a struct of the parsed JSON data and an error. All of the responses that these methods return can be found in the responses subpackage. There is also a requests subpackage but mostly you don't need to bother with those; they get instantiated by these client methods.

Index

Constants

This section is empty.

Variables

View Source
var AndroidClient = ClientDescription{
	DeviceModel: "android-generic",
	Username:    "android",
	Password:    "AC7IBG09A3DTSYM4R41UJWL07VLN8JI7",
	BaseURL:     "tuner.pandora.com/services/json/",
	EncryptKey:  "6#26FRL$ZWD",
	DecryptKey:  "R=U!LH$O2B#",
	Version:     "5",
}

AndroidClient is the data for the Android client.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents a Pandora client.

func NewClient

func NewClient(d ClientDescription) (*Client, error)

NewClient creates a new Client with specified ClientDescription.

func (*Client) AuthPartnerLogin

func (c *Client) AuthPartnerLogin() (*responses.AuthPartnerLogin, error)

AuthPartnerLogin establishes a Partner session with provided API username and password and receives a PartnerAuthToken, PartnerID and SyncTime which are stored for later calls. Calls API method "auth.partnerLogin".

func (*Client) AuthUserLogin

func (c *Client) AuthUserLogin(username, password string) (*responses.AuthUserLogin, error)

AuthUserLogin logs in a username and password pair. Receives the UserAuthToken which is used in subsequent calls. You must call AuthPartnerLogin first, and then either this method or UserCreateUser before you proceed. Calls API method "auth.userLogin".

func (*Client) BlowfishCall

func (c *Client) BlowfishCall(protocol, method string, body io.Reader, data interface{}) error

BlowfishCall first encrypts the body before calling PandoraCall. Arguments are identical to PandoraCall.

func (*Client) BookmarkAddArtistBookmark

func (c *Client) BookmarkAddArtistBookmark(trackToken string) (*responses.BookmarkAddArtistBookmark, error)

BookmarkAddArtistBookmark bookmarks an artist. Argument trackToken is a token of a specific artist. Calls API method "bookmark.addArtistBookmark".

func (*Client) BookmarkAddSongBookmark

func (c *Client) BookmarkAddSongBookmark(trackToken string) (*responses.BookmarkAddSongBookmark, error)

BookmarkAddSongBookmark bookmarks a song. Argument trackToken is a token of a specific song. Calls API method "bookmark.addSongBookmark".

func (*Client) ExplainTrack

func (c *Client) ExplainTrack(trackToken string) (*responses.ExplainTrack, error)

ExplainTrack retrieves an incomplete list of attributes assigned to a specified song by the Music Genome Project. Calls API method "track.explainTrack".

func (*Client) GetSyncTime

func (c *Client) GetSyncTime() int

GetSyncTime calculates the SyncTime for each call based on the timeOffset.

func (*Client) MusicSearch

func (c *Client) MusicSearch(searchText string) (*responses.MusicSearch, error)

MusicSearch searches for music, which can be used to create a new or add seeds to a station. Calls API method "music.search".

func (*Client) PandoraCall

func (c *Client) PandoraCall(protocol, method string, body io.Reader, data interface{}) error

PandoraCall is the basic function to send an HTTP POST to pandora.com. Arguments: protocol is either "https://" or "http://", method is whatever must be in the "method" url argument and specifies the remote procedure to call, body is an io.Reader to be passed directly into http.Post, and data is to be passed to json.Unmarshal to parse the JSON response.

func (*Client) StationAddFeedback

func (c *Client) StationAddFeedback(trackToken string, isPositive bool) (*responses.StationAddFeedback, error)

StationAddFeedback adds feedback (thumbs up or down, or star or ban if you prefer) to a song. Argument trackToken is the token identifying a track. Obtained from Client.StationGetPlaylist Argument isPositive is a bool which if true is a "star" and if false is a "ban". Calls API method "station.addFeedback".

func (*Client) StationAddMusic

func (c *Client) StationAddMusic(musicToken, stationToken string) (*responses.StationAddMusic, error)

StationAddMusic adds an additional music seed to an existing station. Argument musicToken is obtained from Client.MusicSearch Argument stationToken is obtained from Client.UserGetStationList Calls API method "station.addMusic".

func (*Client) StationCreateStationMusic

func (c *Client) StationCreateStationMusic(musicToken string) (*responses.StationCreateStation, error)

StationCreateStationMusic creates a new station from a music search result. Argument musicToken is obtained from Client.MusicSearch. Calls API method "station.createStation".

func (*Client) StationCreateStationTrack

func (c *Client) StationCreateStationTrack(trackToken, musicType string) (*responses.StationCreateStation, error)

StationCreateStationTrack creates a new station from a specified track. Argument trackToken is a token of a song or artist obtained from Client.StationGetPlaylist. Argument musicType is either "song" or "artist" specifying the type of track being used. Calls API method "station.createStation".

func (*Client) StationDeleteFeedback

func (c *Client) StationDeleteFeedback(feedbackID string) error

StationDeleteFeedback deletes feedback (thumbs up/down) on a track's feedback ID. Calls API method "station.deleteFeedback".

func (*Client) StationDeleteMusic

func (c *Client) StationDeleteMusic(seedID string) error

StationDeleteMusic removes seed music identified by a seedID from a station. Calls API method "station.deleteMusic".

func (*Client) StationDeleteStation

func (c *Client) StationDeleteStation(stationToken string) error

StationDeleteStation removes a station identified by a stationToken. Calls API method "station.deleteStation".

func (*Client) StationGetGenreStations

func (c *Client) StationGetGenreStations() (*responses.StationGetGenreStations, error)

StationGetGenreStations retrieves a list of predefined "genre stations". Calls API method "station.getGenreStations".

func (*Client) StationGetPlaylist

func (c *Client) StationGetPlaylist(stationToken string) (*responses.StationGetPlaylist, error)

StationGetPlaylist retrieves a playlist for a specified token. Argument stationToken is obtained from UserGetStationList. Note: an error response with code 0 may mean you've called getPlaylist too much. Calls API method "station.getPlaylist".

func (*Client) StationGetStation

func (c *Client) StationGetStation(stationToken string, includeExtendedAttributes bool) (*responses.StationGetStation, error)

StationGetStation retrieves station details. Argument stationToken is obtained from Client.UserGetStationList Argument includeExtendedAttributes will include music seed and feedback IDs in response. Calls API method "station.getStation".

func (*Client) StationRenameStation

func (c *Client) StationRenameStation(stationToken, stationName string) (*responses.StationRenameStation, error)

StationRenameStation sets a new name for a station. Calls API method "station.renameStation".

func (*Client) StationShareStation

func (c *Client) StationShareStation(stationID, stationToken string, emails []string) error

StationShareStation shares a station with provided email addresses. Arguments stationID and stationToken obtained from Client.UserGetStationList Argument emails is a list of email addresses. Calls API method "station.shareStation".

func (*Client) StationTransformSharedStation

func (c *Client) StationTransformSharedStation(stationToken string) (*responses.StationTransformSharedStation, error)

StationTransformSharedStation copies a shared station and creates a user-editable station. Calls API method "station.transformSharedStation".

func (*Client) UserCanSubscribe

func (c *Client) UserCanSubscribe() (*responses.UserCanSubscribe, error)

UserCanSubscribe returns whether a user is subscribed or can subscribe to the premium Pandora One service. Calls API method "user.canSubscribe".

func (*Client) UserCreateUser

func (c *Client) UserCreateUser(username, password, gender, countryCode string, zipCode, birthYear int, emailOptin bool) (*responses.UserCreateUser, error)

UserCreateUser creates a new Pandora user. Argument username must be in the form of an email address. gender must be either "male" or "female". countryCode must be "US". Calls API method "user.createUser".

func (*Client) UserEmailPassword

func (c *Client) UserEmailPassword(username string) error

UserEmailPassword resends the registration email. Calls API method "user.emailPassword".

func (*Client) UserGetBookmarks

func (c *Client) UserGetBookmarks() (*responses.UserGetBookmarks, error)

UserGetBookmarks returns the user's bookmarked artists and songs. Also see BookmarkAddArtistBookmark and BookmarkAddSongBookmark. Calls API method "user.getBookmarks".

func (*Client) UserGetStationList

func (c *Client) UserGetStationList(includeStationArtURL bool) (*responses.UserGetStationList, error)

UserGetStationList gets the list of a user's stations. Calls API method "user.getStationList".

func (*Client) UserGetStationListChecksum

func (c *Client) UserGetStationListChecksum() (*responses.UserGetStationListChecksum, error)

UserGetStationListChecksum returns the checksum of the user's station list. Calls API method "user.getStationListChecksum".

func (*Client) UserSetQuickMix

func (c *Client) UserSetQuickMix(stationIDs []string) error

UserSetQuickMix selects the stations that should be in the special QuickMix station. Calls API method "user.setQuickMix".

func (*Client) UserSleepSong

func (c *Client) UserSleepSong(trackToken string) error

UserSleepSong marks a song to not be played again for 1 month. Calls API method "user.sleepSong".

type ClientDescription

type ClientDescription struct {
	DeviceModel string
	Username    string
	Password    string
	BaseURL     string
	EncryptKey  string
	DecryptKey  string
	Version     string
}

ClientDescription describes a particular type of client to emulate.

Directories

Path Synopsis
Package requests provides structs for use with json.Marshal when sending requests to the Pandora API.
Package requests provides structs for use with json.Marshal when sending requests to the Pandora API.
Package responses provides structs used with json.Unmarshal in processing responses from the Pandora API.
Package responses provides structs used with json.Unmarshal in processing responses from the Pandora API.

Jump to

Keyboard shortcuts

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