npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-pbs-tv-schedules

v0.3.0

Published

Node module implementing the PBS TV Schedules V2 and Locator APIs

Downloads

22

Readme

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

Build Status

Prerequisites

Install

$ npm install node-pbs-tv-schedules

Or

$ git clone [email protected]: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 = require('../'),
    moment = require('moment'),
    options = {};

options.api_key =  process.env.PBS_TV_SCHEDULES_API_KEY || null;
options.log_level = "info";

var pbsAPI = new PBSTvSchedules(options);
var zip = 94110;

// Promises example
pbsAPI.get_callsigns_by_zip(zip)
.then(function (stations){
    pbsAPI.logger.info("get_callsigns_by_zip", stations);
}, function(err){
    pbsAPI.logger.error(err);
});

// Async example
pbsAPI.get_callsigns_by_zip_async(zip, function(err, stations){
    var logger = pbsAPI.logger;
    logger.info("get_callsigns_by_zip_async", stations);
});

// Get upcomings on KQED for show_id
var show_id = 3190;
pbsAPI.get_upcoming_by_callsign_program_id('kqed', show_id)
.then(function(results){
    pbsAPI.logger.info("Title for first airing episode of show_id " + show_id, results.upcoming_episodes[0].episode_title);
})
.catch(function(err){
    pbsAPI.logger.error(err);
})
.done();

// Get a zipcode for an ip address
var ip = '8.8.8.8';
pbsAPI.get_zip_from_ip(ip)
.then(function(results){
    pbsAPI.logger.info("Zip code for ip " + ip + " is", results.$items[0].zipcode);
})
.catch(function(err){
    pbsAPI.logger.error(err);
})
.done();

// Get day's listing for KQED
var datestamp = moment().format('YYYYMMDD'),
    callsign = 'kqed';
pbsAPI.get_day_schedule_for_callsign_date(callsign,datestamp)
.then(function(results){
    pbsAPI.logger.info("Found " + results.feeds.length + " channels");
})
.catch(function (err) {
    pbsAPI.logger.error(err);
})
.done();

Tests

Some tests require an api_key.

$ export PBS_TV_SCHEDULES_API_KEY='YOUR_KEY'
$ cd node-pbs-tv-schedules
$ npm test