gopiano

package module
v0.0.0-...-727117c Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2016 License: BSD-2-Clause Imports: 12 Imported by: 0

README

Pandora.com API Wrapper Client

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

Android, iOS and Air (Desktop) device settings added.

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 https://6xq.net/pandora-apidoc/

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 AirClient = ClientDescription{
	DeviceModel: "D01",
	Username:    "pandora one",
	Password:    "TVCKIBGS9AO9TSYLNNFUML0743LH82D",
	BaseURL:     "internal-tuner.pandora.com/services/json/",
	EncryptKey:  "2%3WCL*JU$MP]4",
	DecryptKey:  "U#IO$RZPAB%VX2",
	Version:     "5",
}

Adobe Air Desktop client (Pandora One)

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",
}

Android OS client

View Source
var IOSClient = ClientDescription{
	DeviceModel: "IP01",
	Username:    "iphone",
	Password:    "P2E4FC0EAD3*878N92B2CDp34I0B1@388137C",
	BaseURL:     "tuner.pandora.com/services/json/",
	EncryptKey:  "721^26xE22776",
	DecryptKey:  "20zE1E47BE57$51",
	Version:     "5",
}

iOS client

View Source
var PalmClient = ClientDescription{
	DeviceModel: "pre",
	Username:    "palm",
	Password:    "IUC7IBG09A3JTSYM4N11UJWL07VLH8JP0",
	BaseURL:     "tuner.pandora.com/services/json/",
	EncryptKey:  "%526CBL$ZU3",
	DecryptKey:  "E#U$MY$O2B=",
	Version:     "5",
}

Palm WebOS client

View Source
var VistaClient = ClientDescription{
	DeviceModel: "WG01",
	Username:    "windowsgadget",
	Password:    "EVCCIBGS9AOJTSYMNNFUML07VLH8JYP0",
	BaseURL:     "internal-tuner.pandora.com/services/json/",
	EncryptKey:  "%22CML*ZU$8YXP[1",
	DecryptKey:  "E#IO$MYZOAB%FVR2",
	Version:     "5",
}

Windows Vista Widget client (Pandora One)

View Source
var WinMoClient = ClientDescription{
	DeviceModel: "VERIZON_MOTOQ9C",
	Username:    "winmo",
	Password:    "ED227E10a628EB0E8Pm825Dw7114AC39",
	BaseURL:     "tuner.pandora.com/services/json/",
	EncryptKey:  "v93C8C2s12E0EBD",
	DecryptKey:  "7D671jt0C5E5d251",
	Version:     "5",
}

Windows Mobile

Functions

func PandoraCall

func PandoraCall(callURL string, body io.Reader) (json.RawMessage, error)

PandoraCall is the basic function to send an HTTP POST to pandora.com.

Types

type Client

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

Client information needed to interface with pandora API.

func NewClient

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

NewClient creates a new Client with specified ClientDescription

func (*Client) AuthPartnerLogin

func (c *Client) AuthPartnerLogin() (*response.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.

func (*Client) AuthUserLogin

func (c *Client) AuthUserLogin(username, password string) (*response.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.

func (*Client) BookmarkAddArtistBookmark

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

BookmarkAddArtistBookmark bookmarks an artist. Argument trackToken is a token of a specific artist.

func (*Client) BookmarkAddSongBookmark

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

BookmarkAddSongBookmark bookmarks a song. Argument trackToken is a token of a specific song.

func (*Client) Call

func (c *Client) Call(req request.Type, data interface{}) error

Call makes the given request to pandora and unmarshals the result into the 'data' argument.

func (*Client) ExplainTrack

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

ExplainTrack retrieves an incomplete list of attributes assigned specified son by the Music Genome Project

func (*Client) GetSyncTime

func (c *Client) GetSyncTime() int

GetSyncTime returns a calculated SyncTime (Unix epoch) which is required for most calls.

func (*Client) MusicSearch

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

MusicSearch searches for music, which can be used to create a new or add seeds to a station.

func (*Client) StationAddFeedback

func (c *Client) StationAddFeedback(trackToken string, isPositive bool) (*response.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".

func (*Client) StationAddMusic

func (c *Client) StationAddMusic(musicToken, stationToken string) (*response.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

func (*Client) StationCreateStationMusic

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

StationCreateStationMusic creates a new station from a music search result. Argument musicToken is obtained from Client.MusicSearch.

func (*Client) StationCreateStationTrack

func (c *Client) StationCreateStationTrack(trackToken, musicType string) (*response.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.

func (*Client) StationDeleteFeedback

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

StationDeleteFeedback deletes feedback (thumbs up/down) on a particular tracks feedback ID.

func (*Client) StationDeleteMusic

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

StationDeleteMusic removes seed music identified by a seedID from a station.

func (*Client) StationDeleteStation

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

StationDeleteStation removes a station identified by a stationToken.

func (*Client) StationGetGenreStations

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

StationGetGenreStations retrieves a list of predefined "genre stations".

func (*Client) StationGetPlaylist

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

StationGetPlaylist retrieves a playlist for a specified token. Argument stationToken is a obtained from User.GetStationList. Note: an error response with code 0 may mean you've called getPlaylist too much.

func (*Client) StationGetStation

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

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

func (*Client) StationRenameStation

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

StationRenameStation sets a new name for a station.

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.

func (*Client) StationTransformSharedStation

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

StationTransformSharedStation copies a shared station and creates a user-editable station.

func (*Client) Token

func (c *Client) Token() request.UserToken

Token returns UserToken needed for some requests

func (*Client) UserCanSubscribe

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

UserCanSubscribe returns whehter a user is subscribed or can subscribe to the premium Pandora One service.

func (*Client) UserCreateUser

func (c *Client) UserCreateUser(username, password, gender, countryCode string, zipCode, birthYear int, emailOptin bool) (*response.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".

func (*Client) UserEmailPassword

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

UserEmailPassword resends registration email, maybe?

func (*Client) UserGetBookmarks

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

UserGetBookmarks returns the users bookmarked artists and songs. Also see BookmarkAddArtistBookmark and BookmarkAddSongBookmark.

func (*Client) UserGetStationList

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

UserGetStationList gets the list of a users stations.

func (*Client) UserGetStationListChecksum

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

UserGetStationListChecksum returns the checksum of the user's station list.

func (*Client) UserSetQuickMix

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

UserSetQuickMix selects the stations that should be in the special QuickMix station.

func (*Client) UserSleepSong

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

UserSleepSong marks a song to be not played again for 1 month.

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
Structs for use with json.Marshal when sending requests to the Pandora API.
Structs for use with json.Marshal when sending requests to the Pandora API.
Structs used with json.Unmarshal in processing responses from the Pandora API.
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