tvdb.js

1.0.7 • Public • Published

tvdb.js

Build Status Coverage Status NPM Downloads license XO code style

NPM

Node.js wrapper for thetvdb.com API. It is promise-based and uses the ES6 syntax (you must at least use the stable version of Node.js).

  • Promise-based
  • Abstracts all the unnecessary data structure returned from thetvdb.com API
  • Lowercase attributes
  • Returns the season & episode numbers as integers
  • Multi-language support

Installation

npm install tvdb.js

Initialization

const tv = require('tvdb.js')('API_KEY')

Retrieve a show

Retrieve a show using its ID:

tv.find('80279')

Retrieve a show using its name:

tv.find('The Big Bang Theory')

You can specify an optional language parameter (english by default), for example:

tv.find('The Big Bang Theory', 'fr')

Retrieve a show episodes

The query below returns the show as well as all the episodes:

tv.find('The Big Bang Theory')
.then(serie => {
  console.log('Name', serie.name)
  console.log('Overview', serie.overview)
  console.log('Episodes count', serie.episodes.length)
 
  // Make use of the native find Javascript function to filter the episodes
  const episode = serie.episodes.find(ep => ep.name == 'The Robotic Manipulation')
  console.log('Episode Name', episode.name) // The Robotic Manipulation
 
  // Access the episode's season and number
  console.log('Season', episode.season)
  console.log('Number', episode.number)
})
.catch(err => console.error(err)) // Failed to fetch the serie

You can also use the await keyword (this is an ES6 feature):

try {
  const show = await tv.find('The Big Bang Theory')
  console.log('Name', show.name)
  console.log('Overview', show.overview)
  console.log('Episodes count', show.episodes.length)
 
  // Make use of the native find Javascript function to filter the episodes
  const episode = show.episodes.find(ep => ep.name == 'The Robotic Manipulation')
  console.log('Episode Name', episode.name) // The Robotic Manipulation
 
  // Access the episode's season and number
  console.log('Season', episode.season)
  console.log('Number', episode.number)
} catch (err) {
  console.error(err) 
}

Licence

MIT

Package Sidebar

Install

npm i tvdb.js

Weekly Downloads

3

Version

1.0.7

License

MIT

Unpacked Size

15.7 kB

Total Files

8

Last publish

Collaborators

  • said