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.2.3 to 1.3.0

test.js

163

defs/node.d.ts
/************************************************
* *
* Node.js v0.8.8 API *
* Node.js v0.10.1 API *
* *

@@ -36,3 +36,3 @@ ************************************************/

(id: string): any;
resolve(): string;
resolve(id:string): string;
cache: any;

@@ -84,7 +84,6 @@ extensions: any;

removeListener(event: string, listener: Function): void;
removeAllListeners(event: string): void;
removeAllListener(event: string): void;
setMaxListeners(n: number): void;
listeners(event: string): { Function; }[];
//emit(event: string, arg1?: any, arg2?: any): void;
emit(event: string, ...args: any[]): void;
emit(event: string, arg1?: any, arg2?: any): void;
}

@@ -125,4 +124,6 @@

setgid(id: number): void;
setgid(id: string): void;
getuid(): number;
setuid(id: number): void;
setuid(id: string): void;
version: string;

@@ -232,13 +233,21 @@ versions: { http_parser: string; node: string; v8: string; ares: string; uv: string; zlib: string; openssl: string; };

export var EventEmitter: NodeEventEmitter;
export class EventEmitter implements NodeEventEmitter {
addListener(event: string, listener: Function);
on(event: string, listener: Function): any;
once(event: string, listener: Function): void;
removeListener(event: string, listener: Function): void;
removeAllListener(event: string): void;
setMaxListeners(n: number): void;
listeners(event: string): { Function; }[];
emit(event: string, arg1?: any, arg2?: any): void;
}
}
declare module "http" {
export import events = module("events");
export import net = module("net");
export import stream = module("stream");
import events = module("events");
import net = module("net");
import stream = module("stream");
export interface Server extends events.NodeEventEmitter {
listen(port: number, hostname?: string, backlog?: number, callback?: Function): void;
listen(port: number, hostname?: number, callback?: Function): void;
listen(path: string, callback?: Function): void;

@@ -309,3 +318,3 @@ listen(handle: any, listeningListener?: Function): void;

declare module "cluster" {
export import child_process = module("child_process");
import child_process = module("child_process");

@@ -347,3 +356,3 @@ export interface ClusterSettings {

declare module "zlib" {
export import stream = module("stream");
import stream = module("stream");
export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; }

@@ -426,5 +435,5 @@

declare module "https" {
export import tls = module("tls");
export import events = module("events");
export import http = module("http");
import tls = module("tls");
import events = module("events");
import http = module("http");

@@ -493,4 +502,4 @@ export interface ServerOptions {

declare module "repl" {
export import stream = module("stream");
export import events = module("events");
import stream = module("stream");
import events = module("events");

@@ -512,4 +521,4 @@ export interface ReplOptions {

declare module "readline" {
export import events = module("events");
export import stream = module("stream");
import events = module("events");
import stream = module("stream");

@@ -548,4 +557,4 @@ export interface ReadLine extends events.NodeEventEmitter {

declare module "child_process" {
export import events = module("events");
export import stream = module("stream");
import events = module("events");
import stream = module("stream");

@@ -599,13 +608,12 @@ export interface ChildProcess extends events.NodeEventEmitter {

export interface Url {
href?: string;
protocol?: string;
auth?: string;
hostname?: string;
port?: string;
host?: string;
pathname?: string;
search?: string;
query?: string;
slashes?: bool;
hash?: string;
href: string;
protocol: string;
auth: string;
hostname: string;
port: string;
host: string;
pathname: string;
search: string;
query: string;
slashes: bool;
}

@@ -634,3 +642,3 @@

declare module "net" {
export import stream = module("stream");
import stream = module("stream");

@@ -651,3 +659,3 @@ export interface NodeSocket extends stream.ReadWriteStream {

resume(): void;
setTimeout(timeout: number, callback?: Function); void;
setTimeout(timeout: number, callback?: Function): void;
setNoDelay(noDelay?: bool): void;

@@ -689,3 +697,3 @@ setKeepAlive(enable?: bool, initialDelay?: number): void;

declare module "dgram" {
export import events = module("events");
import events = module("events");

@@ -708,3 +716,3 @@ export function createSocket(type: string, callback?: Function): Socket;

declare module "fs" {
export import stream = module("stream");
import stream = module("stream");

@@ -743,28 +751,22 @@ interface Stats {

export function renameSync(oldPath: string, newPath: string): void;
export function truncate(fd: number, len: number, callback?: Function): void;
export function truncateSync(fd: number, len: number): void;
export function truncate(fd: string, len: number, callback?: Function): void;
export function truncateSync(fd: string, len: number): void;
export function chown(path: string, uid: number, gid: number, callback?: Function): void;
export function chownSync(path: string, uid: number, gid: number): void;
export function fchown(fd: number, uid: number, gid: number, callback?: Function): void;
export function fchownSync(fd: number, uid: number, gid: number): void;
export function fchown(fd: string, uid: number, gid: number, callback?: Function): void;
export function fchownSync(fd: string, uid: number, gid: number): void;
export function lchown(path: string, uid: number, gid: number, callback?: Function): void;
export function lchownSync(path: string, uid: number, gid: number): void;
export function chmod(path: string, mode: number, callback?: Function): void;
export function chmod(path: string, mode: string, callback?: Function): void;
export function chmodSync(path: string, mode: number): void;
export function chmodSync(path: string, mode: string): void;
export function fchmod(fd: number, mode: number, callback?: Function): void;
export function fchmod(fd: number, mode: string, callback?: Function): void;
export function fchmodSync(fd: number, mode: number): void;
export function fchmodSync(fd: number, mode: string): void;
export function fchmod(fd: string, mode: string, callback?: Function): void;
export function fchmodSync(fd: string, mode: string): void;
export function lchmod(path: string, mode: string, callback?: Function): void;
export function lchmod(path: string, mode: number, callback?: Function): void;
export function lchmodSync(path: string, mode: number): void;
export function lchmodSync(path: string, mode: string): void;
export function stat(path: string, callback?: (err: Error, stats: Stats) =>any): Stats;
export function lstat(path: string, callback?: (err: Error, stats: Stats) =>any): Stats;
export function fstat(fd: number, callback?: (err: Error, stats: Stats) =>any): Stats;
export function fstat(fd: string, callback?: (err: Error, stats: Stats) =>any): Stats;
export function statSync(path: string): Stats;
export function lstatSync(path: string): Stats;
export function fstatSync(fd: number): Stats;
export function fstatSync(fd: string): Stats;
export function link(srcpath: string, dstpath: string, callback?: Function): void;

@@ -777,3 +779,3 @@ export function linkSync(srcpath: string, dstpath: string): void;

export function realpath(path: string, cache: string, callback: (err: Error, resolvedPath: string) =>any): void;
export function realpathSync(path: string, cache?: bool): string;
export function realpathSync(path: string, cache?: string): void;
export function unlink(path: string, callback?: Function): void;

@@ -783,29 +785,30 @@ export function unlinkSync(path: string): void;

export function rmdirSync(path: string): void;
export function mkdir(path: string, mode?: any, callback?: Function): void;
export function mkdirSync(path: string, mode?: number): void;
export function mkdir(path: string, mode?: string, callback?: Function): void;
export function mkdirSync(path: string, mode?: string): void;
export function readdir(path: string, callback?: (err: Error, files: string[]) => void): void;
export function readdirSync(path: string): string[];
export function close(fd: number, callback?: Function): void;
export function closeSync(fd: number): void;
export function open(path: string, flags: string, mode?: string, callback?: (err: Error, fd: number) =>any): void;
export function openSync(path: string, flags: string, mode?: string): number;
export function close(fd: string, callback?: Function): void;
export function closeSync(fd: string): void;
export function open(path: string, flags: string, mode?: string, callback?: (err: Error, fd: string) =>any): void;
export function openSync(path: string, flags: string, mode?: string): void;
export function utimes(path: string, atime: number, mtime: number, callback?: Function): void;
export function utimesSync(path: string, atime: number, mtime: number): void;
export function futimes(fd: number, atime: number, mtime: number, callback?: Function): void;
export function futimesSync(fd: number, atime: number, mtime: number): void;
export function fsync(fd: number, callback?: Function): void;
export function fsyncSync(fd: number): void;
export function write(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, written: number, buffer: NodeBuffer) =>any): void;
export function writeSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number;
export function read(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, bytesRead: number, buffer: NodeBuffer) => void): void;
export function readSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number;
export function readFile(filename: string, encoding: string, callback: (err: Error, data: string) => void ): void;
export function readFile(filename: string, callback: (err: Error, data: NodeBuffer) => void ): void;
export function futimes(fd: string, atime: number, mtime: number, callback?: Function): void;
export function futimesSync(fd: string, atime: number, mtime: number): void;
export function fsync(fd: string, callback?: Function): void;
export function fsyncSync(fd: string): void;
export function write(fd: string, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err, written: number, buffer: NodeBuffer) =>any): void;
export function writeSync(fd: string, buffer: NodeBuffer, offset: number, length: number, position: number): void;
export function read(fd: string, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err, bytesRead: number, buffer: NodeBuffer) => void): void;
export function readSync(fd: string, buffer: NodeBuffer, offset: number, length: number, position: number): any[];
export function readFile(filename: string, options: { encoding?: string; flag?: string; }, callback: (err, data: any) => void ): void;
export function readFile(filename: string, callback: (err, data: NodeBuffer) => void ): void;
export function readFileSync(filename: string): NodeBuffer;
export function readFileSync(filename: string, encoding: string): string;
export function writeFile(filename: string, data: any, encoding?: string, callback?: Function): void;
export function writeFileSync(filename: string, data: any, encoding?: string): void;
export function appendFile(filename: string, data: any, encoding?: string, callback?: Function): void;
export function appendFileSync(filename: string, data: any, encoding?: string): void;
export function readFileSync(filename: string, options: { encoding?: string; flag?: string; }): any;
export function writeFile(filename: string, data: any, callback?: (err) => void): void;
export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err) => void): void;
export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err) => void): void;
export function appendFile(filename: string, data: any, callback?: (err) => void): void;
export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
export function watchFile(filename: string, listener: { curr: Stats; prev: Stats; }): void;

@@ -834,3 +837,2 @@ export function watchFile(filename: string, options: { persistent?: bool; interval?: number; }, listener: { curr: Stats; prev: Stats; }): void;

export function join(...paths: any[]): string;
export function resolve(to: string): string;
export function resolve(from: string, to: string): string;

@@ -859,5 +861,5 @@ export function resolve(from: string, from2: string, to: string): string;

declare module "tls" {
export import crypto = module("crypto");
export import net = module("net");
export import stream = module("stream");
import crypto = module("crypto");
import net = module("net");
import stream = module("stream");

@@ -1007,3 +1009,3 @@ var CLIENT_RENEG_LIMIT: number;

declare module "stream" {
export import events = module("events");
import events = module("events");

@@ -1040,3 +1042,3 @@ export interface WritableStream extends events.NodeEventEmitter {

export function log(string: string): void;
export function inspect(object: any, showHidden?: bool, depth?: number, color?: bool): string;
export function inspect(object: any, showHidden?: bool, depth?: number, color?: bool): void;
export function isArray(object: any): bool;

@@ -1050,2 +1052,3 @@ export function isRegExp(object: any): bool;

declare module "assert" {
export function (booleanValue: bool, message?: string);
export function fail(actual: any, expected: any, message: string, operator: string): void;

@@ -1066,3 +1069,3 @@ export function assert(value: any, message: string): void;

declare module "tty" {
export import net = module("net");
import net = module("net");

@@ -1081,3 +1084,3 @@ export function isatty(fd: string): bool;

declare module "domain" {
export import events = module("events");
import events = module("events");

@@ -1084,0 +1087,0 @@ export interface Domain extends events.NodeEventEmitter { }

@@ -0,1 +1,6 @@

var __extends = this.__extends || function (d, b) {
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
"use strict";

@@ -29,5 +34,5 @@ var http = require('http')

})();
exports.Episode = Episode;
var Movie = (function () {
function Movie(obj) {
this._episodes = [];
for(var attr in obj) {

@@ -39,3 +44,12 @@ if(obj.hasOwnProperty(attr)) {

}
Movie.prototype.episodes = function (cb) {
return Movie;
})();
exports.Movie = Movie;
var TVShow = (function (_super) {
__extends(TVShow, _super);
function TVShow(object) {
_super.call(this, object);
this._episodes = [];
}
TVShow.prototype.episodes = function (cb) {
if(typeof (cb) !== "function") {

@@ -77,4 +91,5 @@ throw new TypeError("cb must be a function");

};
return Movie;
})();
return TVShow;
})(Movie);
exports.TVShow = TVShow;
var ImdbError = (function () {

@@ -91,3 +106,3 @@ function ImdbError(message, movie) {

var poromenos = new ApiHost("imdbapi.poromenos.org", "/js/");
function get(name, cb) {
function getReq(req, cb) {
var responseData = "";

@@ -99,6 +114,12 @@ if(typeof (cb) !== "function") {

myDeanclatworthy = new ApiHost(deanclatworthy);
myDeanclatworthy.path += "?" + querystring.stringify({
q: name,
yg: 0
});
if(req.name !== null) {
myDeanclatworthy.path += "?" + querystring.stringify({
q: req.name,
yg: 0
});
} else if(req.id !== null) {
myDeanclatworthy.path += "?" + querystring.stringify({
id: req.id
});
}
return http.get(myDeanclatworthy, onResponse).on('error', onError);

@@ -119,5 +140,9 @@ function onResponse(res) {

if(responseObject.hasOwnProperty("code") && responseObject.hasOwnProperty("error")) {
return cb(new ImdbError(responseObject.error + ": " + name, name), null);
return cb(new ImdbError(responseObject.error + ": " + (req.name === null ? req.id : req.name), req), null);
}
responseObject = new Movie(responseObject);
if(responseObject.series === 0) {
responseObject = new Movie(responseObject);
} else {
responseObject = new TVShow(responseObject);
}
return cb(null, responseObject);

@@ -129,9 +154,12 @@ }

}
exports.getReq = getReq;
function get(name, cb) {
return getReq({
id: null,
name: name
}, cb);
}
exports.get = get;
; ;
;
function getById(id, cb) {
var responseData = "";
if(typeof (cb) !== "function") {
throw new TypeError("cb must be a function");
}
var intRegex = /^\d+$/;

@@ -145,31 +173,8 @@ if(intRegex.test(id)) {

}
var myDeanclatworthy;
myDeanclatworthy = new ApiHost(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, null);
}
if(responseObject.hasOwnProperty("code") && responseObject.hasOwnProperty("error")) {
return cb(new ImdbError(responseObject.error + ": " + id, id), null);
}
return cb(null, responseObject);
}
function onError(err) {
return cb(err, null);
}
return getReq({
id: id,
name: null
}, cb);
}
exports.getById = getById;
; ;
;

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

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

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

@@ -14,3 +14,3 @@ # node-imdb-api

var movie;
imdb.get('The Toxic Avenger', function(err, things) {
imdb.getReq({ name: 'The Toxic Avenger' }, function(err, things) {
movie = things;

@@ -40,6 +40,6 @@ });

Furthermore if you already know the id you can call getById.
Furthermore if you already know the id you can call getReq with different args:
var movie;
imdb.getById('0090190', function(err, things) {
imdb.getReq({ id: '0090190' }, function(err, things) {
movie = things;

@@ -46,0 +46,0 @@ });

@@ -7,2 +7,7 @@ "use strict";

export interface MovieRequest {
name: string;
id: string;
}
class ApiHost {

@@ -31,8 +36,7 @@ host: string;

class Episode {
export class Episode {
constructor (public season: number, public name: string, public number: number) { }
}
class Movie {
private _episodes: Episode[] = [];
export class Movie {
public imdbid: string;

@@ -58,3 +62,11 @@ public imdburl: string;

}
}
export class TVShow extends Movie {
private _episodes: Episode[] = [];
constructor (object: Object) {
super(object);
}
public episodes(cb: (Error, object) => Array) {

@@ -105,2 +117,3 @@ if (typeof(cb) !== "function")

}
}

@@ -111,3 +124,3 @@

constructor(public message: string, public movie: string) {
constructor(public message: string, public movie: MovieRequest) {
}

@@ -119,3 +132,3 @@ }

export function get(name: string, cb: (Error, any) => any) {
export function getReq(req: MovieRequest, cb: (Error, any) => any) {
var responseData = "";

@@ -129,4 +142,9 @@

myDeanclatworthy = new ApiHost(deanclatworthy);
myDeanclatworthy.path += "?" + querystring.stringify({ q: name, yg: 0 });
if (req.name !== null) {
myDeanclatworthy.path += "?" + querystring.stringify({ q: req.name, yg: 0 });
} else if (req.id !== null) {
myDeanclatworthy.path += "?" + querystring.stringify({ id: req.id });
}
return http.get(myDeanclatworthy, onResponse).on('error', onError);

@@ -152,6 +170,10 @@

if (responseObject.hasOwnProperty("code") && responseObject.hasOwnProperty("error")) {
return cb(new ImdbError(responseObject.error + ": " + name, name), null);
return cb(new ImdbError(responseObject.error + ": " + (req.name === null ? req.id : req.name), req), null);
}
responseObject = new Movie(responseObject);
if (responseObject.series === 0)
responseObject = new Movie(responseObject);
else
responseObject = new TVShow(responseObject);
return cb(null, responseObject);

@@ -163,10 +185,10 @@ }

}
}
export function get(name: string, cb: (Error, any) => any) {
return getReq({id: null, name: name }, cb);
};
export function getById(id: string, cb: (Error, any) => any) {
var responseData = "";
if (typeof(cb) !== "function")
throw new TypeError("cb must be a function");
var intRegex = /^\d+$/;

@@ -183,37 +205,4 @@ if(intRegex.test(id)) {

var myDeanclatworthy;
myDeanclatworthy = new ApiHost(deanclatworthy);
myDeanclatworthy.path += "?" + querystring.stringify({ id: id});
return http.get(myDeanclatworthy, onResponse).on('error', onError);
function onResponse(res: any) {
return res.on('data', onData).on('error', onError).on('end', onEnd);
}
function onData(data: any) {
responseData += data;
}
function onEnd() {
var responseObject;
try {
responseObject = JSON.parse(responseData);
} catch (e) {
return cb(e, null);
}
if (responseObject.hasOwnProperty("code") && responseObject.hasOwnProperty("error")) {
return cb(new ImdbError(responseObject.error + ": " + id, id), null);
}
return cb(null, responseObject);
}
function onError(err: any) {
return cb(err, null);
}
return getReq({ id: id, name: null }, cb);
};

@@ -9,3 +9,3 @@ {

"stv": 1,
"series": 0,
"series": 1,
"rating": "8.6",

@@ -12,0 +12,0 @@ "runtime": "25min(22episodes)",

@@ -1,3 +0,1 @@

"use strict";
var http = require('http');

@@ -19,3 +17,4 @@ var nock = require('nock');

test.equal(data.imdbid, 'tt0090191', "testing returned data");
test.equal(typeof(data.episodes), "function", "testing for null episodes");
test.equal(data.series, false, "testing series bool");
test.equal(data.hasOwnProperty("episodes"), false, "should not have episodes");

@@ -34,3 +33,3 @@ test.done();

test.deepEqual(err, new imdb.ImdbError('rate limited: The Green Mile', 'The Green Mile'), "testing error code");
test.deepEqual(err, new imdb.ImdbError('rate limited: The Green Mile', { name:'The Green Mile', id: null }), "testing error code");

@@ -61,3 +60,3 @@ test.done();

test.deepEqual(err, new imdb.ImdbError('Film not found: asdfasdfasdf', 'asdfasdfasdf'), "testing film not found error");
test.deepEqual(err, new imdb.ImdbError('Film not found: asdfasdfasdf', { name:'asdfasdfasdf', id: null }), "testing film not found error");

@@ -79,2 +78,3 @@ test.done();

test.equal(typeof(data.episodes), "function", "testing for episodes function");
test.equal(data.series, true, "testing series bool");

@@ -81,0 +81,0 @@ return data.episodes(testEpisodes);

@@ -19,3 +19,4 @@ "use strict";

test.equal(data.title, 'The Toxic Avenger', "testing returned data");
test.equal(typeof(data.episodes), "undefined", "testing for null episodes");
test.equal(data.series, false, "testing series bool");
test.equal(data.hasOwnProperty("episodes"), false, "should not have episodes");

@@ -34,3 +35,3 @@ test.done();

test.deepEqual(err, new imdb.ImdbError('rate limited: tt0090190', 'tt0090190'), "testing error code");
test.deepEqual(err, new imdb.ImdbError('rate limited: tt0090190', { id: 'tt0090190', name: null }), "testing error code");

@@ -61,3 +62,3 @@ test.done();

test.deepEqual(err, new imdb.ImdbError('Film not found: tt0090190', 'tt0090190'), "testing film not found error");
test.deepEqual(err, new imdb.ImdbError('Film not found: tt0090190', { id: 'tt0090190', name: null }), "testing film not found error");

@@ -64,0 +65,0 @@ test.done();

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