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 |
|
5 | Node.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 |
|
7 | Pull 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 |
|
24 | Install with [npm](http://npmjs.org/):
|
25 |
|
26 | ``` shell
|
27 | npm install --save node-tvdb
|
28 | ```
|
29 |
|
30 | And run tests with [Mocha](http://visionmedia.github.io/mocha/):
|
31 |
|
32 | ``` shell
|
33 | TVDB_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 |
|
40 | To 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
|
43 | var TVDB = require("node-tvdb");
|
44 | var tvdb = new TVDB("ABC123");
|
45 |
|
46 | tvdb.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 |
|
55 | Set up tvdb client with API key and optional language (defaults to "en")
|
56 |
|
57 | ``` javascript
|
58 | var Client = require("node-tvdb");
|
59 |
|
60 | var tvdb = new Client("ABC123"); // lang defaults to "en"
|
61 | var tvdbPortuguese = new Client("ABC123", "pt");
|
62 | ```
|
63 |
|
64 | ### getTime
|
65 |
|
66 | Get the current server time
|
67 |
|
68 | ``` javascript
|
69 | tvdb.getTime(function(error, response) {
|
70 | // handle error and response
|
71 | });
|
72 | ```
|
73 |
|
74 | OR
|
75 |
|
76 | ``` javascript
|
77 | tvdb.getTime()
|
78 | .then(function(response) { /* handle response */ })
|
79 | .catch(function(error) { /* handle error */ });
|
80 | ```
|
81 |
|
82 | ### getLanguages
|
83 |
|
84 | Get available languages useable by TheTVDB API
|
85 |
|
86 | ``` javascript
|
87 | tvdb.getLanguages(function(error, response) {
|
88 | // handle error and response
|
89 | });
|
90 | ```
|
91 |
|
92 | OR
|
93 |
|
94 | ``` javascript
|
95 | tvdb.getLanguages()
|
96 | .then(function(response) { /* handle response */ })
|
97 | .catch(function(error) { /* handle error */ });
|
98 | ```
|
99 |
|
100 | ### getSeriesByName
|
101 |
|
102 | Get basic series information by name
|
103 |
|
104 | ``` javascript
|
105 | tvdb.getSeriesByName("Breaking Bad", function(error, response) {
|
106 | // handle error and response
|
107 | });
|
108 | ```
|
109 |
|
110 | OR
|
111 |
|
112 | ``` javascript
|
113 | tvdb.getSeriesByName("Breaking Bad")
|
114 | .then(function(response) { /* handle response */ })
|
115 | .catch(function(error) { /* handle error */ });
|
116 | ```
|
117 |
|
118 | ### getSeriesById
|
119 |
|
120 | Get basic series information by id
|
121 |
|
122 | ``` javascript
|
123 | tvdb.getSeriesById(73255, function(error, response) {
|
124 | // handle error and response
|
125 | });
|
126 | ```
|
127 |
|
128 | OR
|
129 |
|
130 | ``` javascript
|
131 | tvdb.getSeriesById(73255)
|
132 | .then(function(response) { /* handle response */ })
|
133 | .catch(function(error) { /* handle error */ });
|
134 | ```
|
135 |
|
136 | ### getSeriesByRemoteId
|
137 |
|
138 | Get basic series information by remote id (zap2it or imdb)
|
139 |
|
140 | ``` javascript
|
141 | tvdb.getSeriesByRemoteId("tt0903747", function(error, response) {
|
142 | // handle error and response
|
143 | });
|
144 | ```
|
145 |
|
146 | OR
|
147 |
|
148 | ``` javascript
|
149 | tvdb.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 |
|
158 | Get full/all series information by id
|
159 |
|
160 | ``` javascript
|
161 | tvdb.getSeriesAllById(73255, function(error, response) {
|
162 | // handle error and response
|
163 | });
|
164 | ```
|
165 |
|
166 | OR
|
167 |
|
168 | ``` javascript
|
169 | tvdb.getSeriesAllById(73255)
|
170 | .then(function(response) { /* handle response */ })
|
171 | .catch(function(error) { /* handle error */ });
|
172 | ```
|
173 |
|
174 | ### getEpisodesById
|
175 |
|
176 | Get all episodes by series id
|
177 |
|
178 | ``` javascript
|
179 | tvdb.getEpisodesById(153021, function(error, response) {
|
180 | // handle error and response
|
181 | });
|
182 | ```
|
183 |
|
184 | OR
|
185 |
|
186 | ``` javascript
|
187 | tvdb.getEpisodesById(153021)
|
188 | .then(function(response) { /* handle response */ })
|
189 | .catch(function(error) { /* handle error */ });
|
190 | ```
|
191 |
|
192 | ### getEpisodeById
|
193 |
|
194 | Get episode by episode id
|
195 |
|
196 | ``` javascript
|
197 | tvdb.getEpisodeById(4768125, function(error, response) {
|
198 | // handle error and response
|
199 | });
|
200 | ```
|
201 |
|
202 | OR
|
203 |
|
204 | ``` javascript
|
205 | tvdb.getEpisodeById(4768125)
|
206 | .then(function(response) { /* handle response */ })
|
207 | .catch(function(error) { /* handle error */ });
|
208 | ```
|
209 |
|
210 | ### getEpisodeByAirDate
|
211 |
|
212 | Get series episode by air date
|
213 |
|
214 | ``` javascript
|
215 | tvdb.getEpisodeByAirDate(153021, "2011-10-03", function(error, response) {
|
216 | // handle error and response
|
217 | });
|
218 | ```
|
219 |
|
220 | OR
|
221 |
|
222 | ``` javascript
|
223 | tvdb.getEpisodeByAirDate(153021, "2011-10-03")
|
224 | .then(function(response) { /* handle response */ })
|
225 | .catch(function(error) { /* handle error */ });
|
226 | ```
|
227 |
|
228 | ### getActors
|
229 |
|
230 | Get series actors by series id
|
231 |
|
232 | ``` javascript
|
233 | tvdb.getActors(73255, function(error, response) {
|
234 | // handle error and response
|
235 | });
|
236 | ```
|
237 |
|
238 | OR
|
239 |
|
240 | ``` javascript
|
241 | tvdb.getActors(73255)
|
242 | .then(function(response) { /* handle response */ })
|
243 | .catch(function(error) { /* handle error */ });
|
244 | ```
|
245 |
|
246 | ### getBanners
|
247 |
|
248 | Get series banners by series id
|
249 |
|
250 | ``` javascript
|
251 | tvdb.getBanners(73255, function(error, response) {
|
252 | // handle error and response
|
253 | });
|
254 | ```
|
255 |
|
256 | OR
|
257 |
|
258 | ``` javascript
|
259 | tvdb.getBanners(73255)
|
260 | .then(function(response) { /* handle response */ })
|
261 | .catch(function(error) { /* handle error */ });
|
262 | ```
|
263 |
|
264 | ### getUpdates
|
265 |
|
266 | Get series and episode updates since a given unix timestamp
|
267 |
|
268 | ``` javascript
|
269 | tvdb.getUpdates(1400611370, function(error, response) {
|
270 | // handle error and response
|
271 | });
|
272 | ```
|
273 |
|
274 | OR
|
275 |
|
276 | ``` javascript
|
277 | tvdb.getUpdates(1400611370)
|
278 | .then(function(response) { /* handle response */ })
|
279 | .catch(function(error) { /* handle error */ });
|
280 | ```
|
281 |
|
282 | ### getUpdateRecords
|
283 |
|
284 | All updates within the given interval
|
285 |
|
286 | ``` javascript
|
287 | tvdb.getUpdateRecords("day", function(error, response) {
|
288 | // handle error and response
|
289 | });
|
290 | ```
|
291 |
|
292 | OR
|
293 |
|
294 | ``` javascript
|
295 | tvdb.getUpdateRecords("day")
|
296 | .then(function(response) { /* handle response */ })
|
297 | .catch(function(error) { /* handle error */ });
|
298 | ```
|
299 |
|
300 | ### utils.parsePipeList
|
301 |
|
302 | Parse pipe list string to javascript array
|
303 |
|
304 | ``` javascript
|
305 | var list = "|Mos Def|Faune A. Chambers|"; // from a previous api call
|
306 | var guestStars = Client.utils.parsePipeList(list);
|
307 | ```
|
308 |
|
309 | ## License
|
310 |
|
311 | The MIT License (MIT)
|