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 --devTVDB_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.jsvar TVDB = ;var tvdb = "ABC123";tvdb;
// (TypeScript) index.ts;tvdb.getSeriesByName"The Simpsons",
API
var client = new Client(API_KEY, [language])
Set up tvdb client with API key and optional language (defaults to "en")
;; // lang defaults to "en";
getTime
Get the current server time
tvdb.getTime;
OR
tvdb.getTime.then.catch;
getLanguages
Get available languages useable by TheTVDB API
tvdb.getLanguages;
OR
tvdb.getLanguages.then.catch;
getSeriesByName
Get basic series information by name
tvdb.getSeriesByName"Breaking Bad",;
OR
tvdb.getSeriesByName"Breaking Bad".then.catch;
getSeriesById
Get basic series information by id
tvdb.getSeriesById73255,;
OR
tvdb.getSeriesById73255.then.catch;
getSeriesByRemoteId
Get basic series information by remote id (zap2it or imdb)
tvdb.getSeriesByRemoteId"tt0903747",;
OR
tvdb.getSeriesByRemoteId"tt0903747".then.catch;
Note:
tvdb.ts
automatically selects between remote providers (IMDb and zap2it)
getSeriesAllById
Get full/all series information by id
tvdb.getSeriesAllById73255,;
OR
tvdb.getSeriesAllById73255.then.catch;
getEpisodesById
Get all episodes by series id
tvdb.getEpisodesById153021,;
OR
tvdb.getEpisodesById153021.then.catch;
getEpisodeById
Get episode by episode id
tvdb.getEpisodeById4768125,;
OR
tvdb.getEpisodeById4768125.then.catch;
getEpisodeByAirDate
Get series episode by air date
tvdb.getEpisodeByAirDate153021, "2011-10-03",;
OR
tvdb.getEpisodeByAirDate153021, "2011-10-03".then.catch;
getActors
Get series actors by series id
tvdb.getActors73255,;
OR
tvdb.getActors73255.then.catch;
getBanners
Get series banners by series id
tvdb.getBanners73255,;
OR
tvdb.getBanners73255.then.catch;
getUpdates
Get series and episode updates since a given unix timestamp
tvdb.getUpdates1400611370,;
OR
tvdb.getUpdates1400611370.then.catch;
getUpdateRecords
All updates within the given interval
tvdb.getUpdateRecords"day",;
OR
tvdb.getUpdateRecords"day".then.catch;
utils.parsePipeList
Parse pipe list string to javascript array
; // from a previous api call;
License
The MIT License (MIT)