1.0.7 • Published 6 years ago

tvdb.js v1.0.7

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

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

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago