stremiok 2.3.4 → 2.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +14 -13
- package/config.xml +1 -1
- package/css/style.css +5 -0
- package/index.html +43 -40
- package/js/app.js +3 -3
- package/js/downloads.js +16 -16
- package/js/epg.js +2 -3
- package/js/hubpreview.js +1 -1
- package/js/i18n.js +108 -0
- package/js/iptv.js +13 -13
- package/js/jellyfin.js +19 -19
- package/js/lang/ar.js +1972 -0
- package/js/lang/de.js +1972 -0
- package/js/lang/es.js +1972 -0
- package/js/lang/fi.js +1972 -0
- package/js/lang/fr.js +1972 -0
- package/js/lang/he.js +1972 -0
- package/js/lang/hi.js +1972 -0
- package/js/lang/it.js +1972 -0
- package/js/lang/ja.js +1972 -0
- package/js/lang/ko.js +1972 -0
- package/js/lang/languages.js +21 -0
- package/js/lang/pl.js +1972 -0
- package/js/lang/pt-BR.js +1972 -0
- package/js/lang/ru.js +1972 -0
- package/js/lang/tr.js +1972 -0
- package/js/lang/zh-CN.js +1972 -0
- package/js/local.js +9 -9
- package/js/netfolders.js +13 -13
- package/js/player-audio.js +17 -17
- package/js/player-controls.js +100 -100
- package/js/player-core.js +90 -58
- package/js/player-lang.js +22 -22
- package/js/player-quality.js +15 -15
- package/js/player-store.js +13 -13
- package/js/player-subs.js +69 -69
- package/js/plex.js +11 -11
- package/js/plugins.js +270 -0
- package/js/stremio-account.js +8 -8
- package/js/stremio-sync.js +5 -5
- package/js/stremio.js +81 -78
- package/js/stvod.js +4 -4
- package/js/trakt.js +23 -23
- package/js/tvapps.js +4 -4
- package/js/util.js +48 -27
- package/js/vendor/quickjs/LICENSES.md +412 -0
- package/js/vendor/quickjs/crypto-js.js +6659 -0
- package/js/vendor/quickjs/plugin-worker-legacy.js +1364 -0
- package/js/vendor/quickjs/plugin-worker.js +8774 -0
- package/js/vendor/quickjs/quickjs.wasm +0 -0
- package/js/view-core.js +93 -93
- package/js/view-detail.js +132 -130
- package/js/view-discover.js +27 -27
- package/js/view-guide.js +13 -13
- package/js/view-home.js +124 -118
- package/js/view-search.js +25 -25
- package/js/view-settings.js +743 -643
- package/js/xtvod.js +2 -2
- package/js/youtube.js +17 -17
- package/js/ytplay.js +39 -9
- package/package.json +1 -1
- package/service/index.js +227 -13
- package/tizenbrew.html +1 -1
package/js/plugins.js
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/* Nuvio plugins (Settings › Content › Nuvio plugins; docs/PLUGINS.md): programs written for the
|
|
2
|
+
Nuvio apps that look for a title's sources. A repository is a manifest.json the user adds by its
|
|
3
|
+
address; it lists plugins, each one JavaScript file (CommonJS) exporting
|
|
4
|
+
getStreams(tmdbId, mediaType, season, episode) -> a promise of sources.
|
|
5
|
+
|
|
6
|
+
Each plugin runs in a fresh QuickJS context inside a Web Worker (js/vendor/quickjs/
|
|
7
|
+
plugin-worker.js, built by plugin-runtime/): nothing of StremioK's inside, its requests through
|
|
8
|
+
the service (/plug/fetch: the home network as Local-network links from internet addons says),
|
|
9
|
+
64 MB, RUN_MS. Only where that can run: see supported() (2017 and newer TVs)
|
|
10
|
+
and StremioK's own service (the sideloaded app); elsewhere the option isn't shown.
|
|
11
|
+
|
|
12
|
+
The code is downloaded on Add and Refresh only, kept in the TV's database (U.bigStore). New
|
|
13
|
+
plugins start off. Plugins are handed the user's TMDB key (they look titles up by TMDB number),
|
|
14
|
+
which Settings says before they're turned on. Their sources come in as a synthetic addon's,
|
|
15
|
+
"Nuvio plugins", placed and ranked like any addon's.
|
|
16
|
+
Global namespace: Plugins */
|
|
17
|
+
var Plugins = (function () {
|
|
18
|
+
'use strict';
|
|
19
|
+
var KEY = 'stremiok.plugins'; // { on, repos: [{ id, url, name, at, plugins: [{ id, name, version, file, types, on, size, hash }] }] }
|
|
20
|
+
var CODE = 'stremiok.plugins.code.'; // + repo id + '.' + plugin id (U.bigStore)
|
|
21
|
+
var MAX_REPOS = 10, MAX_PLUGINS = 50, CODE_MAX = 1048576, MANIFEST_MAX = 262144, RUN_MS = 20000, RUN_MS_LEGACY = 30000, MAX_RESULTS = 100, AT_ONCE = 2, IDLE_MS = 120000;
|
|
22
|
+
var WORKER = 'js/vendor/quickjs/plugin-worker.js', WORKER_LEGACY = 'js/vendor/quickjs/plugin-worker-legacy.js';
|
|
23
|
+
|
|
24
|
+
// Can this TV run them? Two runtimes (js/vendor/quickjs/): WebAssembly for Chromium 76 and later
|
|
25
|
+
// (Tizen 6 on: built for and tried there), and QuickJS as plain JavaScript (-legacy) for older
|
|
26
|
+
// engines, down to Chromium 47 (Tizen 3: tried on a 2017 TV), one plugin at a time with more time.
|
|
27
|
+
// Offered on both; experimental where not tried (Tizen 4, 5.0, 5.5: Chromium 56 to 69). Both
|
|
28
|
+
// need Workers and the sideloaded app's own service (TizenBrew's is shared with other modules:
|
|
29
|
+
// not there yet; a browser has none).
|
|
30
|
+
var MIN_CHROMIUM = 76, MIN_LEGACY = 47, TRIED_LEGACY = 47;
|
|
31
|
+
var TIZEN_CHROMIUM = { '3.0': 47, '4.0': 56, '5.0': 63, '5.5': 69, '6.0': 76, '6.5': 85 };
|
|
32
|
+
function chromium() { // (a Tizen TV says it without "Chrome/": "(KHTML, like Gecko) 76.0.3809.146/6.0 TV"; Tizen 3 not at all)
|
|
33
|
+
var ua = '' + ((typeof navigator !== 'undefined' && navigator.userAgent) || '');
|
|
34
|
+
var m = /Chrome\/(\d+)\./.exec(ua) || /\(KHTML, like Gecko\) (\d+)\.\d+\.\d+/.exec(ua), t = /Tizen (\d+\.\d+)/.exec(ua);
|
|
35
|
+
return m ? +m[1] : t && TIZEN_CHROMIUM[t[1]] ? TIZEN_CHROMIUM[t[1]] : 0;
|
|
36
|
+
}
|
|
37
|
+
function legacy() { return !(chromium() >= MIN_CHROMIUM && typeof WebAssembly === 'object'); }
|
|
38
|
+
function workerFile() { return legacy() ? WORKER_LEGACY : WORKER; }
|
|
39
|
+
function supported() {
|
|
40
|
+
return chromium() >= MIN_LEGACY && typeof Worker === 'function' && typeof YTPlay !== 'undefined' && !!YTPlay.pluginNet && YTPlay.installMode() === 'wgt';
|
|
41
|
+
}
|
|
42
|
+
function experimental() { var c = chromium(); return c > TRIED_LEGACY && c < MIN_CHROMIUM; }
|
|
43
|
+
function runMs() { return legacy() ? RUN_MS_LEGACY : RUN_MS; }
|
|
44
|
+
function state() {
|
|
45
|
+
var s = U.store.get(KEY, null);
|
|
46
|
+
if (!s || typeof s !== 'object') { s = {}; }
|
|
47
|
+
return { on: s.on === true, repos: (Array.isArray(s.repos) ? s.repos : []).filter(function (r) { return r && typeof r.url === 'string' && Array.isArray(r.plugins); }) };
|
|
48
|
+
}
|
|
49
|
+
function save(s) { U.store.set(KEY, { on: !!s.on, repos: s.repos }); }
|
|
50
|
+
function isEnabled() { return supported() && state().on; }
|
|
51
|
+
function setEnabled(on) { var s = state(); s.on = !!on; save(s); reloadAddons(); }
|
|
52
|
+
function repos() { return state().repos; }
|
|
53
|
+
function enabledPlugins() {
|
|
54
|
+
var out = [];
|
|
55
|
+
repos().forEach(function (r) { r.plugins.forEach(function (p) { if (p.on) { out.push({ repo: r, p: p }); } }); });
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
// (the addon list rebuilt with, or without, the plugins' source addon; titles' sources asked again)
|
|
59
|
+
function reloadAddons() {
|
|
60
|
+
if (typeof Stremio === 'undefined') { return; }
|
|
61
|
+
try { if (Stremio.addonsChanged) { Stremio.addonsChanged(); } if (Stremio.sourcesChanged) { Stremio.sourcesChanged(); } } catch (e) {}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// A repository's manifest address from what was typed: its manifest.json, or the folder it's in.
|
|
65
|
+
function manifestUrl(input) {
|
|
66
|
+
var u = ('' + (input || '')).trim();
|
|
67
|
+
if (!/^https?:\/\/[^\s]+$/i.test(u)) { return ''; }
|
|
68
|
+
if (!/\/manifest\.json(?:[?#]|$)/i.test(u)) { u = u.replace(/[?#].*$/, '').replace(/\/+$/, '') + '/manifest.json'; }
|
|
69
|
+
return u;
|
|
70
|
+
}
|
|
71
|
+
function addressProblem(input) { return manifestUrl(input) ? null : U.t('A web address, like https://example.com/plugins/manifest.json'); }
|
|
72
|
+
function resolve(base, rel) {
|
|
73
|
+
rel = '' + rel;
|
|
74
|
+
if (/^https?:\/\//i.test(rel)) { return rel; }
|
|
75
|
+
var origin = /^(https?:\/\/[^\/]+)/i.exec(base)[1];
|
|
76
|
+
if (rel.charAt(0) === '/') { return origin + rel; }
|
|
77
|
+
return base.replace(/[?#].*$/, '').replace(/[^\/]*$/, '') + rel.replace(/^\.\//, '');
|
|
78
|
+
}
|
|
79
|
+
function hashOf(text) { // (FNV-1a: to tell when a plugin's code changed)
|
|
80
|
+
var h = 0x811c9dc5;
|
|
81
|
+
for (var i = 0; i < text.length; i++) { h ^= text.charCodeAt(i); h = (h + ((h << 1) + (h << 4) + (h << 7) + (h << 8) + (h << 24))) >>> 0; }
|
|
82
|
+
return ('0000000' + h.toString(16)).slice(-8);
|
|
83
|
+
}
|
|
84
|
+
function str(v, max) { return typeof v === 'string' ? v.replace(/[\u0000-\u001f]/g, ' ').trim().slice(0, max) : ''; }
|
|
85
|
+
function idOf(v) { return ('' + v).replace(/[^\w.\-]/g, '_').slice(0, 64); }
|
|
86
|
+
|
|
87
|
+
// A repository read (its manifest, then each plugin's code): { name, plugins: [{…, code}] }.
|
|
88
|
+
function readRepo(url) {
|
|
89
|
+
return U.getJSON(url, 20000, MANIFEST_MAX).then(function (m) {
|
|
90
|
+
var list = m && (Array.isArray(m.scrapers) ? m.scrapers : Array.isArray(m.plugins) ? m.plugins : null);
|
|
91
|
+
if (!list) { throw new Error(U.t('not a plugin repository (no list of plugins)')); }
|
|
92
|
+
list = list.filter(function (x) { return x && x.id && typeof x.filename === 'string'; }).slice(0, MAX_PLUGINS);
|
|
93
|
+
var seen = {};
|
|
94
|
+
list = list.filter(function (x) { var k = idOf(x.id); if (seen[k]) { return false; } seen[k] = true; return true; });
|
|
95
|
+
return Promise.all(list.map(function (x) {
|
|
96
|
+
var types = (Array.isArray(x.supportedTypes) ? x.supportedTypes : ['movie', 'tv']).filter(function (t) { return t === 'movie' || t === 'tv'; });
|
|
97
|
+
var p = { id: idOf(x.id), name: str(x.name, 80) || idOf(x.id), version: str(x.version, 20), file: resolve(url, x.filename), types: types, on: false };
|
|
98
|
+
return U.getText(p.file, 20000, CODE_MAX).then(function (code) { p.code = '' + code; p.size = p.code.length; p.hash = hashOf(p.code); return p; },
|
|
99
|
+
function (e) { p.error = U.problem(e); return p; });
|
|
100
|
+
})).then(function (plugins) { return { name: str(m.name, 80) || url.replace(/^https?:\/\//, '').replace(/\/manifest\.json.*$/i, ''), plugins: plugins }; });
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
// Add a repository (or read it again: refresh), keeping each plugin's on / off. Resolves to
|
|
104
|
+
// { repo, added, changed, failed } (failed: plugins whose code didn't come; kept as they were).
|
|
105
|
+
function saveRepo(url, id) {
|
|
106
|
+
var s = state(), old = null;
|
|
107
|
+
s.repos.forEach(function (r) { if (r.id === id || (!id && r.url === url)) { old = r; } });
|
|
108
|
+
if (!old && s.repos.length >= MAX_REPOS) { return Promise.reject(new Error(U.t('up to {n} repositories', { n: MAX_REPOS }))); }
|
|
109
|
+
return readRepo(url).then(function (got) {
|
|
110
|
+
var rid = old ? old.id : 'r' + Date.now().toString(36);
|
|
111
|
+
var before = {};
|
|
112
|
+
if (old) { old.plugins.forEach(function (p) { before[p.id] = p; }); }
|
|
113
|
+
var added = 0, changed = 0, failed = 0, writes = [];
|
|
114
|
+
var plugins = got.plugins.map(function (p) {
|
|
115
|
+
var was = before[p.id];
|
|
116
|
+
if (p.error) { failed++; return was || null; }
|
|
117
|
+
if (!was) { added++; } else if (was.hash !== p.hash) { changed++; }
|
|
118
|
+
writes.push(U.bigStore.set(CODE + rid + '.' + p.id, p.code));
|
|
119
|
+
return { id: p.id, name: p.name, version: p.version, file: p.file, types: p.types, on: !!(was && was.on), size: p.size, hash: p.hash };
|
|
120
|
+
}).filter(Boolean);
|
|
121
|
+
return Promise.all(writes).then(function () {
|
|
122
|
+
if (old) { old.plugins.forEach(function (p) { if (!plugins.some(function (q) { return q.id === p.id; })) { U.bigStore.remove(CODE + rid + '.' + p.id); } }); }
|
|
123
|
+
var repo = { id: rid, url: url, name: got.name, at: Date.now(), plugins: plugins };
|
|
124
|
+
var s2 = state();
|
|
125
|
+
s2.repos = s2.repos.filter(function (r) { return r.id !== rid; });
|
|
126
|
+
s2.repos.push(repo);
|
|
127
|
+
save(s2);
|
|
128
|
+
reloadAddons();
|
|
129
|
+
return { repo: repo, added: added, changed: changed, failed: failed };
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function addRepo(input) {
|
|
134
|
+
var url = manifestUrl(input);
|
|
135
|
+
if (!url) { return Promise.reject(new Error(addressProblem(input))); }
|
|
136
|
+
return saveRepo(url, null);
|
|
137
|
+
}
|
|
138
|
+
function refreshRepo(id) {
|
|
139
|
+
var r = repos().filter(function (x) { return x.id === id; })[0];
|
|
140
|
+
return r ? saveRepo(r.url, r.id) : Promise.reject(new Error('gone'));
|
|
141
|
+
}
|
|
142
|
+
function removeRepo(id) {
|
|
143
|
+
var s = state();
|
|
144
|
+
s.repos.forEach(function (r) { if (r.id === id) { r.plugins.forEach(function (p) { U.bigStore.remove(CODE + r.id + '.' + p.id); }); } });
|
|
145
|
+
s.repos = s.repos.filter(function (r) { return r.id !== id; });
|
|
146
|
+
save(s);
|
|
147
|
+
reloadAddons();
|
|
148
|
+
}
|
|
149
|
+
function setPlugin(repoId, pluginId, on) {
|
|
150
|
+
var s = state();
|
|
151
|
+
s.repos.forEach(function (r) { if (r.id === repoId) { r.plugins.forEach(function (p) { if (p.id === pluginId) { p.on = !!on; } }); } });
|
|
152
|
+
save(s);
|
|
153
|
+
reloadAddons();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// ---- The Worker (one, kept while in use; gone after IDLE_MS, or when it asks to start over)
|
|
157
|
+
var _worker = null, _waiting = {}, _next = 1, _idle = null;
|
|
158
|
+
function worker() {
|
|
159
|
+
if (_idle) { clearTimeout(_idle); _idle = null; }
|
|
160
|
+
if (_worker) { return _worker; }
|
|
161
|
+
_worker = new Worker(workerFile());
|
|
162
|
+
_worker.onmessage = function (ev) {
|
|
163
|
+
var m = ev.data || {};
|
|
164
|
+
if (m.type === 'restart') { drop(); return; }
|
|
165
|
+
var w = _waiting[m.id];
|
|
166
|
+
if (!w) { return; }
|
|
167
|
+
delete _waiting[m.id];
|
|
168
|
+
clearTimeout(w.timer);
|
|
169
|
+
w.done(m);
|
|
170
|
+
idleLater();
|
|
171
|
+
};
|
|
172
|
+
_worker.onerror = function (e) { U.log('plugins', 'Plugin runtime error: ' + ((e && e.message) || 'unknown')); fail('the plugin runtime stopped'); };
|
|
173
|
+
return _worker;
|
|
174
|
+
}
|
|
175
|
+
function idleLater() { if (!Object.keys(_waiting).length) { _idle = setTimeout(drop, IDLE_MS); } }
|
|
176
|
+
function drop() { if (_worker) { try { _worker.terminate(); } catch (e) {} _worker = null; } }
|
|
177
|
+
function fail(why) { var w = _waiting; _waiting = {}; drop(); Object.keys(w).forEach(function (k) { clearTimeout(w[k].timer); w[k].done({ type: 'failed', why: why, logs: [] }); }); }
|
|
178
|
+
function runOne(code, plugin, args, net) {
|
|
179
|
+
return new Promise(function (resolve) {
|
|
180
|
+
var id = _next++;
|
|
181
|
+
var timer = setTimeout(function () { if (_waiting[id]) { fail('took too long'); } }, runMs() + 5000); // (a runtime that stopped answering: started over)
|
|
182
|
+
_waiting[id] = { done: resolve, timer: timer };
|
|
183
|
+
var tmdbKey = typeof Stremio !== 'undefined' && Stremio.getIntegrations ? (Stremio.getIntegrations().tmdb || '') : '';
|
|
184
|
+
try { worker().postMessage({ type: 'run', id: id, code: code, scraperId: plugin.id, args: args, tmdbKey: tmdbKey, net: net, timeoutMs: runMs(), maxResults: MAX_RESULTS }); }
|
|
185
|
+
catch (e) { delete _waiting[id]; clearTimeout(timer); resolve({ type: 'failed', why: (e && e.message) || 'couldn’t start', logs: [] }); }
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// ---- A title's sources
|
|
190
|
+
function lanAllowed() { return typeof Stremio !== 'undefined' && Stremio.getPrefs ? !!Stremio.getPrefs().allowLocal : false; }
|
|
191
|
+
// A plugin's source as an addon's: plain data, its headers as proxyHeaders (played as an addon's).
|
|
192
|
+
function toSource(x, plugin, n) {
|
|
193
|
+
if (!x || typeof x !== 'object') { return null; }
|
|
194
|
+
var url = typeof x.url === 'string' ? x.url.trim() : '', hash = typeof x.infoHash === 'string' && /^[0-9a-f]{40}$/i.test(x.infoHash) ? x.infoHash.toLowerCase() : '';
|
|
195
|
+
if (!hash && (!/^https?:\/\/[^\s]+$/i.test(url) || url.length > 4096)) { return null; }
|
|
196
|
+
if (url && !lanAllowed() && U.urlIsPrivate && U.urlIsPrivate(url)) { return null; }
|
|
197
|
+
var bits = [str(x.title, 300) || str(x.name, 120)];
|
|
198
|
+
if (str(x.quality, 20)) { bits.push(str(x.quality, 20)); }
|
|
199
|
+
if (str(x.size, 30)) { bits.push(str(x.size, 30)); }
|
|
200
|
+
var s = { name: plugin.name + (str(x.name, 60) && str(x.name, 60) !== plugin.name ? '\n' + str(x.name, 60) : ''), title: bits.filter(Boolean).join('\n'), _plugin: plugin.id, _pluginPos: n };
|
|
201
|
+
if (hash) { s.infoHash = hash; if (typeof x.fileIdx === 'number') { s.fileIdx = x.fileIdx; } } else { s.url = url; }
|
|
202
|
+
var h = x.headers && typeof x.headers === 'object' ? x.headers : (x.behaviorHints && x.behaviorHints.proxyHeaders && x.behaviorHints.proxyHeaders.request);
|
|
203
|
+
var clean = h ? U.sanitizeHeaders(h) : null;
|
|
204
|
+
s.behaviorHints = { notWebReady: true };
|
|
205
|
+
if (clean) {
|
|
206
|
+
s.behaviorHints.proxyHeaders = { request: {} };
|
|
207
|
+
if (clean.ua) { s.behaviorHints.proxyHeaders.request['User-Agent'] = clean.ua; }
|
|
208
|
+
if (clean.ref) { s.behaviorHints.proxyHeaders.request.Referer = clean.ref; }
|
|
209
|
+
if (clean.cookie) { s.behaviorHints.proxyHeaders.request.Cookie = clean.cookie; }
|
|
210
|
+
if (clean.origin) { s.behaviorHints.proxyHeaders.request.Origin = clean.origin; }
|
|
211
|
+
if (clean.accept) { s.behaviorHints.proxyHeaders.request.Accept = clean.accept; }
|
|
212
|
+
if (clean.lang) { s.behaviorHints.proxyHeaders.request['Accept-Language'] = clean.lang; }
|
|
213
|
+
s._headers = clean;
|
|
214
|
+
}
|
|
215
|
+
return s;
|
|
216
|
+
}
|
|
217
|
+
// The TMDB number plugins ask by: in the id (tmdb:…), the title's details, or looked up.
|
|
218
|
+
function tmdbOf(type, id, meta) {
|
|
219
|
+
var m = /^tmdb:(\d+)/.exec(id);
|
|
220
|
+
if (m) { return Promise.resolve(m[1]); }
|
|
221
|
+
var known = meta && (meta.moviedb_id || meta.tmdb_id || (meta.behaviorHints && meta.behaviorHints.tmdbId));
|
|
222
|
+
if (known && /^\d+$/.test('' + known)) { return Promise.resolve('' + known); }
|
|
223
|
+
var imdb = /^(tt\d+)/.exec(id);
|
|
224
|
+
if (!imdb || typeof Stremio === 'undefined' || !Stremio.tmdbFind) { return Promise.resolve(null); }
|
|
225
|
+
return Stremio.tmdbFind(imdb[1], type === 'series' ? 'tv' : 'movie').then(function (n) { return n ? '' + n : null; });
|
|
226
|
+
}
|
|
227
|
+
function streams(type, id, meta) {
|
|
228
|
+
if (!isEnabled()) { return Promise.resolve([]); }
|
|
229
|
+
var kind = type === 'series' ? 'tv' : type === 'movie' ? 'movie' : '';
|
|
230
|
+
var todo = enabledPlugins().filter(function (x) { return kind && x.p.types.indexOf(kind) !== -1; });
|
|
231
|
+
if (!todo.length) { return Promise.resolve([]); }
|
|
232
|
+
var ep = /:(\d+):(\d+)$/.exec(id || '');
|
|
233
|
+
return tmdbOf(type, id || '', meta).then(function (tmdb) {
|
|
234
|
+
if (!tmdb) { U.log('plugins', 'No TMDB number for ' + id + ' (a TMDB key is needed: Settings › Content › Integrations)'); return []; }
|
|
235
|
+
var args = [tmdb, kind, ep ? +ep[1] : null, ep ? +ep[2] : null];
|
|
236
|
+
return YTPlay.pluginNet(lanAllowed()).then(function (net) {
|
|
237
|
+
var out = [];
|
|
238
|
+
return U.settleAll(todo.map(function (x) {
|
|
239
|
+
return function () {
|
|
240
|
+
return U.bigStore.get(CODE + x.repo.id + '.' + x.p.id).then(function (code) {
|
|
241
|
+
if (typeof code !== 'string' || !code) { throw new Error('its code isn’t on the TV: refresh its repository'); }
|
|
242
|
+
return runOne(code, x.p, args, net);
|
|
243
|
+
}).then(function (r) {
|
|
244
|
+
(r.logs || []).slice(0, 20).forEach(function (l) { U.log('plugins', x.p.name + ': ' + l); });
|
|
245
|
+
if (r.type !== 'done') { throw new Error(r.why || 'failed'); }
|
|
246
|
+
var list = (Array.isArray(r.streams) ? r.streams : []).slice(0, MAX_RESULTS).map(function (s, n) { return toSource(s, x.p, n); }).filter(Boolean);
|
|
247
|
+
out = out.concat(list);
|
|
248
|
+
}).then(null, function (e) { U.log('plugins', x.p.name + ' (' + args.slice(0, 2).join(' ') + '): ' + ((e && e.message) || e)); });
|
|
249
|
+
};
|
|
250
|
+
}), legacy() ? 1 : AT_ONCE).then(function () { return out; });
|
|
251
|
+
}, function () { return []; });
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// The synthetic addon its sources come in as ("Nuvio plugins": a source addon, no catalogs)
|
|
256
|
+
var _addon = null;
|
|
257
|
+
function synthAddon() {
|
|
258
|
+
if (!_addon) {
|
|
259
|
+
_addon = { __local: true, __sources: true, __impl: { streams: streams }, url: 'local:plugins', base: 'local:plugins',
|
|
260
|
+
manifest: { id: 'org.stremiok.plugins', name: 'Nuvio plugins', version: '1.0.0', types: ['movie', 'series'], catalogs: [],
|
|
261
|
+
resources: [{ name: 'stream', types: ['movie', 'series'], idPrefixes: ['tt', 'tmdb:'] }] } };
|
|
262
|
+
}
|
|
263
|
+
return _addon;
|
|
264
|
+
}
|
|
265
|
+
function hasSources() { return isEnabled() && enabledPlugins().length > 0; }
|
|
266
|
+
|
|
267
|
+
return { supported: supported, isEnabled: isEnabled, setEnabled: setEnabled, repos: repos, addRepo: addRepo, refreshRepo: refreshRepo, removeRepo: removeRepo,
|
|
268
|
+
setPlugin: setPlugin, addressProblem: addressProblem, manifestUrl: manifestUrl, streams: streams, synthAddon: synthAddon, hasSources: hasSources,
|
|
269
|
+
toSource: toSource, workerFile: workerFile, experimental: experimental, slower: legacy, MAX_REPOS: MAX_REPOS };
|
|
270
|
+
})();
|
package/js/stremio-account.js
CHANGED
|
@@ -15,7 +15,7 @@ var StremioAccount = (function () {
|
|
|
15
15
|
function start() {
|
|
16
16
|
return U.getJSON(LINK + 'create?type=Create', 15000, 65536).then(function (r) {
|
|
17
17
|
var x = (r && r.result) || r || {};
|
|
18
|
-
if (!/^[A-Za-z0-9]{2,16}$/.test(x.code || '') || !U.parseUrl(x.link)) { throw new Error('Stremio didn’t give a code'); }
|
|
18
|
+
if (!/^[A-Za-z0-9]{2,16}$/.test(x.code || '') || !U.parseUrl(x.link)) { throw new Error(U.t('Stremio didn’t give a code')); }
|
|
19
19
|
return { code: x.code, link: x.link };
|
|
20
20
|
});
|
|
21
21
|
}
|
|
@@ -26,7 +26,7 @@ var StremioAccount = (function () {
|
|
|
26
26
|
return new Promise(function (resolve, reject) {
|
|
27
27
|
function ask() {
|
|
28
28
|
if (stopped && stopped()) { reject(new Error('stopped')); return; }
|
|
29
|
-
if (Date.now() > until) { reject(new Error('The code expired: try again')); return; }
|
|
29
|
+
if (Date.now() > until) { reject(new Error(U.t('The code expired: try again'))); return; }
|
|
30
30
|
U.getJSON(LINK + 'read?type=Read&code=' + encodeURIComponent(code), 15000, 65536).then(function (r) {
|
|
31
31
|
var key = r && r.result && r.result.authKey;
|
|
32
32
|
if (typeof key === 'string' && key && key.length < 200) { if (stopped && stopped()) { signOut(key); reject(new Error('stopped')); return; } resolve(key); return; }
|
|
@@ -42,26 +42,26 @@ var StremioAccount = (function () {
|
|
|
42
42
|
max = max || MAX_BYTES;
|
|
43
43
|
return new Promise(function (resolve, reject) {
|
|
44
44
|
var xhr = new XMLHttpRequest(), done = false;
|
|
45
|
-
try { xhr.open('POST', API + method, true); } catch (e) { reject(new Error('couldn’t reach Stremio')); return; }
|
|
45
|
+
try { xhr.open('POST', API + method, true); } catch (e) { reject(new Error(U.t('couldn’t reach Stremio'))); return; }
|
|
46
46
|
xhr.timeout = 20000;
|
|
47
47
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
48
48
|
xhr.onprogress = function (ev) { // (an answer over MAX_BYTES: stopped as it arrives, as every other request is)
|
|
49
|
-
if (!done && ev && ev.loaded > max) { done = true; try { xhr.abort(); } catch (e) {} reject(new Error('too large an answer')); }
|
|
49
|
+
if (!done && ev && ev.loaded > max) { done = true; try { xhr.abort(); } catch (e) {} reject(new Error(U.t('too large an answer'))); }
|
|
50
50
|
};
|
|
51
51
|
xhr.onreadystatechange = function () {
|
|
52
52
|
if (xhr.readyState !== 4 || done) { return; }
|
|
53
53
|
done = true;
|
|
54
54
|
var text = '' + (xhr.responseText || ''), data = null;
|
|
55
|
-
if (text.length > max) { reject(new Error('too large an answer')); return; }
|
|
55
|
+
if (text.length > max) { reject(new Error(U.t('too large an answer'))); return; }
|
|
56
56
|
try { data = JSON.parse(text); } catch (e2) { data = null; }
|
|
57
57
|
if (xhr.status >= 200 && xhr.status < 300 && data && data.result) { resolve(data.result); return; }
|
|
58
58
|
var err = new Error((data && data.error && data.error.message) || ('HTTP ' + xhr.status));
|
|
59
59
|
err.code = (data && data.error && typeof data.error.code === 'number') ? data.error.code : 0;
|
|
60
60
|
reject(err);
|
|
61
61
|
};
|
|
62
|
-
xhr.ontimeout = function () { if (!done) { done = true; reject(new Error('Stremio didn’t answer')); } };
|
|
63
|
-
xhr.onerror = function () { if (!done) { done = true; reject(new Error('couldn’t reach Stremio')); } };
|
|
64
|
-
try { xhr.send(JSON.stringify(body)); } catch (e3) { reject(new Error('couldn’t reach Stremio')); }
|
|
62
|
+
xhr.ontimeout = function () { if (!done) { done = true; reject(new Error(U.t('Stremio didn’t answer'))); } };
|
|
63
|
+
xhr.onerror = function () { if (!done) { done = true; reject(new Error(U.t('couldn’t reach Stremio'))); } };
|
|
64
|
+
try { xhr.send(JSON.stringify(body)); } catch (e3) { reject(new Error(U.t('couldn’t reach Stremio'))); }
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
// The account's addons StremioK can use: [{ url, name, description }] (a link on the
|
package/js/stremio-sync.js
CHANGED
|
@@ -67,7 +67,7 @@ var StremioSync = (function () {
|
|
|
67
67
|
function lostSignIn() {
|
|
68
68
|
if (!isConnected()) { return; }
|
|
69
69
|
setState({ reconnect: true });
|
|
70
|
-
if (!_told) { _told = true; U.toast('Your Stremio account needs connecting again: Settings › Content › Integrations', 6000); U.log('stremio', 'Stremio sign-in no longer works: connect again in Settings'); }
|
|
70
|
+
if (!_told) { _told = true; U.toast(U.t('Your Stremio account needs connecting again: Settings › Content › Integrations'), 6000); U.log('stremio', 'Stremio sign-in no longer works: connect again in Settings'); }
|
|
71
71
|
}
|
|
72
72
|
function connectStatus() {
|
|
73
73
|
var a = auth() || {}, s = state();
|
|
@@ -338,9 +338,9 @@ var StremioSync = (function () {
|
|
|
338
338
|
function synthAddon() {
|
|
339
339
|
return {
|
|
340
340
|
__local: true, __impl: { catalog: synthCatalog }, url: 'local:stremio', base: 'local:stremio',
|
|
341
|
-
manifest: { id: 'org.stremiok.stremio-library', name: 'Stremio Library', version: '1.0.0', types: ['movie', 'series'], resources: ['catalog'],
|
|
342
|
-
catalogs: [{ type: 'movie', id: 'stremio_library_movies', name: 'Stremio Library', extra: [{ name: 'skip' }] },
|
|
343
|
-
{ type: 'series', id: 'stremio_library_shows', name: 'Stremio Library', extra: [{ name: 'skip' }] }] }
|
|
341
|
+
manifest: { id: 'org.stremiok.stremio-library', name: U.t('Stremio Library'), version: '1.0.0', types: ['movie', 'series'], resources: ['catalog'],
|
|
342
|
+
catalogs: [{ type: 'movie', id: 'stremio_library_movies', name: U.t('Stremio Library'), extra: [{ name: 'skip' }] },
|
|
343
|
+
{ type: 'series', id: 'stremio_library_shows', name: U.t('Stremio Library'), extra: [{ name: 'skip' }] }] }
|
|
344
344
|
};
|
|
345
345
|
}
|
|
346
346
|
|
|
@@ -591,7 +591,7 @@ var StremioSync = (function () {
|
|
|
591
591
|
setState(sendOnly ? { err: '' } : { last: Date.now(), err: '' });
|
|
592
592
|
}, function (e) {
|
|
593
593
|
if (g !== _gen || (e && e.stale)) { return; }
|
|
594
|
-
setState({ err: (e && e.message) || 'couldn’t reach Stremio' });
|
|
594
|
+
setState({ err: (e && e.message) || U.t('couldn’t reach Stremio') });
|
|
595
595
|
U.log('stremio', 'Stremio sync: ' + ((e && e.message) || 'failed'));
|
|
596
596
|
}).then(function () {
|
|
597
597
|
if (_syncing === p) { _syncing = null; }
|