stremio-local-addon
Advanced tools
Comparing version 1.4.1 to 1.4.2
@@ -13,3 +13,3 @@ const consts = require('./consts') | ||
// Properties that determine when Stremio picks this add-on | ||
resources: ['catalog', 'meta'], | ||
resources: ['catalog', 'meta', 'stream'], | ||
types: ['movie', 'series', 'other'], | ||
@@ -16,0 +16,0 @@ |
@@ -5,18 +5,20 @@ const fetch = require('node-fetch') | ||
const mapEntryToMeta = require('./mapEntryToMeta') | ||
const consts = require('./consts') | ||
const PREFIX_BT = require('./consts').PREFIX_BT | ||
function metaHandler(storage, engineUrl, args, cb) { | ||
const entry = storage.getAggrEntry(args.id) | ||
if (entry) { | ||
// Saved entry is found | ||
mapEntryToMeta(engineUrl, entry, function(err, meta) { | ||
cb(err, meta ? { meta: meta } : null) | ||
}) | ||
} else if (args.id.indexOf(PREFIX_BT) === 0) { | ||
if (args.id.startsWith(consts.PREFIX_LOCAL)) { | ||
const entry = storage.getAggrEntry(args.id) | ||
if (!entry) { | ||
cb(new Error('entry not found')) | ||
} else { | ||
// Saved entry is found | ||
mapEntryToMeta(engineUrl, entry, function(err, meta) { | ||
cb(err, meta ? { meta: meta } : null) | ||
}) | ||
} | ||
} else if (args.id.startsWith(consts.PREFIX_BT)) { | ||
// Saved entr is not found, but we can make an entry from a torrent | ||
getNonIndexedTorrent(engineUrl, args.id.slice(PREFIX_BT.length), cb) | ||
getNonIndexedTorrent(engineUrl, args.id.slice(consts.PREFIX_BT.length), cb) | ||
} else { | ||
cb(new Error('entry not found')) | ||
cb(new Error('invalid request prefix for meta resource')) | ||
} | ||
@@ -23,0 +25,0 @@ } |
@@ -33,2 +33,21 @@ const path = require('path') | ||
// WARNING: this here is expensive iteration; if the user has thousands of torrents, it may become a problem | ||
// and we might have to switch to using an index | ||
for (let k of storage.byItemId.keys()) { | ||
if (k.startsWith(consts.PREFIX_BT)) { | ||
// for PREFIX_BT, we only care for the first, since they're all equivalent | ||
const entry = storage.byItemId.get(k).values().next().value | ||
entry.files.forEach(function(f, i) { | ||
if (args.type === f.type && args.id === getFileVideoId(f)) streams.push({ | ||
title: path.basename(f.path), | ||
infoHash: entry.ih, | ||
fileIdx: i, | ||
id: entry.ih+'/'+i, | ||
sources: entry.sources | ||
}) | ||
}) | ||
} | ||
} | ||
cb(null, { streams: streams }) | ||
@@ -35,0 +54,0 @@ } |
{ | ||
"name": "stremio-local-addon", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "Local add-on to find playable files: .torrent, .mp4, .mkv and .avi", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -35,3 +35,2 @@ const tape = require('tape') | ||
t.ok(Array.isArray(resp.metas), 'resp has metas') | ||
console.log(resp.metas) | ||
t.end() | ||
@@ -38,0 +37,0 @@ }) |
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
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
651
24957
21