Summary
A node module implementing the PBS TV Schedules API to provide National PBS TV Schedule information and ip to zip locator services.
See
- https://projects.pbs.org/confluence/display/tvsapi/TV+Schedules+Version+2
- https://projects.pbs.org/confluence/display/localization/Locator
Prerequisites
Install
$ npm install node-pbs-tv-schedules
Or
$ git clone git@github.com:KQED/node-pbs-tv-schedules.git
$ cd node-pbs-tv-schedules
$ npm install
Usage
See examples
Custom Request
See examples/custom_request.js
for example of how to craft the PBS TV Schedule Method url.
$ export PBS_TV_SCHEDULES_API_KEY='YOUR_KEY'
$ cd examples
$ node custom_request.js
[2015-07-09T22:53:00.071Z] INFO: node-pbs-tv-schedules/79425 on kip-mbp.kqed.org:
Channels { headends:
[ { feeds: [Object], name: 'AT&T U-verse - San Francisco' },
{ feeds: [Object], name: 'Astound Broadband - San Francisco' },
{ feeds: [Object], name: 'Broadcast TV - Oakland' },
{ feeds: [Object], name: 'Broadcast TV - San Fran-Oak-Sj' },
{ feeds: [Object], name: 'Comcast - San Francisco' },
{ feeds: [Object], name: 'DirecTV - San Francisco-Oak-SJ' },
{ feeds: [Object], name: 'Dish Network - San Francisco-Oak-SJ' },
{ feeds: [Object],
name: 'TVMAX - Bernal Heights - San Francisco' } ] }
...
Built In Functions
There are some built in functions for common actions.
See examples/examples.js
$ export PBS_TV_SCHEDULES_API_KEY='YOUR_KEY'
$ cd node-pbs-tv-schedules
$ npm run example
00:31:43.470Z INFO node-pbs-tv-schedules: Title for first airing episode of show_id 3190 This Perfect World
00:31:43.510Z INFO node-pbs-tv-schedules: Zip code for ip 8.8.8.8 is 94040
00:31:43.517Z INFO node-pbs-tv-schedules: get_callsigns_by_zip [ 'KQED', 'KQEH', 'KRCB' ]
00:31:43.576Z INFO node-pbs-tv-schedules: get_callsigns_by_zip_async [ 'KQED', 'KQEH', 'KRCB' ]
Example Code
var PBSTvSchedules = moment = options = {}; optionsapi_key = processenvPBS_TV_SCHEDULES_API_KEY || null;optionslog_level = "info"; var pbsAPI = options;var zip = 94110; // Promises examplepbsAPI; // Async examplepbsAPI; // Get upcomings on KQED for show_idvar show_id = 3190;pbsAPI; // Get a zipcode for an ip addressvar ip = '8.8.8.8';pbsAPI; // Get day's listing for KQEDvar datestamp = callsign = 'kqed';pbsAPI;
Tests
Some tests require an api_key.
$ export PBS_TV_SCHEDULES_API_KEY='YOUR_KEY'
$ cd node-pbs-tv-schedules
$ npm test