stremiok 2.3.5 → 2.3.7
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 +27 -0
- package/README.md +18 -15
- package/config.xml +2 -1
- package/css/style.css +1 -0
- package/index.html +43 -42
- package/js/lang/ar.js +94 -5
- package/js/lang/de.js +102 -13
- package/js/lang/es.js +92 -3
- package/js/lang/fi.js +98 -9
- package/js/lang/fr.js +102 -13
- package/js/lang/he.js +94 -5
- package/js/lang/hi.js +94 -5
- package/js/lang/it.js +94 -5
- package/js/lang/ja.js +94 -5
- package/js/lang/ko.js +92 -3
- package/js/lang/pl.js +118 -29
- package/js/lang/pt-BR.js +92 -3
- package/js/lang/ru.js +94 -5
- package/js/lang/tr.js +94 -5
- package/js/lang/zh-CN.js +96 -7
- package/js/local.js +63 -18
- package/js/netfolders.js +76 -8
- package/js/player-audio.js +16 -8
- package/js/player-controls.js +68 -0
- package/js/player-core.js +129 -9
- package/js/player-lang.js +16 -0
- package/js/player-store.js +7 -2
- package/js/player-subs.js +267 -17
- package/js/plugins.js +306 -0
- package/js/stremio.js +57 -8
- package/js/util.js +10 -1
- 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 +2 -2
- package/js/view-detail.js +18 -7
- package/js/view-settings.js +251 -15
- package/js/ytplay.js +60 -7
- package/package.json +1 -1
- package/service/index.js +1884 -67
- package/tizenbrew.html +1 -1
package/js/plugins.js
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
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, authorOff: x.enabled === 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, authorOff: !!p.authorOff }; // (authorOff: its repository marks it off, often as broken)
|
|
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
|
+
// A title's sources from the plugins that are on, within the time addons get (Settings ›
|
|
228
|
+
// Content › Addons › Wait for addons: a slower plugin is left out, the runtime started over so
|
|
229
|
+
// the next title doesn't wait behind it). The list carries _notes: [{ plugin, why }] for each
|
|
230
|
+
// that gave nothing (failed, too slow, no TMDB number), shown on No sources found.
|
|
231
|
+
function waitMs() {
|
|
232
|
+
var w = typeof Stremio !== 'undefined' && Stremio.getPrefs ? (+Stremio.getPrefs().addonWait || 0) * 1000 : 0;
|
|
233
|
+
return Math.max(w, 15000);
|
|
234
|
+
}
|
|
235
|
+
function streams(type, id, meta) {
|
|
236
|
+
if (!isEnabled()) { return Promise.resolve([]); }
|
|
237
|
+
var kind = type === 'series' ? 'tv' : type === 'movie' ? 'movie' : '';
|
|
238
|
+
var todo = enabledPlugins().filter(function (x) { return kind && x.p.types.indexOf(kind) !== -1; });
|
|
239
|
+
if (!todo.length) { return Promise.resolve([]); }
|
|
240
|
+
var ep = /:(\d+):(\d+)$/.exec(id || '');
|
|
241
|
+
function noted(list, notes) { list._notes = notes; return list; }
|
|
242
|
+
return tmdbOf(type, id || '', meta).then(function (tmdb) {
|
|
243
|
+
if (!tmdb) {
|
|
244
|
+
U.log('plugins', 'No TMDB number for ' + id + ' (a TMDB key is needed: Settings › Content › Integrations)');
|
|
245
|
+
return noted([], todo.map(function (x) { return { plugin: x.p.name, why: U.t('no TMDB number for this title (a TMDB key is needed: Settings › Content › Integrations)') }; }));
|
|
246
|
+
}
|
|
247
|
+
var args = [tmdb, kind, ep ? +ep[1] : null, ep ? +ep[2] : null];
|
|
248
|
+
return YTPlay.pluginNet(lanAllowed()).then(function (net) {
|
|
249
|
+
var out = [], notes = [], over = false, state = {};
|
|
250
|
+
var all = U.settleAll(todo.map(function (x) {
|
|
251
|
+
return function () {
|
|
252
|
+
if (over) { return Promise.resolve(); }
|
|
253
|
+
state[x.p.id] = 'running';
|
|
254
|
+
return U.bigStore.get(CODE + x.repo.id + '.' + x.p.id).then(function (code) {
|
|
255
|
+
if (typeof code !== 'string' || !code) { throw new Error('its code isn’t on the TV: refresh its repository'); }
|
|
256
|
+
return runOne(code, x.p, args, net);
|
|
257
|
+
}).then(function (r) {
|
|
258
|
+
if (over) { return; }
|
|
259
|
+
(r.logs || []).slice(0, 20).forEach(function (l) { U.log('plugins', x.p.name + ': ' + l); });
|
|
260
|
+
if (r.type !== 'done') { throw new Error(r.why || 'failed'); }
|
|
261
|
+
var list = (Array.isArray(r.streams) ? r.streams : []).slice(0, MAX_RESULTS).map(function (s, n) { return toSource(s, x.p, n); }).filter(Boolean);
|
|
262
|
+
state[x.p.id] = 'done';
|
|
263
|
+
if (!list.length) { notes.push({ plugin: x.p.name, why: U.t('no sources for this') }); }
|
|
264
|
+
out = out.concat(list);
|
|
265
|
+
}).then(null, function (e) {
|
|
266
|
+
if (over) { return; }
|
|
267
|
+
var why = '' + ((e && e.message) || e);
|
|
268
|
+
state[x.p.id] = 'failed';
|
|
269
|
+
U.log('plugins', x.p.name + ' (' + args.slice(0, 2).join(' ') + '): ' + why);
|
|
270
|
+
notes.push({ plugin: x.p.name, why: why });
|
|
271
|
+
});
|
|
272
|
+
};
|
|
273
|
+
}), legacy() ? 1 : AT_ONCE);
|
|
274
|
+
return new Promise(function (resolve) {
|
|
275
|
+
var timer = setTimeout(function () {
|
|
276
|
+
over = true;
|
|
277
|
+
var late = todo.filter(function (x) { return state[x.p.id] !== 'done' && state[x.p.id] !== 'failed'; });
|
|
278
|
+
late.forEach(function (x) {
|
|
279
|
+
U.log('plugins', x.p.name + ' (' + args.slice(0, 2).join(' ') + '): too slow, left out after ' + Math.round(waitMs() / 1000) + ' s');
|
|
280
|
+
notes.push({ plugin: x.p.name, why: U.t('too slow: left out after {n} s (Wait for addons)', { n: Math.round(waitMs() / 1000) }) });
|
|
281
|
+
});
|
|
282
|
+
if (late.length) { fail('too slow'); } // (the runtime started over: the next title doesn't wait behind them)
|
|
283
|
+
resolve(noted(out, notes));
|
|
284
|
+
}, waitMs());
|
|
285
|
+
all.then(function () { if (over) { return; } over = true; clearTimeout(timer); resolve(noted(out, notes)); });
|
|
286
|
+
});
|
|
287
|
+
}, function () { return []; });
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// The synthetic addon its sources come in as ("Nuvio plugins": a source addon, no catalogs)
|
|
292
|
+
var _addon = null;
|
|
293
|
+
function synthAddon() {
|
|
294
|
+
if (!_addon) {
|
|
295
|
+
_addon = { __local: true, __sources: true, __impl: { streams: streams }, url: 'local:plugins', base: 'local:plugins',
|
|
296
|
+
manifest: { id: 'org.stremiok.plugins', name: 'Nuvio plugins', version: '1.0.0', types: ['movie', 'series'], catalogs: [],
|
|
297
|
+
resources: [{ name: 'stream', types: ['movie', 'series'], idPrefixes: ['tt', 'tmdb:'] }] } };
|
|
298
|
+
}
|
|
299
|
+
return _addon;
|
|
300
|
+
}
|
|
301
|
+
function hasSources() { return isEnabled() && enabledPlugins().length > 0; }
|
|
302
|
+
|
|
303
|
+
return { supported: supported, isEnabled: isEnabled, setEnabled: setEnabled, repos: repos, addRepo: addRepo, refreshRepo: refreshRepo, removeRepo: removeRepo,
|
|
304
|
+
setPlugin: setPlugin, addressProblem: addressProblem, manifestUrl: manifestUrl, streams: streams, synthAddon: synthAddon, hasSources: hasSources,
|
|
305
|
+
toSource: toSource, workerFile: workerFile, experimental: experimental, slower: legacy, MAX_REPOS: MAX_REPOS };
|
|
306
|
+
})();
|
package/js/stremio.js
CHANGED
|
@@ -443,6 +443,7 @@ var Stremio = (function () {
|
|
|
443
443
|
else if (iptvOn) { iptvJoin(addons, rev); }
|
|
444
444
|
if (typeof XtVod !== 'undefined' && XtVod.isEnabled()) { addons.push(XtVod.synthAddon()); } // (your Xtream accounts' films and series: after your addons)
|
|
445
445
|
if (typeof StVod !== 'undefined' && StVod.isEnabled()) { addons.push(StVod.synthAddon()); } // (your Stalker portals' films and series)
|
|
446
|
+
if (typeof Plugins !== 'undefined' && Plugins.hasSources()) { addons.push(Plugins.synthAddon()); } // (your Nuvio plugins: a source addon)
|
|
446
447
|
if (typeof Jellyfin !== 'undefined') { Jellyfin.synthAddons().forEach(function (a) { addons.push(a); }); } // (your Jellyfin and Emby servers' libraries: one addon a kind)
|
|
447
448
|
if (typeof Plex !== 'undefined') { Plex.synthAddons().forEach(function (a) { addons.push(a); }); } // (your Plex servers')
|
|
448
449
|
if (hasYouTube()) { addons.push(YouTube.synthAddon()); } // (after your addons: its rows last on Home)
|
|
@@ -569,14 +570,16 @@ var Stremio = (function () {
|
|
|
569
570
|
// The file import reads (parseSetupList): a line an addon link, playlist link or API key, what
|
|
570
571
|
// any StremioK imports, and #!stremiok <kind> <JSON> lines, comments to an older one: playlist
|
|
571
572
|
// (a playlist's name, guide link, off), stalker (a portal) and store (one of EXPORT_STORE, what
|
|
572
|
-
// you chose in Settings: not caches
|
|
573
|
-
//
|
|
574
|
-
// yours, only those
|
|
573
|
+
// you chose in Settings: not caches or your Trakt sign-in; integrations without the three keys,
|
|
574
|
+
// which have their own lines, or Trakt's) and history (one of HISTORY_STORE, when ticked: where
|
|
575
|
+
// you stopped, watched marks…). Imported settings and history replace yours, only those listed.
|
|
575
576
|
var EXPORT_LINE = '#!stremiok ';
|
|
576
577
|
var EXPORT_STORE = ['stremiok.prefs', 'stremiok.feeds', 'stremiok.searchfeeds', 'stremiok.sourcefeeds', 'stremiok.ranking', 'stremiok.server', 'stremiok.formats',
|
|
577
578
|
'stremiok.resblock', 'stremiok.subcfg', 'stremiok.audiocfg', 'stremiok.playercfg', 'stremiok.private', 'stremiok.youtube', 'stremiok.appshortcuts',
|
|
578
579
|
'stremiok.appsallowed', 'stremiok.aiomanager', 'stremiok.iptv.stalkerall', 'stremiok.iptv.stalkerkeep', 'stremiok.iptv.every', 'stremiok.local.matching', 'stremiok.local.hidden',
|
|
579
580
|
'stremiok.addonsoff', 'stremiok.integrations'];
|
|
581
|
+
var HISTORY_STORE = ['stremiok.progress', 'stremiok.watched', 'stremiok.cworder', 'stremiok.subhist', 'stremiok.audiohist', 'stremiok.playedsrc', 'stremiok.seriessrc',
|
|
582
|
+
'stremiok.unsuitable', 'stremiok.aspects', 'stremiok.iptv.favs', 'stremiok.local.matches', 'stremiok.local.fixes'];
|
|
580
583
|
function plural(n, one) { return n + ' ' + one + (n === 1 ? '' : 's'); }
|
|
581
584
|
function iptvLists() { return (_hasIptv && IPTV.getPlaylists) ? IPTV.getPlaylists() : []; }
|
|
582
585
|
// What there is to export: [{ key, label }] (settings always).
|
|
@@ -589,6 +592,7 @@ var Stremio = (function () {
|
|
|
589
592
|
if (st) { out.push({ key: 'stalker', label: U.tn(st, '{n} Stalker portal (their MAC addresses)', '{n} Stalker portals (their MAC addresses)') }); }
|
|
590
593
|
if (keys.length) { out.push({ key: 'keys', label: U.t('API keys: {keys}', { keys: keys.join(', ') }) }); }
|
|
591
594
|
out.push({ key: 'settings', label: U.t('Your settings: look, Home, playback, subtitles, sources, streaming server, YouTube…') });
|
|
595
|
+
if (HISTORY_STORE.some(function (k) { return U.store.get(k, null) != null; })) { out.push({ key: 'history', label: U.t('Your history: where you stopped, watched marks, Continue Watching…'), off: true }); }
|
|
592
596
|
return out;
|
|
593
597
|
}
|
|
594
598
|
function settingsValue(key) {
|
|
@@ -633,11 +637,18 @@ var Stremio = (function () {
|
|
|
633
637
|
if (v !== null && v !== undefined) { out.push(EXPORT_LINE + 'store ' + JSON.stringify({ k: key.replace(/^stremiok\./, ''), v: v })); }
|
|
634
638
|
});
|
|
635
639
|
}
|
|
640
|
+
if (want.history) {
|
|
641
|
+
out.push('');
|
|
642
|
+
HISTORY_STORE.forEach(function (key) {
|
|
643
|
+
var v = U.store.get(key, null);
|
|
644
|
+
if (v !== null && v !== undefined) { out.push(EXPORT_LINE + 'history ' + JSON.stringify({ k: key.replace(/^stremiok\./, ''), v: v })); }
|
|
645
|
+
});
|
|
646
|
+
}
|
|
636
647
|
return out.join('\n') + '\n';
|
|
637
648
|
}
|
|
638
649
|
function parseSetupList(text) {
|
|
639
650
|
var out = { items: [], ignored: 0 }, seen = {}, mine = getAddonUrls(), integ = getIntegrations();
|
|
640
|
-
var have = iptvLists(), lists = have.map(function (x) { return x.url; }), details = {}, store = [];
|
|
651
|
+
var have = iptvLists(), lists = have.map(function (x) { return x.url; }), details = {}, store = [], hist = [];
|
|
641
652
|
function push(it) { var k = it.kind + ' ' + it.value; if (seen[k]) { return; } seen[k] = 1; out.items.push(it); }
|
|
642
653
|
function stremiokLine(rest) { // (an export's own lines: see exportSetup)
|
|
643
654
|
var m = /^([a-z]+)\s+(\{[\s\S]*\})$/.exec(rest), o = null;
|
|
@@ -651,6 +662,7 @@ var Stremio = (function () {
|
|
|
651
662
|
return;
|
|
652
663
|
}
|
|
653
664
|
if (m[1] === 'store' && typeof o.k === 'string' && EXPORT_STORE.indexOf('stremiok.' + o.k) !== -1 && o.v !== undefined && o.v !== null) { store.push(o); return; }
|
|
665
|
+
if (m[1] === 'history' && typeof o.k === 'string' && HISTORY_STORE.indexOf('stremiok.' + o.k) !== -1 && o.v !== undefined && o.v !== null) { hist.push(o); return; }
|
|
654
666
|
out.ignored++;
|
|
655
667
|
}
|
|
656
668
|
('' + (text || '')).split(/\r?\n/).forEach(function (line) {
|
|
@@ -677,6 +689,7 @@ var Stremio = (function () {
|
|
|
677
689
|
if (d) { it.info = d; if (typeof d.name === 'string' && d.name) { it.label = U.t('IPTV playlist') + ' · ' + d.name.slice(0, 60); } }
|
|
678
690
|
});
|
|
679
691
|
if (store.length) { push({ kind: 'settings', value: 'settings', entries: store, label: U.tn(store.length, 'Your settings ({n} part)', 'Your settings ({n} parts)'), have: false, note: U.t('replaces yours') }); }
|
|
692
|
+
if (hist.length) { push({ kind: 'history', value: 'history', entries: hist, label: U.t('Your history and progress'), have: false, note: U.t('replaces yours') }); }
|
|
680
693
|
return out;
|
|
681
694
|
}
|
|
682
695
|
function playlistDetails(id, d) {
|
|
@@ -686,7 +699,7 @@ var Stremio = (function () {
|
|
|
686
699
|
}
|
|
687
700
|
// Import the chosen lines (parseSetupList's items): what was added, as importSetupList says.
|
|
688
701
|
function applySetupEntries(items) {
|
|
689
|
-
var result = { addons: 0, playlists: 0, omdb: false, tmdb: false, mdblist: false, settings: false, ignored: 0 };
|
|
702
|
+
var result = { addons: 0, playlists: 0, omdb: false, tmdb: false, mdblist: false, settings: false, history: false, ignored: 0 };
|
|
690
703
|
(items || []).forEach(function (it) {
|
|
691
704
|
if (KEY_NAMES[it.kind]) { setIntegration(it.kind, it.value); result[it.kind] = true; }
|
|
692
705
|
else if (it.kind === 'playlist') {
|
|
@@ -709,6 +722,9 @@ var Stremio = (function () {
|
|
|
709
722
|
} else { U.store.set(key, o.v); }
|
|
710
723
|
});
|
|
711
724
|
result.settings = true;
|
|
725
|
+
} else if (it.kind === 'history') {
|
|
726
|
+
it.entries.forEach(function (o) { var key = 'stremiok.' + o.k; if (HISTORY_STORE.indexOf(key) !== -1) { U.store.set(key, o.v); } });
|
|
727
|
+
result.history = true;
|
|
712
728
|
}
|
|
713
729
|
else if (it.kind === 'addon') {
|
|
714
730
|
var added = addAddon(it.value);
|
|
@@ -1170,6 +1186,10 @@ var Stremio = (function () {
|
|
|
1170
1186
|
var ph = s.behaviorHints && s.behaviorHints.proxyHeaders, h = ph && ph.request ? U.sanitizeHeaders(ph.request) : null;
|
|
1171
1187
|
if (h) { s._headers = h; }
|
|
1172
1188
|
});
|
|
1189
|
+
// (StremioK's own source that says why parts of it gave nothing: Nuvio plugins, one line each)
|
|
1190
|
+
if (a.__impl && res.streams && Array.isArray(res.streams._notes)) {
|
|
1191
|
+
res.streams._notes.slice(0, 10).forEach(function (n) { notes.push({ addon: (a.manifest.name || U.t('Addon')) + ' · ' + ('' + n.plugin).slice(0, 60), title: ('' + n.why).replace(/\s+/g, ' ').slice(0, 160), text: '', rank: i }); });
|
|
1192
|
+
}
|
|
1173
1193
|
slots[i] = arr; okCount++;
|
|
1174
1194
|
if (!arr.length && notes.length === said) { note(a, i, U.t('no sources for this')); } // (its notices say why, when it sent any)
|
|
1175
1195
|
}).then(function () { done(); }, function (err) {
|
|
@@ -2320,6 +2340,35 @@ var Stremio = (function () {
|
|
|
2320
2340
|
if (info.container && info.container !== 'hls') { out.push(info.container.toUpperCase()); }
|
|
2321
2341
|
return out.join(' · ');
|
|
2322
2342
|
}
|
|
2343
|
+
// A source's details corrected by its file's header (the player's S.mi: see the service's
|
|
2344
|
+
// mediaInfo), where the header says: resolution (by width: a wide film is less tall), codec,
|
|
2345
|
+
// bit depth, HDR (Dolby Vision with or without a layer under it), the audio track that plays
|
|
2346
|
+
// first, the container. What the header doesn't say stays as the name had it.
|
|
2347
|
+
var FILE_AUDIO = { truehd: 'truehd', dts: 'dts', eac3: 'eac3', ac3: 'ac3', aac: 'aac', opus: 'opus', flac: 'flac' };
|
|
2348
|
+
function withFileInfo(info, mi) {
|
|
2349
|
+
var i = {};
|
|
2350
|
+
Object.keys(info || {}).forEach(function (k) { i[k] = info[k]; });
|
|
2351
|
+
i.audio = ((info && info.audio) || []).slice();
|
|
2352
|
+
if (!mi || typeof mi !== 'object') { return i; }
|
|
2353
|
+
var v = mi.video;
|
|
2354
|
+
if (v) {
|
|
2355
|
+
var w = +v.width || 0, h = +v.height || 0;
|
|
2356
|
+
if (w || h) { i.res = w >= 3200 || h >= 1800 ? 2160 : w >= 2400 || h >= 1300 ? 1440 : w >= 1700 || h >= 900 ? 1080 : w >= 1100 || h >= 650 ? 720 : 480; }
|
|
2357
|
+
if (/^(h264|hevc|av1)$/.test(v.codec || '')) { i.codec = v.codec; }
|
|
2358
|
+
if (v.bitDepth >= 10) { i.bits10 = true; } else if (v.bitDepth === 8) { i.bits10 = false; }
|
|
2359
|
+
if (v.dv) { i.hdr = (v.dv.compat === 1 || v.dv.compat === 6 || v.dv.compat === 4 || v.dv.compat === 2) ? 'dv' : 'dv-only'; }
|
|
2360
|
+
else if (v.hdr === 'hdr10' || v.hdr === 'hlg') { i.hdr = i.hdr === 'hdr10p' && v.hdr === 'hdr10' ? 'hdr10p' : 'hdr'; }
|
|
2361
|
+
}
|
|
2362
|
+
var tracks = mi.audio || [], first = tracks.filter(function (a) { return a.default; })[0] || tracks[0];
|
|
2363
|
+
if (first && FILE_AUDIO[first.codec]) {
|
|
2364
|
+
var a = FILE_AUDIO[first.codec];
|
|
2365
|
+
if (a === 'dts' && i.audio.indexOf('dtshd') !== -1) { a = 'dtshd'; } // (DTS-HD looks like DTS in a header: the name says which)
|
|
2366
|
+
i.audio = (i.audio.indexOf('atmos') !== -1 && (a === 'truehd' || a === 'eac3') ? ['atmos'] : []).concat([a]);
|
|
2367
|
+
}
|
|
2368
|
+
if (/^(mkv|mp4|webm)$/.test(mi.container || '')) { i.container = mi.container; } else if (mi.container === 'mov') { i.container = 'mp4'; }
|
|
2369
|
+
i.fromFile = true;
|
|
2370
|
+
return i;
|
|
2371
|
+
}
|
|
2323
2372
|
function formatKeys(info) {
|
|
2324
2373
|
var k = [], pk = profileKey(info);
|
|
2325
2374
|
if (pk) { k.push(pk); }
|
|
@@ -2408,7 +2457,7 @@ var Stremio = (function () {
|
|
|
2408
2457
|
addonUrlProblem: function (v) { return U.urlProblem(v); },
|
|
2409
2458
|
getAddonUrls: getAddonUrls, manifestProblem: function (url) { return _manifestProblem[url] || ''; }, manifestDetail: function (url) { return _manifestDetail[url] || ''; }, addAddon: addAddon, removeAddon: removeAddon, moveAddon: moveAddon, streamNotes: streamNotes, keepSource: keepSource, forgetSource: forgetSource, sourceId: sourceId, hasStreamAddons: hasStreamAddons, thirdPartyNote: thirdPartyNote, refreshAddons: refreshAddons, refreshAddon: refreshAddon,
|
|
2410
2459
|
getIntegrations: getIntegrations, setIntegration: setIntegration, getPrefs: getPrefs, setPref: setPref, addonLogo: addonLogo,
|
|
2411
|
-
getIntroSegments: getIntroSegments,
|
|
2460
|
+
getIntroSegments: getIntroSegments, tmdbFind: tmdbFind,
|
|
2412
2461
|
tmdbValidate: tmdbValidate, mdblistValidate: mdblistValidate, omdbValidate: omdbValidate,
|
|
2413
2462
|
tmdbFindTvId: tmdbFindTvId, tmdbSeasonEpisodes: tmdbSeasonEpisodes, tmdbImg: tmdbImg,
|
|
2414
2463
|
tmdbTitleExtras: tmdbTitleExtras, tmdbExtrasById: tmdbExtrasById, tmdbEpisodeCast: tmdbEpisodeCast, tmdbEpisodeTrailer: tmdbEpisodeTrailer, setHideWords: setHideWords, hideWordHit: hideWordHit, normalizeAddonUrl: normalizeManifestUrl, debridOf: debridOf, addonOrigin: addonOrigin, setAddonOrigin: setAddonOrigin, parseSetupList: parseSetupList, applySetupEntries: applySetupEntries, exportGroups: exportGroups, exportSetup: exportSetup, sizeLimitHit: sizeLimitHit, setSizeLimit: setSizeLimit, gbText: gbText, runtimeMinutes: runtimeMinutes, tmdbPeople: tmdbPeople, tmdbPerson: tmdbPerson, tmdbBrowse: tmdbBrowse, tmdbTitleTrailers: tmdbTitleTrailers, tmdbProviders: tmdbProviders, tmdbProvidersKept: tmdbProvidersKept, tmdbGenres: tmdbGenres, tmdbWhereToWatch: tmdbWhereToWatch, watchRegion: watchRegion, autoWatchRegion: autoWatchRegion, tmdbImdbId: tmdbImdbId, findFilm: findFilm, hasTmdb: function () { return !!tmdbKey(); },
|
|
@@ -2420,7 +2469,7 @@ var Stremio = (function () {
|
|
|
2420
2469
|
getMeta: getMeta, getStreams: getStreams, prefetchStreams: prefetchStreams, dedupeStreams: dedupeStreams,
|
|
2421
2470
|
getSubtitles: getSubtitles,
|
|
2422
2471
|
getSearchCatalogs: getSearchCatalogs, findTitles: findTitles,
|
|
2423
|
-
addonsChanged: function () { _loaded = null; }, // (StremioK's own YouTube catalogs changed)
|
|
2472
|
+
addonsChanged: function () { _loaded = null; }, sourcesChanged: sourcesChanged, // (StremioK's own YouTube catalogs changed)
|
|
2424
2473
|
setAllowLocal: function (on) { setPref('allowLocal', !!on); var kept = _loaded; configChanged(); _loaded = kept; },
|
|
2425
2474
|
getRanking: getRanking, moveRanking: moveRanking, toggleRanking: toggleRanking,
|
|
2426
2475
|
setPlayedFirst: setPlayedFirst, resetRanking: resetRanking,
|
|
@@ -2436,7 +2485,7 @@ var Stremio = (function () {
|
|
|
2436
2485
|
isPlayable: isPlayable, youTubeSource: youTubeSource, torrentSource: torrentSource,
|
|
2437
2486
|
keptSources: keptSources, torrentFile: torrentFile, server: server, setServer: setServer, testServer: testServer, convertUrl: convertUrl, serverAddressProblem: serverAddressProblem, streamLabel: streamLabel, streamName: streamName,
|
|
2438
2487
|
streamSize: streamSize, streamDescription: streamDescription,
|
|
2439
|
-
streamInfo: streamInfo, formatTags: formatTags, formatKeys: formatKeys, recordFormats: recordFormats, setFormat: setFormat,
|
|
2488
|
+
streamInfo: streamInfo, formatTags: formatTags, formatKeys: formatKeys, withFileInfo: withFileInfo, recordFormats: recordFormats, setFormat: setFormat,
|
|
2440
2489
|
resetFormats: resetFormats, badFormats: badFormats, formatList: formatList,
|
|
2441
2490
|
resList: resList, setResAllowed: setResAllowed, blockedRes: blockedRes,
|
|
2442
2491
|
importSetupList: importSetupList, savedManifest: savedManifest, isAddonOff: isAddonOff, setAddonOff: setAddonOff, onIptvReady: onIptvReady, streamListenerCount: function (type, id) { var e = _streamCache[type + ':' + id]; return e ? e.listeners.length : 0; },
|
package/js/util.js
CHANGED
|
@@ -398,12 +398,21 @@ var U = (function () {
|
|
|
398
398
|
var ua = headerValue(h.ua != null ? h.ua : (h['User-Agent'] || h['user-agent']), HEADER_MAX.ua);
|
|
399
399
|
var ref = headerValue(h.ref != null ? h.ref : (h.Referer || h.referer), HEADER_MAX.ref);
|
|
400
400
|
var cookie = headerValue(h.cookie != null ? h.cookie : (h.Cookie || h.COOKIE), HEADER_MAX.cookie);
|
|
401
|
+
// (and three the TV's player can't send, played through the service: see player-core's
|
|
402
|
+
// fileViaService) an Origin is a site's address alone
|
|
403
|
+
var origin = headerValue(h.origin != null ? h.origin : (h.Origin || h.ORIGIN), HEADER_MAX.ref);
|
|
404
|
+
var accept = headerValue(h.accept != null ? h.accept : (h.Accept || h.ACCEPT), HEADER_MAX.ua);
|
|
405
|
+
var lang = headerValue(h.lang != null ? h.lang : (h['Accept-Language'] || h['accept-language']), HEADER_MAX.ua);
|
|
401
406
|
if (ref && !/^https?:\/\/[^\s]+$/i.test(ref)) { ref = ''; }
|
|
402
|
-
if (
|
|
407
|
+
if (origin && !/^https?:\/\/[^\s\/?#]+$/i.test(origin)) { origin = ''; }
|
|
408
|
+
if (!ua && !ref && !cookie && !origin && !accept && !lang) { return null; }
|
|
403
409
|
var out = {};
|
|
404
410
|
if (ua) { out.ua = ua; }
|
|
405
411
|
if (ref) { out.ref = ref; }
|
|
406
412
|
if (cookie) { out.cookie = cookie; }
|
|
413
|
+
if (origin) { out.origin = origin; }
|
|
414
|
+
if (accept) { out.accept = accept; }
|
|
415
|
+
if (lang) { out.lang = lang; }
|
|
407
416
|
return out;
|
|
408
417
|
}
|
|
409
418
|
|