gopiano

package module
v0.0.0-...-7b1fa67 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2019 License: BSD-2-Clause Imports: 13 Imported by: 3

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

This section is empty.

Functions

This section is empty.

Types

type Client

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

Class for a Client object.

func NewClient

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

Create a new Client with specified ClientDescription

func (*Client) AuthPartnerLogin

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

Client.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)

Client.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 string, method string, body io.Reader, data interface{}) error

Client.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)

Client.AddArtistBookmark 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)

Client.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)

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

func (*Client) GetSyncTime

func (c *Client) GetSyncTime() int

Most calls require a SyncTime int argument (Unix epoch). We store our current time offset but must calculate the SyncTime for each call. This method does that.

func (*Client) MusicSearch

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

Client.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 string, method string, body io.Reader, data interface{}) error

Client.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)

Client.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)

Client.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)

Client.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)

Client.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

Client.StationDeleteFeedback deletes feedback (thumbs up/down) on a particular tracks feedback ID. Calls API method "station.deleteFeedback"

func (*Client) StationDeleteMusic

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

Client.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

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

func (*Client) StationGetGenreStations

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

Client.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)

Client.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. Calls API method "station.getPlaylist"

func (*Client) StationGetStation

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

Client.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)

Client.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

Client.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)

Client.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)

Client.UserCanSubscribe returns whehter 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)

Client.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

Client.UserEmailPassword resends registration email, maybe? Calls API method "user.emaillPassword"

func (*Client) UserGetBookmarks

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

Client.UserGetBookmarks returns the users 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)

Client.UserGetStationList gets the list of a users stations. Call API method "user.getStationList"

func (*Client) UserGetStationListChecksum

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

Client.UserGetStationList returns the checksum of the user's station list. Call API method "user.getStationListChecksum"

func (*Client) UserSetQuickMix

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

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

func (*Client) UserSleepSong

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

Client.UserSleepSong marks a song to be not 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
}

Describes a particular type of client to emulate.

var AndroidClient ClientDescription = 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",
}

The data for the Android client.

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