name-to-imdb
Advanced tools
Comparing version 2.0.1 to 2.1.0
@@ -17,2 +17,3 @@ var namedQueue = require('named-queue'); | ||
var cache = { }; | ||
var cacheLastSet = { }; | ||
@@ -44,4 +45,5 @@ // Named queue, means that we're not working on one name more than once at a tim | ||
if (cache.hasOwnProperty(key)) | ||
if (cache.hasOwnProperty(key) && Date.now()-cacheLastSet[key] < CACHE_TTL) { | ||
return cb(null, cache[key][0], { match: cache[key][1].match, isCached: true }) | ||
} | ||
@@ -58,3 +60,3 @@ queue.push({ | ||
cache[key] = [imdb_id, match] | ||
setTimeout(function() { delete cache[key] }, CACHE_TTL) | ||
cacheLastSet[key] = Date.now() | ||
} | ||
@@ -61,0 +63,0 @@ |
{ | ||
"name": "name-to-imdb", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "Finds IMDB ID by movie/series name (fuzzily) and optionally year and type", | ||
@@ -29,3 +29,3 @@ "main": "index.js", | ||
"needle": "^1.1.2", | ||
"stremio-addons": "^2.0.2" | ||
"node-fetch": "^2.2.0" | ||
}, | ||
@@ -32,0 +32,0 @@ "devDependencies": { |
@@ -1,9 +0,9 @@ | ||
var Stremio = require("stremio-addons"); | ||
var fetch = require("node-fetch") | ||
var helpers = require("../helpers") | ||
// Use cinemeta to pull names of movies and series against IMDB IDs | ||
var stremio = new Stremio.Client(); | ||
stremio.add("http://cinemeta.strem.io/stremioget/stremio/v1"); | ||
//stremio.add("http://localhost:3005/stremioget/stremio/v1"); | ||
var cinemetaUrls = { | ||
'movie': 'https://cinemeta.strem.io/stremioget/stremio/v1/q.json?b=eyJwYXJhbXMiOltudWxsLHt9XSwibWV0aG9kIjoibmFtZXMubW92aWUiLCJpZCI6MSwianNvbnJwYyI6IjIuMCJ9', | ||
'series': 'https://cinemeta.strem.io/stremioget/stremio/v1/q.json?b=eyJwYXJhbXMiOltudWxsLHt9XSwibWV0aG9kIjoibmFtZXMuc2VyaWVzIiwiaWQiOjEsImpzb25ycGMiOiIyLjAifQ==', | ||
} | ||
@@ -25,11 +25,17 @@ // Index entry in our in-mem index | ||
// It's OK if we don't pass type and we don't fetch names, because we will go to google fallback | ||
if (query.type && !pulled[query.type]) stremio.call("names."+query.type, { }, function(err, res) { | ||
if (err) console.error(err); | ||
if (res) { | ||
if (query.type && !pulled[query.type] && cinemetaUrls[query.type]) { | ||
fetch(cinemetaUrls[query.type]) | ||
.then(function(resp) { return resp.json() }) | ||
.then(function(resp) { return resp.result }) | ||
.then(function(res) { | ||
res.forEach(indexEntry); | ||
pulled[query.type] = 1; | ||
} | ||
match(); | ||
}); | ||
else process.nextTick(match); | ||
}) | ||
.catch(function(e) { | ||
console.error(e) | ||
}) | ||
.then(function() { | ||
match() | ||
}) | ||
} else process.nextTick(match); | ||
@@ -51,2 +57,2 @@ function match() { | ||
module.exports = metadataFind | ||
module.exports = metadataFind |
var nameToImdb = require("../index"); | ||
var tape = require("tape") | ||
tape("basic test - match from google (type not provided)", function(t) { | ||
tape("basic test - match from imdb (type not provided)", function(t) { | ||
nameToImdb({ name: "south park" }, function(err, res, inf) { | ||
t.error(err); | ||
t.equals(res, "tt0121955") | ||
t.ok(inf) | ||
t.ok(inf.match && inf.match.match("google"), "is matched on google"); | ||
t.ok(inf, 'has inf') | ||
t.ok(inf.match && inf.match.match("imdbFind"), "is matched on imdb"); | ||
t.end() | ||
@@ -11,0 +11,0 @@ //console.log(inf); // inf contains info on where we matched that name - e.g. locally, or on google |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22409
9
305
1
+ Addednode-fetch@^2.2.0
+ Addednode-fetch@2.7.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
- Removedstremio-addons@^2.0.2
- Removedasync@1.5.2(transitive)
- Removedejs@2.7.4(transitive)
- Removedevents@1.1.1(transitive)
- Removedextend@3.0.2(transitive)
- Removedonce@1.4.0(transitive)
- Removedstremio-addons@2.8.14(transitive)
- Removedwrappy@1.0.2(transitive)