Pitchfork Client
An unofficial Node.js client for Pitchfork reviews based on the Pitchfork API Client for Python.
Install
Using NPM
npm install pitchfork
Using Github
git clone git@github.com:omardelarosa/pitchfork-npm.git
You can then use it as a command-line tool or as a node module
API
You can require pitchfork
and use it inside of any Node.JS application.
var p4k =
Search
A Search
constructor that extends EventEmitter. Listeners can be attached to the 'ready' event which will fire when all reviews have been fetched and parsed. For example:
var p = var s = 'wilco' s //=> [ {Review}, {Review}, {Review}, ... ]
.results
An Array
of Review
objects.
.init()
Called once when Search is instantiated to fetch results. Not usually called directly
Page
A Page
constructor that extends EventEmitter. This constructor takes an integer argument specifying which page of reviews you wish to fetch from /reviews/albums/:page_num
. Listeners can be attached to the 'ready' event which will fire when all reviews have been fetched and parsed. For example, this would return all the most recent reviews:
var p = var s = 1 s //=> [ {Review}, {Review}, {Review}, ... ]
Review
The Review
constructor encapsulates methods and data relating to the Pitchfork review. The Review
extends EventEmitter
and fires a 'ready' event when the review has been fetched and parsed.
.attributes
An Object
with information about the album and its text. Sample below:
.fetch()
This method is automatically called when the Review
is instantiated and returns a Promise. This generally isn't called directly.
.promise
This stores the thennable promise object generated by .fetch for attaching .then-style callbacks.
.verbose()
The full Review
instance represented as JSON.
.truncated()
The attributes of the Review
instance with editorial.html/editorial.text condensed into the first 300 characters of of the text assigned to the key '.text'.
.text_pretty_print()
Prints a plain-text representation of the review.
CLI (Command-Line Interface)
Returns a review for a given artist and album title.
$ pitchfork wilco 'yankee hotel foxtrot'# { ... pretty-printed, colorized quasi-JSON object... }
or you can use -a and -t flags.
$ pitchfork -a wilco -t 'yankee hotel foxtrot'# { ... pretty-printed, colorized quasi-JSON object... }
Returns a list of reviews for a given artist with no album.
$ pitchfork -a 'wilco'# [ # { ... pretty-printed, colorized quasi-JSON object... }, # { ... pretty-printed, colorized quasi-JSON object... }, # { ... pretty-printed, colorized quasi-JSON object... } # ]
For valid, uncolored JSON, use the --json flag:
$ pitchfork -a 'wilco' -t 'yankee hotel foxtrot' --json# { ... valid JSON object... }
Flags
flag(s) | required | argument | description |
---|---|---|---|
-a | y | artist_name | returns a review by given artist |
-t | album_title | returns a review by given album title | |
-j,--json | returns review attributes as un-prettified json | ||
-v, --verbose | returns review entire object as json | ||
-V, --version | returns version number | ||
-T,--truncated | returns a truncated json object of the review attributes | ||
-tx,--text | returns a text version of review (ex: to pipe output to 'less' ) | ||
-p | page_number | returns a list of reviews located on the specified page |