UNPKG

6.77 kBMarkdownView Raw
1# node-tvdb
2
3[![wercker status](https://app.wercker.com/status/19dcad373ede868e37754a0367d68382/s/master "wercker status")](https://app.wercker.com/project/bykey/19dcad373ede868e37754a0367d68382)
4
5Node.js library for accessing [TheTVDB API](http://www.thetvdb.com/wiki/index.php/Programmers_API). Refactored from [joaocampinhos/thetvdb-api](https://github.com/joaocampinhos/thetvdb-api) to give nicer output and lots of additional features.
6
7Pull requests are always very welcome.
8
9## Features
10
11- Handle errors from API as JavaScript errors
12- Only returns relevant data (no need to call response.Data.Series etc.)
13- Set language at initialisation or afterwards when needed
14- Normalised keys and values
15- Empty values parsed as null
16- Updates endpoint grouped by type
17- Supports both node callback functions and promises
18- Utility function to parse TheTVDB API's pipe list (e.g. "|Name|Name|Name|Name|")
19- Use zip data instead of straight xml where possible
20- [Tests with Mocha and Wercker CI](https://app.wercker.com/#applications/53f155d02094f9781d058f98)
21
22## Installation
23
24Install with [npm](http://npmjs.org/):
25
26``` shell
27npm install --save node-tvdb
28```
29
30And run tests with [Mocha](http://visionmedia.github.io/mocha/):
31
32``` shell
33TVDB_KEY=[YOUR API KEY HERE] npm test
34```
35
36> _Mocha is installed as a development dependency; you do not need to install it globally to run the tests._
37
38## Example Usage
39
40To start using this library you first need an API key. You can request one [here](http://thetvdb.com/?tab=apiregister). Then just follow this simple example that fetches all the shows containing "The Simpsons" in the name.
41
42``` javascript
43var TVDB = require("node-tvdb");
44var tvdb = new TVDB("ABC123");
45
46tvdb.getSeriesByName("The Simpsons", function(err, response) {
47 // handle error and response
48});
49```
50
51## API
52
53### var client = new Client(API_KEY, [language])
54
55Set up tvdb client with API key and optional language (defaults to "en")
56
57``` javascript
58var Client = require("node-tvdb");
59
60var tvdb = new Client("ABC123"); // lang defaults to "en"
61var tvdbPortuguese = new Client("ABC123", "pt");
62```
63
64### getTime
65
66Get the current server time
67
68``` javascript
69tvdb.getTime(function(error, response) {
70 // handle error and response
71});
72```
73
74OR
75
76``` javascript
77tvdb.getTime()
78 .then(function(response) { /* handle response */ })
79 .catch(function(error) { /* handle error */ });
80```
81
82### getLanguages
83
84Get available languages useable by TheTVDB API
85
86``` javascript
87tvdb.getLanguages(function(error, response) {
88 // handle error and response
89});
90```
91
92OR
93
94``` javascript
95tvdb.getLanguages()
96 .then(function(response) { /* handle response */ })
97 .catch(function(error) { /* handle error */ });
98```
99
100### getSeriesByName
101
102Get basic series information by name
103
104``` javascript
105tvdb.getSeriesByName("Breaking Bad", function(error, response) {
106 // handle error and response
107});
108```
109
110OR
111
112``` javascript
113tvdb.getSeriesByName("Breaking Bad")
114 .then(function(response) { /* handle response */ })
115 .catch(function(error) { /* handle error */ });
116```
117
118### getSeriesById
119
120Get basic series information by id
121
122``` javascript
123tvdb.getSeriesById(73255, function(error, response) {
124 // handle error and response
125});
126```
127
128OR
129
130``` javascript
131tvdb.getSeriesById(73255)
132 .then(function(response) { /* handle response */ })
133 .catch(function(error) { /* handle error */ });
134```
135
136### getSeriesByRemoteId
137
138Get basic series information by remote id (zap2it or imdb)
139
140``` javascript
141tvdb.getSeriesByRemoteId("tt0903747", function(error, response) {
142 // handle error and response
143});
144```
145
146OR
147
148``` javascript
149tvdb.getSeriesByRemoteId("tt0903747")
150 .then(function(response) { /* handle response */ })
151 .catch(function(error) { /* handle error */ });
152```
153
154> Note: `node-tvdb` automatically selects between remote providers (IMDb and zap2it)
155
156### getSeriesAllById
157
158Get full/all series information by id
159
160``` javascript
161tvdb.getSeriesAllById(73255, function(error, response) {
162 // handle error and response
163});
164```
165
166OR
167
168``` javascript
169tvdb.getSeriesAllById(73255)
170 .then(function(response) { /* handle response */ })
171 .catch(function(error) { /* handle error */ });
172```
173
174### getEpisodesById
175
176Get all episodes by series id
177
178``` javascript
179tvdb.getEpisodesById(153021, function(error, response) {
180 // handle error and response
181});
182```
183
184OR
185
186``` javascript
187tvdb.getEpisodesById(153021)
188 .then(function(response) { /* handle response */ })
189 .catch(function(error) { /* handle error */ });
190```
191
192### getEpisodeById
193
194Get episode by episode id
195
196``` javascript
197tvdb.getEpisodeById(4768125, function(error, response) {
198 // handle error and response
199});
200```
201
202OR
203
204``` javascript
205tvdb.getEpisodeById(4768125)
206 .then(function(response) { /* handle response */ })
207 .catch(function(error) { /* handle error */ });
208```
209
210### getEpisodeByAirDate
211
212Get series episode by air date
213
214``` javascript
215tvdb.getEpisodeByAirDate(153021, "2011-10-03", function(error, response) {
216 // handle error and response
217});
218```
219
220OR
221
222``` javascript
223tvdb.getEpisodeByAirDate(153021, "2011-10-03")
224 .then(function(response) { /* handle response */ })
225 .catch(function(error) { /* handle error */ });
226```
227
228### getActors
229
230Get series actors by series id
231
232``` javascript
233tvdb.getActors(73255, function(error, response) {
234 // handle error and response
235});
236```
237
238OR
239
240``` javascript
241tvdb.getActors(73255)
242 .then(function(response) { /* handle response */ })
243 .catch(function(error) { /* handle error */ });
244```
245
246### getBanners
247
248Get series banners by series id
249
250``` javascript
251tvdb.getBanners(73255, function(error, response) {
252 // handle error and response
253});
254```
255
256OR
257
258``` javascript
259tvdb.getBanners(73255)
260 .then(function(response) { /* handle response */ })
261 .catch(function(error) { /* handle error */ });
262```
263
264### getUpdates
265
266Get series and episode updates since a given unix timestamp
267
268``` javascript
269tvdb.getUpdates(1400611370, function(error, response) {
270 // handle error and response
271});
272```
273
274OR
275
276``` javascript
277tvdb.getUpdates(1400611370)
278 .then(function(response) { /* handle response */ })
279 .catch(function(error) { /* handle error */ });
280```
281
282### getUpdateRecords
283
284All updates within the given interval
285
286``` javascript
287tvdb.getUpdateRecords("day", function(error, response) {
288 // handle error and response
289});
290```
291
292OR
293
294``` javascript
295tvdb.getUpdateRecords("day")
296 .then(function(response) { /* handle response */ })
297 .catch(function(error) { /* handle error */ });
298```
299
300### utils.parsePipeList
301
302Parse pipe list string to javascript array
303
304``` javascript
305var list = "|Mos Def|Faune A. Chambers|"; // from a previous api call
306var guestStars = Client.utils.parsePipeList(list);
307```
308
309## License
310
311The MIT License (MIT)