New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eztvapi

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eztvapi

A client for the Popcorn TV shows API, eztvapi.re

2.0.1
latest
Source
npm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

eztvapi

Build Status Codebeat badge Codacy Badge Maintainability Coverage Status

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.

import * as eztvapi from 'eztvapi';

const client = eztvapi.createClient();

async function getAllShows() {
  let allShows = [];
  async function fetchShows(page) {
    const shows = await client.getShows(page);
    allShows = [
      ...allShows,
      ...shows,
    ];

    if (!shows.length) {
      return allShows;
    }

    return fetchShows(page + 1);
  }

  const shows = await fetchShows(1);
  return Promise.all(shows.map(show => client.getShow(show.id)));
}

const shows = await getAllShows();

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

client = eztvapi.createClient(options?: EztvApiClientOptions): EztvApiClient

Create a new API client.

Arguments

  • options
    • endpoint (string; optional; default: https://api-fetch.website/tv): HTTP or HTTPS endpoint of the API
    • rateLimitRequests (number; optional; default: 1) Rate limit number of requests per interval
    • rateLimitInterval (number; optional; default: 1000) Rate limit interval

Returns

Returns a new EztvApiClient instance.

Example

// client with 1000 requests per minute rate limit
const client = eztvapi.createClient({
  rateLimitRequests: 1000,
  rateLimitInterval: 60 * 1000,
});
shows = await client.getShows(pageNumber?: number): Promise<Array<ShowStub>>

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.getShows(6);
console.log(shows.map(show => show.title));
show = await client.getShow(id: string): Promise<?Show>

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.getShow('tt0944947');
if (show) {
  console.log(show.title);
}

License

Copyright (c) 2015 - 2017 Max Kueng

MIT License

Keywords

eztv

FAQs

Package last updated on 19 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts