Package: pydora
This code is licensed under the MIT license. The code is maintained onGitHub.This is a reasonably complete implementation of the Pandora API in pure Python
that supports Python 3.5+. It contains a complete implementation of the core
radio features but does not implement account management or Pandora Plus
functionality; pull requests adding that functionality are welcomed from anyone
needing those features.Keys or passwords for Pandora arenotprovided in this repo, you’ll have togo get thosefor yourself. Make something awesome with this library, don’t abuse Pandora,
that’s not cool.Project CompleteThis projectis actively maintainedbut the author considers it to be both
stable and complete. There will be very few new changes initiated by the author
outside of bug fixes and security updates.If you run into a problem, file an issue and we’ll respond. Pull requests for
new features and fixes will be reviewed and accepted if they meet our criteria
for stability, see below for contributing instructions.CompatibilityThis is the2.xseries which supports only Python 3.5+. For older versions
of Python please use the1.xseries. The1.xseries is no longer
maintained but pull requests to fix bugs are still welcomed.This package uses semantic versioning. The API is guaranteed to be stable
within a major version release. Please constrain your dependencies to major
versions. For example, to depend on version2.xuse this line in your
setup.pyinstall_requires:pydora>=2,<3InstallingInstalling is as simple as using pip and running the built-in configuration
command to create a~/.pydora.cfgfile. If you already have aPianoBarconfig file Pydora will automatically use
that.$ pip install pydora
$ pydora-configureOn Ubuntu installvlcorvlc:# apt-get install vlcTo install VLC on Mac OS X visit theVLC siteto downloadVLC.app, then drag-and-drop
the bundle into your/Applicationsfolder. Pydora will auto-detect this.Audio Output Back-endThepydoraplayer does not directly support audio output but instead relies
upon external audio output back-ends. The two supported back-ends are VLC and
mpg123. The main difference between the two back-ends is the supported file
formats. VLC supports a vast array of codecs, including MP3 and AAC, the two
formats that Pandora uses. mpg123 on the other hand supports only MP3. As of
2017 Pandora has started to prefer AAC files over MP3 which necessitates VLC.
Thepydoraplayer will try to auto-detect whatever player exists on your
system, preferring VLC, and will use that audio output back-end. If you notice
a lot of skipping in a playlist consider installing VLC.Remote VLC Back-endIt is also possible to remotely control a copy of VLC running on another
machine if you’re unable or unwilling to install Pydora on your playback
machine. To do this start VLC on the remote machine with therc-hostoption
set. For example:vlc -I rc --advanced --rc-host=0.0.0.0:1234Once VLC is running start Pydora with thevlc-netoption and specify the
remote host and port that VLC is listening on. For example:pydora --vlc-net 192.168.0.12:1234Pydora will now send all audio playback requests to the remote VLC. It does
this using a text control protocol; all audio data is streamed directly from
the internet to VLC and is not passed over the Pydora control channel. Because
of this it is possible for the control channel to run over a very low bandwidth
connection.Note: VLC doesn’t provide any security so anyone on the network will be
able to control VLC. It is generally safer to bind VLC to127.0.0.1and use
something like SSH forwarding to securely forward the port to a remote host but
that’s outside of the scope of this README.Simple PlayerIncluded ispydora, a simple Pandora stream player that runs at the command
line. It requires that mpg123 or VLC be installed with HTTP support as well as
a settings file (example below) located in~/.pydora.cfg. Alternatively an
environment variablePYDORA_CFGcan point to the path of the config file.The player only supports basic functionality for now. It will display a station
list, allow listening to any station, basic feedback and bookmarking are also
supported. The player starts an mpg123 or VLC process in remote control mode
and feeds commands to it. It does not download any music but rather streams
them directly from Pandora.When playing the following keys work (press enter afterwards):n- next songp- pause or resume songs- station list (stops song)d- thumbs down tracku- thumbs up trackb- bookmark songa- bookmark artistS- sleep songQ- quit programvu- volume upvd- volume down?- display helpNote: volume control is currently only supported with the VLC back-end.Sample Config FileThe built-inpydora-configurescript can be run to create a configuration
file automatically if you don’t already have one. This will download the keys
from the link below and pick a suitable one when writing the config file. If
you want to create the config file manually the format is:[api]
api_host = hostname
encryption_key = key
decryption_key = key
username = partner username
password = partner password
device = key
default_audio_quality = mediumQuality

[user]
username = your username
password = your passworddefault_audio_qualityDefault audio quality to request from the API; can be one oflowQuality,mediumQuality(default), orhighQuality. If the preferred audio quality
is not available for the device specified, then the next-highest bit-rate
stream that Pandora supports for the chosen device will be used.Programmatic UseThe Pydora distribution contains two python packages. Thepandorapackageis the API for interacting with the Pandora service. Thepydorapackageis
a very small reference implementation of using the API to drive a command line
player. If you’re interested in the command line skip this section and read
Installing below to get started.The easiest way to get started is by using thepandora.clientbuilderpackage. This package contains a set of factories that can be used to build a
Pandora client with some configuration. The classes in the package that end inBuilderare the factories and the rest of the classes are implementation
details. All of the builders will return an instance ofpandora.client.APIClientthat is completely configured and ready for use in
your program.If you have an existing program and would like to connect to Pandora the
easiest way is to use theSettingsDictBuilderclass like so:client = SettingsDictBuilder({
    "DECRYPTION_KEY": "see_link_above",
    "ENCRYPTION_KEY": "see_link_above",
    "PARTNER_USER": "see_link_above",
    "PARTNER_PASSWORD": "see_link_above",
    "DEVICE": "see_link_above",
}).build()

client.login("username", "password")At this point the client is ready for use, seepandora.client.APIClientfor
a list of methods that can be called. All responses from the API will return
Python objects from thepandora.models.pandorapackage or raise exceptions
frompandora.errorsFor a more functional example look at the filepydora/player.pywhich shows
how to use the API in a simple command line application.Pandora API Spec and Partner KeysIf you’re interested in the underlying API or need to download the keys
yourself you can find more details at the links below. This documentation is
community maintained and not official.API SpecPartner KeysContributingSeeCONTRIBUTINGContributorsThanks to the contributors who make Pydora possible by adding features and
fixing bugs. List is organized by date of first contribution.Mike Crute (@mcrute)John Cass (@jcass77)Thomas Weißschuh (@t-8c)Skybound1 (@Skybound1)Hugo (@hugovk)mspencer92 (@mspencer92)