eztvapi
A Node.js client for the Popcorn API used in PopcornTime.
Features
- Promise-based API
- Built-in rate limiting
- Flow typed
- Easy to use
Installation
npm install --save eztvapi
Example
Here's an example how to fetch all the shows with all the episodes.
; const client = eztvapi; { let allShows = ; { const shows = await client; allShows = ...allShows ...shows ; if !showslength return allShows; return ; } const shows = await ; return Promiseallshows;} const shows = await ;
Documentation
Types
ShowStatus
ShowStatus = 'returning_series' | 'in_production' | 'planned' | 'canceled' | 'ended' | 'unknown';
ShowRating
ShowRating = {
percentage: number;
watching: number;
votes: number;
loved: number;
hated: number;
};
ShowImageSet
ShowImageSet = {
poster: ?string;
fanart: ?string;
banner: ?string;
};
Torrent
Torrent = {
provider: ?string;
peers: number;
seeds: number;
url: ?string;
};
Torrents
Torrents = { [key: string]: Torrent };
Episode
Episode = {
tvdbId: ?string;
title: ?string;
episode: number;
season: number;
firstAired: ?Date;
dateBased: boolean;
overview: ?string;
torrents: ?Torrents;
};
ShowStub
ShowStub = {
id: string;
imdbId: ?string;
tvdbId: ?string;
title: string;
slug: string;
year: ?number;
seasons: ?number;
images: ShowImageSet;
rating: ?ShowRating;
};
Show
Show = {
id: string;
imdbId: ?string;
tvdbId: ?string;
title: string;
slug: string;
year: ?number;
synopsis: ?string;
runtime: ?number;
country: ?string;
network: ?string;
airDay: ?string;
airTime: ?string;
status: ShowStatus;
seasons: ?number;
lastUpdated: ?Date;
episodes: Array<Episode>;
genres: Array<string>;
images: ShowImageSet;
rating: ?ShowRating;
};
EztvApiClient
EztvApiClient = {
getShows: (pageNumber?: number) => Promise<Array<ShowStub>>;
getShow: (id: string) => Promise<?Show>;
};
EztvApiClientOptions
EztvApiClientOptions = {
endpoint?: string;
rateLimitRequests?: number;
rateLimitInterval?: number;
};
API
EztvApiClientOptions): EztvApiClient
client = eztvapi.createClient(options?:Create a new API client.
Arguments
options
endpoint
(string; optional; default: https://api-fetch.website/tv): HTTP or HTTPS endpoint of the APIrateLimitRequests
(number; optional; default: 1) Rate limit number of requests per intervalrateLimitInterval
(number; optional; default: 1000) Rate limit interval
Returns
Returns a new EztvApiClient instance.
Example
// client with 1000 requests per minute rate limitconst client = eztvapi;
ShowStub>>
shows = await client.getShows(pageNumber?: number): Promise<Array<Arguments
pageNumber
(number; optional; default: 1): Number of the requested page
Returns
A Promise
that resolves with an array of ShowStub. Note that if
the there are no entries on a given page it will return an empty array and not
throw.
Example
const shows = await client;console;
Show>
show = await client.getShow(id: string): Promise<?Get detailed information about a TV show including the list of episodes and magnet links.
Arguments
id
(string; required): The ID of the requested show
Returns
A Promise
that resolves with a Show object. Note that if the show
could not be found it resolves with null
and does not throw.
Example
const show = await client;if show console;
License
Copyright (c) 2015 - 2017 Max Kueng
MIT License