Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

imdb-api

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imdb-api - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

test/test-getById.js

64

lib/imdb.js

@@ -75,3 +75,3 @@ var http = require('http');

function onEnd() {
var responseObject
var responseObject;

@@ -100,2 +100,62 @@ try {

}
}
};
module.exports.getById = function(id, cb) {
var responseData = "";
if (typeof(cb) !== "function")
throw new TypeError("cb must be a function");
var intRegex = /^\d+$/;
if(intRegex.test(id)) {
// user give us a raw id we need to prepend it with tt
id = 'tt'+id;
}
var imdbRegex = /^tt\d+$/;
if(! imdbRegex.test(id)) {
throw new TypeError("id must be a an imdb id (tt12345 or 12345)");
}
var myDeanclatworthy;
myDeanclatworthy = extend(myDeanclatworthy, deanclatworthy);
myDeanclatworthy.path += "?" + querystring.stringify({ id: id});
return http.get(myDeanclatworthy, onResponse).on('error', onError);
function onResponse(res) {
return res.on('data', onData).on('error', onError).on('end', onEnd);
}
function onData(data) {
responseData += data;
}
function onEnd() {
var responseObject;
try {
responseObject = JSON.parse(responseData);
} catch (e) {
return cb(e);
}
if (responseObject.hasOwnProperty("code") && responseObject.hasOwnProperty("error")) {
return cb(responseObject.error);
}
if (responseObject.stv === 1 || responseObject.series === 1) {
responseObject.episodes = episodes;
} else {
responseObject.episodes = null;
}
return cb(null, responseObject);
}
function onError(err) {
return cb(err);
}
};

2

package.json

@@ -5,3 +5,3 @@ {

"description": "Queries unofficial imdb APIs to get movie and television information from imdb",
"version": "1.0.1",
"version": "1.1.0",
"main": "lib/imdb.js",

@@ -8,0 +8,0 @@ "homepage": "https://github.com/worr/node-imdb-api",

@@ -39,2 +39,30 @@ # node-imdb-api

Furthermore if you already know the id you can call getById.
var movie;
imdb.getById('0090190', function(err, things) {
movie = things;
});
DATA
console.log(movie);
{ imdbid: 'tt0090190',
imdburl: 'http://www.imdb.com/title/tt0090190/',
genres: 'Action,Comedy,Horror,Sci-Fi',
languages: 'English',
country: 'USA',
votes: '11103',
stv: 0,
series: 0,
rating: '6.0',
runtime: '87min,Canada:78min,USA:82min(unratedversion:DirectorsCut),Argentina:87min(MardelPlataFilmFestival),USA:78min(R-ratedversion)',
title: 'The Toxic Avenger',
year: '1984',
usascreens: 0,
ukscreens: 0,
episodes: null
}
What is this episodes shit?

@@ -41,0 +69,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc