This is a Node.js port of Brian Ustas's Pandata module, originally written for Ruby. Node.js is asynchronous, making this module significantly faster than the original. Promises are used to handle sequential and parallel asynchronous requests.
It is a library for downloading a user's Pandora.com data. This data includes:
- Playing Station*
- Recent Activity*
- Stations*
- Bookmarks (artists, tracks)*
- Likes (albums, artists, stations, tracks)
- Followers
- Following
Where possible, Pandora feeds are used (indicated by an asterisk above).
Pandata can only access public Pandora profiles (profiles are public by default). Users can make their profiles private in Pandora's settings.
First, grab a Pandora webname from an email address, and create a new Pandata scraper for that user:
Pandata = require 'pandata'
# Pandata.get takes either an email or a Pandora webname, and a callback to
# execute once a webname is retrieved
Pandata.get 'wmayner@gmail.com', (webname) ->
# Create a new scraper for the user
wills_scraper = new Pandata(webname)
Next, use the API to scrape data. The API methods return promises for the data. Use them like so:
# Get recent activity
wills_scraper.recent_activity()
.then(
# The promise resolved successfully
(data) ->
console.log "Will's recent activity on Pandora:"
console.log data
# Do something with the data
# The promise was rejected for some reason
(reason) ->
console.log "Something went wrong!"
console.error reason
# Error handling
)
# Get only liked tracks
wills_scraper.likes('tracks')
.then(
# The promise resolved successfully
(data) ->
console.log "Tracks Will likes on Pandora:"
console.log data
# Do something with the data
# The promise was rejected for some reason
(reason) ->
console.log "Something went wrong!"
console.error reason
# Error handling
)
For more information on the API methods and the data returned, refer to the the API documentation.
Pandata's promises are generated by when, are thus thenable, and in full compliance with the Promises/A+ spec. This means they can be used with any promise implementation that is also compliant.
See when's documentation for more information.
If you need to use Pandata on the command line, then there's no need for a Node.js version, since the Ruby version provides CLI functionality. See the instructions on how to install the original Ruby version in the Pandata repository.
The original ruby version was written by Brian Ustas.