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

tvdb.ts

v1.6.8

Published

Node.js library for accessing TheTVDB's API

Downloads

2

Readme

tvdb.ts

Node.js library for accessing TheTVDB API. Refactored from edwellbrook/node-tvdb to give TypeScript Completion

Pull requests are always very welcome.

Features

  • Handle errors from API as JavaScript errors
  • Only returns relevant data (no need to call response.Data.Series etc.)
  • Set language at initialisation or afterwards when needed
  • Normalised keys and values
  • Empty values parsed as null
  • Updates endpoint grouped by type
  • Supports both node callback functions and promises
  • Utility function to parse TheTVDB API's pipe list (e.g. "|Name|Name|Name|Name|")
  • Use zip data instead of straight xml where possible
  • Tests with Mocha and Wercker CI

Installation

Install with npm:

npm install --save tvdb.ts

And run tests with Mocha:

npm install --dev
TVDB_KEY=[YOUR API KEY HERE] npm test

Mocha is installed as a development dependency; you do not need to install it globally to run the tests.

Example Usage

To start using this library you first need an API key. You can request one here. Then just follow this simple example that fetches all the shows containing "The Simpsons" in the name.

// (Javascript) index.js
var TVDB = require("tvdb.ts");
var tvdb = new TVDB("ABC123");

tvdb.getSeriesByName("The Simpsons", function(err, response) {
    // handle error and response
});
// (TypeScript) index.ts
import TVDB = require("tvdb.ts");
var tvdb = new TVDB("ABC123")

tvdb.getSeriesByName("The Simpsons", (err, response) => {
    // response is typed ! response.<auto_completion>
})

API

var client = new Client(API_KEY, [language])

Set up tvdb client with API key and optional language (defaults to "en")

import TVDB = require("tvdb.ts");

var tvdb           = new TVDB("ABC123"); // lang defaults to "en"
var tvdbPortuguese = new TVDB("ABC123", "pt");

getTime

Get the current server time

tvdb.getTime((error, response) => {
    // handle error and response
});

OR

tvdb.getTime()
    .then((response) => { /* handle response */ })
    .catch((error) => { /* handle error */ });

getLanguages

Get available languages useable by TheTVDB API

tvdb.getLanguages((error, response) => {
    // handle error and response
});

OR

tvdb.getLanguages()
    .then((response) => { /* handle response */ })
    .catch((error) => { /* handle error */ });

getSeriesByName

Get basic series information by name

tvdb.getSeriesByName("Breaking Bad", (error, response) => {
    // handle error and response
});

OR

tvdb.getSeriesByName("Breaking Bad")
    .then((response) => { /* handle response */ })
    .catch((error) => { /* handle error */ });

getSeriesById

Get basic series information by id

tvdb.getSeriesById(73255, (error, response) => {
    // handle error and response
});

OR

tvdb.getSeriesById(73255)
    .then((response) => { /* handle response */ })
    .catch((error) => { /* handle error */ });

getSeriesByRemoteId

Get basic series information by remote id (zap2it or imdb)

tvdb.getSeriesByRemoteId("tt0903747", (error, response) => {
    // handle error and response
});

OR

tvdb.getSeriesByRemoteId("tt0903747")
    .then((response) => { /* handle response */ })
    .catch((error) => { /* handle error */ });

Note: tvdb.ts automatically selects between remote providers (IMDb and zap2it)

getSeriesAllById

Get full/all series information by id

tvdb.getSeriesAllById(73255, (error, response) => {
    // handle error and response
});

OR

tvdb.getSeriesAllById(73255)
    .then((response) => { /* handle response */ })
    .catch((error) => { /* handle error */ });

getEpisodesById

Get all episodes by series id

tvdb.getEpisodesById(153021, (error, response) => {
    // handle error and response
});

OR

tvdb.getEpisodesById(153021)
    .then((response) => { /* handle response */ })
    .catch((error) => { /* handle error */ });

getEpisodeById

Get episode by episode id

tvdb.getEpisodeById(4768125, (error, response) => {
    // handle error and response
});

OR

tvdb.getEpisodeById(4768125)
    .then((response) => { /* handle response */ })
    .catch((error) => { /* handle error */ });

getEpisodeByAirDate

Get series episode by air date

tvdb.getEpisodeByAirDate(153021, "2011-10-03", (error, response) => {
    // handle error and response
});

OR

tvdb.getEpisodeByAirDate(153021, "2011-10-03")
    .then((response) => { /* handle response */ })
    .catch((error) => { /* handle error */ });

getActors

Get series actors by series id

tvdb.getActors(73255, (error, response) => {
    // handle error and response
});

OR

tvdb.getActors(73255)
    .then((response) => { /* handle response */ })
    .catch((error) => { /* handle error */ });

getBanners

Get series banners by series id

tvdb.getBanners(73255, (error, response) => {
    // handle error and response
});

OR

tvdb.getBanners(73255)
    .then((response) => { /* handle response */ })
    .catch((error) => { /* handle error */ });

getUpdates

Get series and episode updates since a given unix timestamp

tvdb.getUpdates(1400611370, (error, response) => {
    // handle error and response
});

OR

tvdb.getUpdates(1400611370)
    .then((response) => { /* handle response */ })
    .catch((error) => { /* handle error */ });

getUpdateRecords

All updates within the given interval

tvdb.getUpdateRecords("day", (error, response) => {
    // handle error and response
});

OR

tvdb.getUpdateRecords("day")
    .then((response) => { /* handle response */ })
    .catch((error) => { /* handle error */ });

utils.parsePipeList

Parse pipe list string to javascript array

var list = "|Mos Def|Faune A. Chambers|"; // from a previous api call
var guestStars = TVDB.utils.parsePipeList(list);

License

The MIT License (MIT)