Jump To …

pandata

Pandora scraper

Version

0.0.1

Author

Will Mayner <wmayner@gmail.com> (http://www.willmayner.com)

Repository

git - https://github.com/willmayner/pandata

Dependencies

  • URIjs *
  • request *
  • cheerio *
  • when *

Stats

http://cloc.sourceforge.net v 1.55  T=0.5 s (8.0 files/s, 1040.0 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
CoffeeScript                     4             64            195            261
-------------------------------------------------------------------------------
SUM:                             4             64            195            261
-------------------------------------------------------------------------------

pandata

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.

Usage

As a library

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.

A note on promises

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.

As a command-line tool

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.

Credits

The original ruby version was written by Brian Ustas.

generated Sun May 18 2014 23:57:48 GMT-0500 (CDT)