A client for the Popcorn TV Shows API (eztvapi.re).
npm install eztvapi --save
To see what the result of each function looks like check out the Popcorn API docs.
Create an API client object.
The client has built-in rate limiting functionality. By default it limits API calls to one request per second. You can change it by passing the right options.
var eztvapi = require('eztvapi');
var eztv = eztvapi({
apiLimitRequests: 10, // 10 requests
apiLimitInterval: 60000 // per minute
});
apiUrl
(optional; default: http://eztvapi.re): The base URL of the API. Note that there is no slash at the end.apiLimitRequests
(optional; default: 1): The maximum number of requests per a given interval.apiLimitInterval
(optional; default: 1000): The duration in milliseconds
Get a list of TV shows (paginated, 50 per page).
var eztv = require('eztvapi')();
var page = 1;
eztv.getShows(page, function (err, shows) {
if (err) { return console.log('No such page or something went wrong'); }
console.log(shows);
});
Create a stream that emits every show.
var eztv = require('eztvapi')();
var stream = eztv.createShowsStream();
stream.on('data', function (show) {
console.log(show);
});
stream.on('end', function () {
console.log('All done');
});
var through = require('through2').obj;
var eztv = require('eztvapi')();
var shows = eztv.createShowsStream();
var log = through(function (show, encoding, callback) {
console.log(show.title);
callback();
});
shows
.pipe(log);
Get information about a show including episodes and seasons by its IMDB ID (imdb_id
).
var eztv = require('eztvapi')();
var imdbId = 'tt0944947';
eztv.getShow(imdbId, function (err, show) {
if (err) { return console.log('No such show or something'); }
console.log(show.title);
// Game of Thrones
});
MIT