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

eztvapi

v2.0.1

Published

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

Downloads

36

Readme

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