stremiok 2.3.5 → 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 +10 -0
- package/README.md +13 -13
- package/config.xml +1 -1
- package/index.html +43 -42
- package/js/lang/ar.js +33 -2
- package/js/lang/de.js +41 -10
- package/js/lang/es.js +31 -0
- package/js/lang/fi.js +37 -6
- package/js/lang/fr.js +41 -10
- package/js/lang/he.js +33 -2
- package/js/lang/hi.js +33 -2
- package/js/lang/it.js +33 -2
- package/js/lang/ja.js +33 -2
- package/js/lang/ko.js +31 -0
- package/js/lang/pl.js +57 -26
- package/js/lang/pt-BR.js +31 -0
- package/js/lang/ru.js +33 -2
- package/js/lang/tr.js +33 -2
- package/js/lang/zh-CN.js +35 -4
- package/js/player-core.js +31 -1
- package/js/plugins.js +270 -0
- package/js/stremio.js +3 -2
- 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-detail.js +8 -4
- package/js/view-settings.js +85 -1
- package/js/ytplay.js +28 -3
- package/package.json +1 -1
- package/service/index.js +227 -13
- package/tizenbrew.html +1 -1
|
Binary file
|
package/js/view-detail.js
CHANGED
|
@@ -1629,15 +1629,19 @@
|
|
|
1629
1629
|
U.store.set(UNSUIT_KEY, all);
|
|
1630
1630
|
}
|
|
1631
1631
|
// Hold OK on a source: Play from the start (a place to resume), Play through StremioK's service
|
|
1632
|
-
// (
|
|
1632
|
+
// (see serviceHlsOk), Not suitable (or back), and
|
|
1633
1633
|
// with a USB drive plugged in, Download to it (js/downloads.js). With only Not suitable to
|
|
1634
1634
|
// offer, it's asked at once.
|
|
1635
|
-
//
|
|
1636
|
-
//
|
|
1635
|
+
// A source on the internet (not YouTube, DRM, a USB file or the service's own links): Play
|
|
1636
|
+
// through StremioK's service, this once. An HLS one through its relay (Settings › Playback ›
|
|
1637
|
+
// Seeking & buffering › HLS through StremioK's service, for all of them; not under TizenBrew,
|
|
1638
|
+
// whose page player can't take it), a file through the file relay (player-core's fileViaService).
|
|
1637
1639
|
function serviceHlsOk(stream) {
|
|
1638
1640
|
if (!stream || stream._yt || stream._localFile || stream._drm || typeof YTPlay === 'undefined' || YTPlay.installMode() === 'browser') { return false; }
|
|
1639
1641
|
var url = '' + (stream.url || '');
|
|
1640
|
-
|
|
1642
|
+
if (!/^https?:\/\//i.test(url) || /^http:\/\/(localhost|127\.0\.0\.1)[:\/]/i.test(url) || /\.mpd(?:[?#]|$)/i.test(url)) { return false; }
|
|
1643
|
+
var hls = /\.m3u8?(?:[?#]|$)/i.test(url) || Stremio.streamInfo(stream).container === 'hls';
|
|
1644
|
+
return !hls || YTPlay.installMode() !== 'tizenbrew';
|
|
1641
1645
|
}
|
|
1642
1646
|
function sourceMenu(stream) {
|
|
1643
1647
|
var canStart = !howHere() && savedPlace(_d.streamId);
|
package/js/view-settings.js
CHANGED
|
@@ -404,6 +404,7 @@
|
|
|
404
404
|
[U.t('USB drive'), U.t('The Local tab: what\'s on your drive, matched to titles; hidden files'), 'usb'],
|
|
405
405
|
[U.t('Network folders'), U.t('Folders a NAS or computer shares over WebDAV, in the Local tab: their videos as sources'), 'netfolders'],
|
|
406
406
|
[U.t('Media servers'), U.t('Your Jellyfin or Emby server: its libraries on Home, its files as sources'), 'mediaservers'],
|
|
407
|
+
[U.t('Nuvio plugins'), U.t('Programs written for the Nuvio apps that look for sources: someone else’s code, run on your TV'), 'plugins'],
|
|
407
408
|
[U.t('Import configuration file'), U.t('Import addons, API keys & IPTV playlists'), 'import'],
|
|
408
409
|
[U.t('Export configuration'), U.t('Your addons, playlists, API keys and settings, to your phone'), 'export']] },
|
|
409
410
|
playback: { title: U.t('Playback'), rows: [
|
|
@@ -467,6 +468,7 @@
|
|
|
467
468
|
else if (_settingsSection === 'usb') { settingsUsb(wrap); }
|
|
468
469
|
else if (_settingsSection === 'netfolders') { settingsNetFolders(wrap); }
|
|
469
470
|
else if (_settingsSection === 'mediaservers') { settingsMediaServers(wrap); }
|
|
471
|
+
else if (_settingsSection === 'plugins') { settingsPlugins(wrap); }
|
|
470
472
|
else if (_settingsSection === 'private') { settingsPrivate(wrap); }
|
|
471
473
|
else if (_settingsSection === 'appshortcuts') { settingsAppShortcuts(wrap); }
|
|
472
474
|
else if (_settingsSection === 'import') { settingsImport(wrap); }
|
|
@@ -533,7 +535,10 @@
|
|
|
533
535
|
function settingsGroup(wrap, key) {
|
|
534
536
|
var g = SETTINGS_GROUPS[key];
|
|
535
537
|
wrap.appendChild(U.el('h2', null, g.title));
|
|
536
|
-
g.rows.forEach(function (row) {
|
|
538
|
+
g.rows.forEach(function (row) {
|
|
539
|
+
if (row[2] === 'plugins' && !(typeof Plugins !== 'undefined' && Plugins.supported())) { return; } // (a TV that can't run them: not offered)
|
|
540
|
+
wrap.appendChild(sectionRow(row[0], row[1], row[2]));
|
|
541
|
+
});
|
|
537
542
|
if (key === 'diagnostics') {
|
|
538
543
|
if (typeof YTPlay !== 'undefined' && YTPlay.installMode && YTPlay.installMode() === 'tizenbrew') { wrap.appendChild(U.el('div', 'hint', TIZENBREW_NOTE)); }
|
|
539
544
|
// How StremioK was installed, and whether its YouTube service (channels, trailers) answers
|
|
@@ -1712,6 +1717,85 @@
|
|
|
1712
1717
|
}
|
|
1713
1718
|
|
|
1714
1719
|
// ---- Media servers: your Jellyfin servers ----
|
|
1720
|
+
// Settings › Content › Nuvio plugins (js/plugins.js): on / off (after a warning), the
|
|
1721
|
+
// repositories you added, each one's plugins on / off. Only on a TV that can run them.
|
|
1722
|
+
function settingsPlugins(wrap) {
|
|
1723
|
+
wrap.appendChild(U.el('h2', null, U.t('Nuvio plugins')));
|
|
1724
|
+
if (typeof Plugins === 'undefined' || !Plugins.supported()) {
|
|
1725
|
+
wrap.appendChild(U.el('div', 'hint', U.t('Nuvio plugins need a 2017 or newer TV and the sideloaded app.')));
|
|
1726
|
+
focusSettings(); return;
|
|
1727
|
+
}
|
|
1728
|
+
var on = Plugins.isEnabled(), focus = null;
|
|
1729
|
+
var sw = U.el('div', 'addon-item focusable cfg-row');
|
|
1730
|
+
sw.appendChild(U.el('div', 'a-name', U.t('Nuvio plugins:') + ' ' + (on ? U.t('On') : U.t('Off'))));
|
|
1731
|
+
sw.appendChild(U.el('div', 'a-url', (on ? U.t('Your plugins look for sources on title pages') : U.t('Off: no plugin runs'))
|
|
1732
|
+
+ ' · ' + (on ? U.t('OK to turn off') : U.t('OK to turn on'))));
|
|
1733
|
+
sw.__onselect = function () {
|
|
1734
|
+
_focusChild = 'pl:switch';
|
|
1735
|
+
if (on) { Plugins.setEnabled(false); renderSettings(); return; }
|
|
1736
|
+
confirm(U.t('Nuvio plugins are someone else’s code, run on your TV. StremioK keeps them apart from your settings and files, but they can reach any website, they learn which titles you open, and they’re given your TMDB key. StremioK doesn’t check what they find, and gives no help with any particular plugin. Turn them on?'),
|
|
1737
|
+
U.t('Turn on'), function () { Plugins.setEnabled(true); renderSettings(); });
|
|
1738
|
+
};
|
|
1739
|
+
if (_focusChild === 'pl:switch') { focus = sw; }
|
|
1740
|
+
wrap.appendChild(sw);
|
|
1741
|
+
if (!Stremio.getIntegrations().tmdb) { wrap.appendChild(U.el('div', 'hint', U.t('Plugins look titles up by their TMDB number: add a TMDB key in Settings › Content › Integrations.'))); }
|
|
1742
|
+
if (Plugins.experimental()) { wrap.appendChild(U.el('div', 'hint', U.t('Experimental on this TV: plugins haven’t been tried on its generation yet, and run slower here (one at a time).'))); }
|
|
1743
|
+
else if (Plugins.slower()) { wrap.appendChild(U.el('div', 'hint', U.t('Plugins run slower on this TV than on 2021 and newer ones (one at a time).'))); }
|
|
1744
|
+
var add = U.el('div', 'addon-item focusable cfg-row');
|
|
1745
|
+
add.appendChild(U.el('div', 'a-name', U.t('+ Add a repository')));
|
|
1746
|
+
add.appendChild(U.el('div', 'a-url', U.t('Its address (a manifest.json): its plugins are listed, each off until you turn it on')));
|
|
1747
|
+
add.__onselect = function () {
|
|
1748
|
+
App.openEntry({
|
|
1749
|
+
title: U.t('Nuvio plugins: repository'), hint: U.t('Its address, like https://example.com/plugins/manifest.json. RETURN cancels.'),
|
|
1750
|
+
value: 'https://', placeholder: 'https://example.com/plugins/manifest.json', phone: 'plugins',
|
|
1751
|
+
validate: function (v) { return Plugins.addressProblem(v); },
|
|
1752
|
+
onConfirm: function (url) {
|
|
1753
|
+
App.back();
|
|
1754
|
+
U.spinner(true, U.t('Reading the repository…'));
|
|
1755
|
+
Plugins.addRepo(url).then(function (r) {
|
|
1756
|
+
U.spinner(false);
|
|
1757
|
+
U.toast(U.tn(r.repo.plugins.length, 'Added “{name}”: {n} plugin (off until you turn it on)', 'Added “{name}”: {n} plugins (off until you turn them on)', { name: r.repo.name }), 5000);
|
|
1758
|
+
_focusChild = 'pl:' + r.repo.id;
|
|
1759
|
+
renderSettings();
|
|
1760
|
+
}, function (e) { U.spinner(false); U.toast(U.t('Couldn’t add it: {why}', { why: U.problem(e) }), 6000); });
|
|
1761
|
+
}
|
|
1762
|
+
});
|
|
1763
|
+
};
|
|
1764
|
+
wrap.appendChild(add);
|
|
1765
|
+
Plugins.repos().forEach(function (r) {
|
|
1766
|
+
var row = U.el('div', 'addon-item focusable cfg-row');
|
|
1767
|
+
row.appendChild(U.el('div', 'a-name', '📦 ' + r.name));
|
|
1768
|
+
row.appendChild(U.el('div', 'a-url', r.url + ' · ' + U.tn(r.plugins.length, '{n} plugin', '{n} plugins') + ' · ' + U.t('OK: refresh or remove')));
|
|
1769
|
+
row.__onselect = function () {
|
|
1770
|
+
pickList(r.name, [['refresh', U.t('↻ Refresh')], ['remove', U.t('Remove')]], null, function (v) {
|
|
1771
|
+
_focusChild = 'pl:' + r.id;
|
|
1772
|
+
if (v === 'refresh') {
|
|
1773
|
+
U.spinner(true, U.t('Reading the repository…'));
|
|
1774
|
+
Plugins.refreshRepo(r.id).then(function (x) {
|
|
1775
|
+
U.spinner(false);
|
|
1776
|
+
U.toast(U.t('“{name}”: {added} new, {changed} changed', { name: r.name, added: x.added, changed: x.changed }) + (x.failed ? ' · ' + U.tn(x.failed, '{n} didn’t come (kept as it was)', '{n} didn’t come (kept as they were)') : ''), 5000);
|
|
1777
|
+
renderSettings();
|
|
1778
|
+
}, function (e) { U.spinner(false); U.toast(U.t('Couldn’t refresh it: {why}', { why: U.problem(e) }), 6000); });
|
|
1779
|
+
} else {
|
|
1780
|
+
confirm(U.t('Remove “{name}” and its plugins?', { name: r.name }), U.t('Remove'), function () { Plugins.removeRepo(r.id); renderSettings(); });
|
|
1781
|
+
}
|
|
1782
|
+
});
|
|
1783
|
+
};
|
|
1784
|
+
if (_focusChild === 'pl:' + r.id) { focus = row; }
|
|
1785
|
+
wrap.appendChild(row);
|
|
1786
|
+
r.plugins.forEach(function (p) {
|
|
1787
|
+
var pr = U.el('div', 'addon-item focusable cfg-row');
|
|
1788
|
+
pr.appendChild(U.el('div', 'a-name', ' ' + (p.on ? '✓ ' : '○ ') + p.name + (p.version ? ' ' + p.version : '')));
|
|
1789
|
+
var kinds = p.types.map(function (t) { return t === 'tv' ? U.t('Series') : U.t('Movies'); }).join(', ');
|
|
1790
|
+
pr.appendChild(U.el('div', 'a-url', ' ' + kinds + ' · ' + (p.on ? U.t('On') : U.t('Off')) + ' · ' + (p.on ? U.t('OK to turn off') : U.t('OK to turn on'))));
|
|
1791
|
+
pr.__onselect = function () { _focusChild = 'pp:' + r.id + '.' + p.id; Plugins.setPlugin(r.id, p.id, !p.on); renderSettings(); };
|
|
1792
|
+
if (_focusChild === 'pp:' + r.id + '.' + p.id) { focus = pr; }
|
|
1793
|
+
wrap.appendChild(pr);
|
|
1794
|
+
});
|
|
1795
|
+
});
|
|
1796
|
+
wrap.appendChild(U.el('div', 'hint', U.t('Repositories come only from addresses you add. Their sources show with your addons’ (From: Nuvio plugins). The plugin format is the Nuvio project’s; StremioK isn’t affiliated with it.')));
|
|
1797
|
+
if (focus) { _focusChild = null; Focus.setScope(scr('settings'), focus); } else { focusSettings(); }
|
|
1798
|
+
}
|
|
1715
1799
|
function settingsMediaServers(wrap) {
|
|
1716
1800
|
wrap.appendChild(U.el('h2', null, U.t('Media servers')));
|
|
1717
1801
|
var have = typeof Jellyfin !== 'undefined';
|
package/js/ytplay.js
CHANGED
|
@@ -82,11 +82,36 @@ var YTPlay = (function () {
|
|
|
82
82
|
// Referer ({ ua, ref }). opts (with force): { fix: false (the sound as it is), cc: the caption
|
|
83
83
|
// channels to add as subtitle tracks }. cancel (a U.cancelToken): the look stopped, the
|
|
84
84
|
// service's downloads with it (another channel, the player closed).
|
|
85
|
+
// A source's own headers (h: U.sanitizeHeaders's) as the service's query, each in the link's
|
|
86
|
+
// own query: User-Agent, Referer, Cookie, Origin, Accept, Accept-Language.
|
|
87
|
+
function headerQuery(h) {
|
|
88
|
+
if (!h) { return ''; }
|
|
89
|
+
return (h.ua ? '&ua=' + encodeURIComponent(h.ua) : '') + (h.ref ? '&ref=' + encodeURIComponent(h.ref) : '') + (h.cookie ? '&cookie=' + encodeURIComponent(h.cookie) : '') +
|
|
90
|
+
(h.origin ? '&origin=' + encodeURIComponent(h.origin) : '') + (h.accept ? '&accept=' + encodeURIComponent(h.accept) : '') + (h.lang ? '&lang=' + encodeURIComponent(h.lang) : '');
|
|
91
|
+
}
|
|
92
|
+
// A file (not HLS) through the service's file relay, with its headers and the player's byte
|
|
93
|
+
// range: { url } the player opens. lan: redirects into the home network allowed
|
|
94
|
+
// (Settings › Content › Addons › Local-network links from internet addons).
|
|
95
|
+
function fileOpen(url, h, lan) {
|
|
96
|
+
if (MODE === 'browser') { return Promise.reject(new Error('no service')); }
|
|
97
|
+
return ensureService().then(entryAuth).then(function (a) {
|
|
98
|
+
return U.getJSON(PROXY + '/live/file?u=' + encodeURIComponent(url) + headerQuery(h) + (lan ? '&lan=1' : '') + a.q, 5000, 65536, null, a.h);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
// Where a Nuvio plugin's Worker sends its requests (js/plugins.js): { url, headers }, the
|
|
102
|
+
// token in the link (a Worker's POST then needs no preflight). lan: home-network requests
|
|
103
|
+
// allowed (Local-network links from internet addons).
|
|
104
|
+
function pluginNet(lan) {
|
|
105
|
+
if (MODE === 'browser') { return Promise.reject(new Error('no service')); }
|
|
106
|
+
return ensureService().then(entryAuth).then(function (a) {
|
|
107
|
+
return { url: PROXY + '/plug/fetch?' + (a.q || '').replace(/^&/, '') + (lan ? '&lan=1' : ''), headers: a.h || {} };
|
|
108
|
+
});
|
|
109
|
+
}
|
|
85
110
|
function liveOpen(url, h, force, opts, cancel) {
|
|
86
111
|
if (MODE === 'browser') { return Promise.reject(new Error('no service')); }
|
|
87
112
|
var cc = opts && opts.cc ? opts.cc.map(function (c) { return c.ch + (c.lang ? '-' + c.lang : ''); }).join(',') : '';
|
|
88
113
|
return ensureService().then(entryAuth).then(function (a) {
|
|
89
|
-
var q = '/live/open?u=' + encodeURIComponent(url) + (h
|
|
114
|
+
var q = '/live/open?u=' + encodeURIComponent(url) + headerQuery(h) + (force ? '&force=1' : '') +
|
|
90
115
|
(force && opts && opts.fix === false ? '&fix=0' : '') + (force && cc ? '&cc=' + encodeURIComponent(cc) : '') + (force && opts && opts.film ? '&film=1' : '') + (force && opts && opts.raw ? '&raw=1' : '');
|
|
91
116
|
return U.getJSON(PROXY + q + a.q, force ? 5000 : 30000, 65536, cancel || null, a.h);
|
|
92
117
|
});
|
|
@@ -96,7 +121,7 @@ var YTPlay = (function () {
|
|
|
96
121
|
function hlsMaster(url, h) {
|
|
97
122
|
if (MODE === 'browser') { return Promise.reject(new Error('no service')); }
|
|
98
123
|
return ensureService().then(entryAuth).then(function (a) {
|
|
99
|
-
var q = '/live/master?u=' + encodeURIComponent(url) + (h
|
|
124
|
+
var q = '/live/master?u=' + encodeURIComponent(url) + headerQuery(h);
|
|
100
125
|
return U.getText(PROXY + q + a.q, 12000, 524288, null, false, a.h);
|
|
101
126
|
});
|
|
102
127
|
}
|
|
@@ -304,6 +329,6 @@ var YTPlay = (function () {
|
|
|
304
329
|
return MODE === 'tizenbrew' ? U.t('TizenBrew module') : MODE === 'wgt' ? U.t('Sideloaded app (.wgt)') : U.t('Browser (development)');
|
|
305
330
|
}
|
|
306
331
|
|
|
307
|
-
return { ensureService: ensureService, resolverUrl: resolverUrl, infoUrl: infoUrl, canPlay: canPlay, liveOpen: liveOpen, hlsMaster: hlsMaster, aiomAddons: aiomAddons, stalkerList: stalkerList, stalkerVod: stalkerVod, drmLicense: drmLicense, stalkerPlayUrl: stalkerPlayUrl, stalkerGenres: stalkerGenres, stalkerLink: stalkerLink, xtvodAsk: xtvodAsk, epgLoad: epgLoad, epgGet: epgGet, epgFiles: epgFiles, epgClear: epgClear, entryOpen: entryOpen, entryGive: entryGive, entrySeen: entrySeen, entryPoll: entryPoll, entryClose: entryClose, subsUrl: subsUrl, audioLang: audioLang, setAudioLang: setAudioLang, installMode: function () { return MODE; },
|
|
332
|
+
return { ensureService: ensureService, resolverUrl: resolverUrl, infoUrl: infoUrl, canPlay: canPlay, liveOpen: liveOpen, fileOpen: fileOpen, pluginNet: pluginNet, hlsMaster: hlsMaster, aiomAddons: aiomAddons, stalkerList: stalkerList, stalkerVod: stalkerVod, drmLicense: drmLicense, stalkerPlayUrl: stalkerPlayUrl, stalkerGenres: stalkerGenres, stalkerLink: stalkerLink, xtvodAsk: xtvodAsk, epgLoad: epgLoad, epgGet: epgGet, epgFiles: epgFiles, epgClear: epgClear, entryOpen: entryOpen, entryGive: entryGive, entrySeen: entrySeen, entryPoll: entryPoll, entryClose: entryClose, subsUrl: subsUrl, audioLang: audioLang, setAudioLang: setAudioLang, installMode: function () { return MODE; },
|
|
308
333
|
installLabel: installLabel, unavailableMessage: unavailableMessage, isRunning: isRunning, port: PORT };
|
|
309
334
|
})();
|
package/package.json
CHANGED
package/service/index.js
CHANGED
|
@@ -1801,19 +1801,20 @@ function handle(req, res) {
|
|
|
1801
1801
|
// The app's own guide POSTs: a browser sends an Origin with every POST (the app's page is
|
|
1802
1802
|
// file://: "null"); let through with the token, or the guide ticket (for an app that can't
|
|
1803
1803
|
// read the token: see /epg/ticket), which no web page has (/epg/ only).
|
|
1804
|
-
if (who === 'origin' && req.method === 'POST' && /^\/(epg\/(load|get|clear)|drm\/license|entry\/give)$/.test(path) && /^(null|file:\/\/)$/.test(String(req.headers.origin || '')) && (hasToken(parts[1]) || hasTicket(parts[1]))) { who = null; } // (and a DRM license's: see drmControl)
|
|
1804
|
+
if (who === 'origin' && req.method === 'POST' && /^\/(epg\/(load|get|clear)|drm\/license|entry\/give|plug\/fetch)$/.test(path) && /^(null|file:\/\/)$/.test(String(req.headers.origin || '')) && (hasToken(parts[1]) || hasTicket(parts[1]))) { who = null; } // (and a DRM license's: see drmControl)
|
|
1805
1805
|
if (who) { send(res, 403, 'text/plain', 'not allowed (' + who + ')'); return; }
|
|
1806
1806
|
if (req.method === 'OPTIONS') { if (isFs) { send(res, 403, 'text/plain', 'not allowed'); return; } res.writeHead(200); res.end(); return; }
|
|
1807
1807
|
var epgPost = req.method === 'POST' && /^\/epg\/(load|get|clear)$/.test(path); // (a guide's channels: in the body, see epgControl)
|
|
1808
1808
|
var drmPost = req.method === 'POST' && path === '/drm/license'; // (a Widevine license request: see drmControl)
|
|
1809
1809
|
var givePost = req.method === 'POST' && path === '/entry/give'; // (a configuration file for the phone: see entryControl)
|
|
1810
|
-
|
|
1810
|
+
var plugPost = req.method === 'POST' && path === '/plug/fetch'; // (a Nuvio plugin's request: see plugControl)
|
|
1811
|
+
if (req.method !== 'GET' && !epgPost && !drmPost && !givePost && !plugPost) { send(res, 405, 'text/plain', 'GET only'); return; } // (before any work)
|
|
1811
1812
|
if (req.url.length > (/^\/epg\//.test(path) ? 32768 : /^\/(fsdl\/add|live\/(open|master)|dav\/(list|walk|sub))$/.test(path) ? 8192 : 2048)) { send(res, 414, 'text/plain', 'request too long'); return; } // (a download's link can be long; a guide's channels, a bitset)
|
|
1812
1813
|
// (StremioK gave up on it — a screen left, the player closed: what it still waits for is
|
|
1813
1814
|
// dropped; 'close' before the response finished means that on every Node)
|
|
1814
1815
|
var leaving = [];
|
|
1815
1816
|
function leaveAll() { var l = leaving; leaving = []; l.forEach(function (f) { try { f(); } catch (e) {} }); }
|
|
1816
|
-
if (!isFs && path !== '/dav/walk' && !/^\/live\/[0-9a-f]{32}\/
|
|
1817
|
+
if (!isFs && path !== '/dav/walk' && !/^\/live\/[0-9a-f]{32}\/[tf]$/.test(path)) { // (a folder's walk, a raw channel's or a file's stream: their own limits)
|
|
1817
1818
|
var deadline = setTimeout(function () { if (!res.headersSent) { send(res, 504, 'text/plain', 'took too long'); } leaveAll(); }, REQ_MS);
|
|
1818
1819
|
res.on('finish', function () { clearTimeout(deadline); });
|
|
1819
1820
|
res.on('close', function () { clearTimeout(deadline); if (!res.finished) { leaveAll(); } });
|
|
@@ -1837,6 +1838,16 @@ function handle(req, res) {
|
|
|
1837
1838
|
req.on('end', function () { if (!over) { epgControl(req, res, path, (parts[1] ? parts[1] + '&' : '') + body); } });
|
|
1838
1839
|
return;
|
|
1839
1840
|
}
|
|
1841
|
+
if (path === '/plug/fetch' && !plugPost) { send(res, 405, 'text/plain', 'POST only'); return; }
|
|
1842
|
+
if (plugPost) {
|
|
1843
|
+
if (!entryAllowed(req, parts[1])) { send(res, 403, 'text/plain', 'not allowed (token)'); req.resume(); return; }
|
|
1844
|
+
if (+(req.headers['content-length'] || 0) > PLUG_ASK_MAX) { send(res, 413, 'text/plain', 'too much asked'); req.resume(); return; }
|
|
1845
|
+
var pbody = '', pover = false;
|
|
1846
|
+
req.setEncoding('utf8');
|
|
1847
|
+
req.on('data', function (c) { if (pover) { return; } pbody += c; if (pbody.length > PLUG_ASK_MAX) { pover = true; send(res, 413, 'text/plain', 'too much asked'); } });
|
|
1848
|
+
req.on('end', function () { if (!pover) { plugControl(res, parts[1], pbody, leaving); } });
|
|
1849
|
+
return;
|
|
1850
|
+
}
|
|
1840
1851
|
if (drmPost) {
|
|
1841
1852
|
if (+(req.headers['content-length'] || 0) > DRM_BODY_MAX) { send(res, 413, 'text/plain', 'too much asked'); req.resume(); return; }
|
|
1842
1853
|
var dbody = '', dover = false;
|
|
@@ -2008,9 +2019,7 @@ function liveGet(u, who, max, cb, part) {
|
|
|
2008
2019
|
var pu;
|
|
2009
2020
|
try { pu = urllib.parse(url); } catch (e) { cb(e); return; }
|
|
2010
2021
|
if ((pu.protocol !== 'http:' && pu.protocol !== 'https:') || !dlHostOk(pu.hostname)) { cb(upError('a link it can\'t follow', 400)); return; }
|
|
2011
|
-
var h =
|
|
2012
|
-
if (who.ref) { h.Referer = who.ref; }
|
|
2013
|
-
if (who.cookie) { h.Cookie = who.cookie; }
|
|
2022
|
+
var h = liveHeaders(who);
|
|
2014
2023
|
if (who.range) { h.Range = who.range; } // (a film's piece that's part of a file: EXT-X-BYTERANGE)
|
|
2015
2024
|
var opts = { hostname: pu.hostname, port: pu.port, path: pu.path, headers: h };
|
|
2016
2025
|
if (pu.protocol === 'https:' && caList().length) { opts.ca = caList(); }
|
|
@@ -2557,9 +2566,7 @@ function liveStream(s, req, res) {
|
|
|
2557
2566
|
var pu;
|
|
2558
2567
|
try { pu = urllib.parse(url); } catch (e) { fail(400, 'bad link'); return; }
|
|
2559
2568
|
if ((pu.protocol !== 'http:' && pu.protocol !== 'https:') || !dlHostOk(pu.hostname)) { fail(400, 'a link it can\'t follow'); return; }
|
|
2560
|
-
var h =
|
|
2561
|
-
if (s.ref) { h.Referer = s.ref; }
|
|
2562
|
-
if (s.cookie) { h.Cookie = s.cookie; }
|
|
2569
|
+
var h = liveHeaders(s);
|
|
2563
2570
|
var opts = { hostname: pu.hostname, port: pu.port, path: pu.path, headers: h };
|
|
2564
2571
|
if (pu.protocol === 'https:' && caList().length) { opts.ca = caList(); }
|
|
2565
2572
|
try {
|
|
@@ -2636,7 +2643,7 @@ function liveSession(u, who, opts) {
|
|
|
2636
2643
|
delete _live[ids[0]];
|
|
2637
2644
|
}
|
|
2638
2645
|
var raw = !!opts.raw && !opts.film;
|
|
2639
|
-
var s = { id: crypto.randomBytes(16).toString('hex'), ua: who.ua, ref: who.ref, cookie: who.cookie || '', links: {}, at: {}, next: 0, last: Date.now(), a: liveAudio(),
|
|
2646
|
+
var s = { id: crypto.randomBytes(16).toString('hex'), ua: who.ua, ref: who.ref, cookie: who.cookie || '', origin: who.origin || '', accept: who.accept || '', lang: who.lang || '', links: {}, at: {}, next: 0, last: Date.now(), a: liveAudio(),
|
|
2640
2647
|
fix: opts.fix !== false && !opts.film, cc: opts.cc && opts.cc.length && !opts.film && !raw ? opts.cc : null, film: !!opts.film, c: ccState(), got: Object.create(null),
|
|
2641
2648
|
raw: raw ? u : null };
|
|
2642
2649
|
_live[s.id] = s;
|
|
@@ -2685,8 +2692,198 @@ function liveProbe(u, who, cb, leaving) {
|
|
|
2685
2692
|
}
|
|
2686
2693
|
list(u);
|
|
2687
2694
|
}
|
|
2695
|
+
// ---- Nuvio plugins' requests (/plug/fetch) ----
|
|
2696
|
+
// A plugin (js/plugins.js runs it, in QuickJS inside a Web Worker) reaches the network only
|
|
2697
|
+
// through here: POST, the token in the link (a page's Worker can't send the header without a
|
|
2698
|
+
// preflight), the ask in the body as JSON { url, method, headers, body, redirect }. http(s) only;
|
|
2699
|
+
// never the TV itself; the home network only when the link says lan=1 (Local-network links from
|
|
2700
|
+
// internet addons: Allowed), checked on the name, on the address it resolves to, and at every
|
|
2701
|
+
// redirect. Nothing of StremioK's is added (no cookies, keys or its headers); the plugin's own
|
|
2702
|
+
// headers go as they are, but for those that only the connection decides. The answer: JSON
|
|
2703
|
+
// { status, statusText, url, redirected, headers, body } (text, up to 1 MB after unpacking).
|
|
2704
|
+
var PLUG_ASK_MAX = 300 * 1024, PLUG_BODY_MAX = 1048576, PLUG_MS = 20000, PLUG_ACTIVE = 6, PLUG_PER_MINUTE = 240, PLUG_HOPS = 5;
|
|
2705
|
+
var PLUG_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'];
|
|
2706
|
+
var PLUG_DROP = /^(host|content-length|connection|keep-alive|transfer-encoding|te|trailer|upgrade|proxy-.*|x-stremiok|accept-encoding)$/i;
|
|
2707
|
+
var _plugActive = 0, _plugRecent = [];
|
|
2708
|
+
function plugHeaders(h) {
|
|
2709
|
+
var out = {}, n = 0, size = 0;
|
|
2710
|
+
if (!h || typeof h !== 'object') { return out; }
|
|
2711
|
+
Object.keys(h).forEach(function (k) {
|
|
2712
|
+
var v = String(h[k] == null ? '' : h[k]);
|
|
2713
|
+
if (n >= 40 || !/^[!#$%&'*+.^_\x60|~0-9A-Za-z-]{1,64}$/.test(k) || PLUG_DROP.test(k) || !/^[\x20-\x7e\t]*$/.test(v) || (size += k.length + v.length) > 16384) { return; }
|
|
2714
|
+
out[k] = v; n++;
|
|
2715
|
+
});
|
|
2716
|
+
return out;
|
|
2717
|
+
}
|
|
2718
|
+
function plugControl(res, query, text, leaving) {
|
|
2719
|
+
var ask = null;
|
|
2720
|
+
try { ask = JSON.parse(text); } catch (e) { ask = null; }
|
|
2721
|
+
if (!ask || typeof ask !== 'object') { send(res, 400, 'text/plain', 'failed: not a request'); return; }
|
|
2722
|
+
var url = String(ask.url || ''), method = String(ask.method || 'GET').toUpperCase(), lan = /(?:^|&)lan=1(?:&|$)/.test(query || '');
|
|
2723
|
+
if (!/^https?:\/\/[^\s]+$/i.test(url) || url.length > 4096) { send(res, 400, 'text/plain', 'failed: only http(s) links'); return; }
|
|
2724
|
+
if (PLUG_METHODS.indexOf(method) === -1) { send(res, 400, 'text/plain', 'failed: method ' + method); return; }
|
|
2725
|
+
var body = ask.body == null ? null : String(ask.body);
|
|
2726
|
+
var now = Date.now();
|
|
2727
|
+
_plugRecent = _plugRecent.filter(function (t) { return now - t < 60000; });
|
|
2728
|
+
if (_plugRecent.length >= PLUG_PER_MINUTE) { send(res, 429, 'text/plain', 'failed: too many requests, wait a minute'); return; }
|
|
2729
|
+
if (_plugActive >= PLUG_ACTIVE) { send(res, 503, 'text/plain', 'failed: busy'); return; }
|
|
2730
|
+
_plugActive++; _plugRecent.push(now);
|
|
2731
|
+
var r = null, over = false, hops = 0, headers = plugHeaders(ask.headers);
|
|
2732
|
+
if (!Object.keys(headers).some(function (k) { return /^user-agent$/i.test(k); })) { headers['User-Agent'] = TV_UA; }
|
|
2733
|
+
headers['Accept-Encoding'] = 'gzip, deflate';
|
|
2734
|
+
function done(code, out) {
|
|
2735
|
+
if (over) { return; }
|
|
2736
|
+
over = true; _plugActive--; clearTimeout(timer);
|
|
2737
|
+
try { if (r) { r.abort(); } } catch (e) {}
|
|
2738
|
+
if (code === 200) { send(res, 200, 'application/json', JSON.stringify(out)); } else { send(res, code, 'text/plain', 'failed: ' + out); }
|
|
2739
|
+
}
|
|
2740
|
+
leaving.push(function () { done(499, 'nobody waiting'); });
|
|
2741
|
+
var timer = setTimeout(function () { done(504, 'timed out'); }, PLUG_MS);
|
|
2742
|
+
function go(u) {
|
|
2743
|
+
var pu;
|
|
2744
|
+
try { pu = urllib.parse(u); } catch (e) { done(400, 'bad link'); return; }
|
|
2745
|
+
if ((pu.protocol !== 'http:' && pu.protocol !== 'https:') || !dlHostOk(pu.hostname)) { done(403, 'not a link a plugin may follow'); return; }
|
|
2746
|
+
if (!lan && isLanName(pu.hostname)) { done(403, 'a link into your home network (Local-network links from internet addons: Blocked)'); return; }
|
|
2747
|
+
var opts = { hostname: pu.hostname, port: pu.port, path: pu.path, method: method, headers: headers };
|
|
2748
|
+
if (pu.protocol === 'https:' && caList().length) { opts.ca = caList(); }
|
|
2749
|
+
try {
|
|
2750
|
+
r = (pu.protocol === 'https:' ? https : http).request(opts, function (resp) {
|
|
2751
|
+
if (over) { resp.resume(); return; }
|
|
2752
|
+
var sc = resp.statusCode, loc = resp.headers.location;
|
|
2753
|
+
if (ask.redirect !== 'manual' && sc >= 300 && sc < 400 && loc && sc !== 304) {
|
|
2754
|
+
resp.resume();
|
|
2755
|
+
if (++hops > PLUG_HOPS) { done(502, 'too many redirects'); return; }
|
|
2756
|
+
if (sc === 303 || ((sc === 301 || sc === 302) && method === 'POST')) { method = 'GET'; body = null; }
|
|
2757
|
+
go(urllib.resolve(u, loc));
|
|
2758
|
+
return;
|
|
2759
|
+
}
|
|
2760
|
+
var parts = [], size = 0;
|
|
2761
|
+
resp.on('data', function (c) {
|
|
2762
|
+
if (over) { return; }
|
|
2763
|
+
size += c.length;
|
|
2764
|
+
if (size > PLUG_BODY_MAX) { done(502, 'answer too large (over 1 MB)'); return; }
|
|
2765
|
+
parts.push(c);
|
|
2766
|
+
});
|
|
2767
|
+
resp.on('end', function () {
|
|
2768
|
+
if (over) { return; }
|
|
2769
|
+
decompress(Buffer.concat(parts), resp.headers['content-encoding'], function (err, buf) {
|
|
2770
|
+
if (err) { done(502, 'couldn\'t unpack the answer'); return; }
|
|
2771
|
+
if (buf.length > PLUG_BODY_MAX) { done(502, 'answer too large (over 1 MB)'); return; }
|
|
2772
|
+
var hs = {};
|
|
2773
|
+
Object.keys(resp.headers).forEach(function (k) { if (!/^(content-encoding|content-length|transfer-encoding|connection)$/i.test(k)) { var v = resp.headers[k]; hs[k] = (Array.isArray(v) ? v.join(', ') : String(v)).slice(0, 8192); } });
|
|
2774
|
+
done(200, { status: sc, statusText: resp.statusMessage || '', url: u, redirected: hops > 0, headers: hs, body: buf.toString('utf8') });
|
|
2775
|
+
});
|
|
2776
|
+
});
|
|
2777
|
+
resp.on('error', function () { done(502, 'the site stopped sending'); });
|
|
2778
|
+
});
|
|
2779
|
+
guardSelf(r, function () { done(403, 'not a link a plugin may follow'); });
|
|
2780
|
+
if (!lan) { // (the address a name leads to, before connecting: not into the home network)
|
|
2781
|
+
r.on('socket', function (sock) {
|
|
2782
|
+
sock.on('lookup', function (err, addr) { if (!err && isLanName(addr)) { done(403, 'a link into your home network (Local-network links from internet addons: Blocked)'); } });
|
|
2783
|
+
sock.on('connect', function () { if (isLanName(sock.remoteAddress)) { done(403, 'a link into your home network (Local-network links from internet addons: Blocked)'); } });
|
|
2784
|
+
});
|
|
2785
|
+
}
|
|
2786
|
+
r.on('error', function (e) { done(502, (e && e.message) || 'network error'); });
|
|
2787
|
+
if (body !== null && method !== 'GET' && method !== 'HEAD') { r.write(body); }
|
|
2788
|
+
r.end();
|
|
2789
|
+
} catch (e) { done(400, 'bad request'); }
|
|
2790
|
+
}
|
|
2791
|
+
go(url);
|
|
2792
|
+
}
|
|
2793
|
+
|
|
2794
|
+
// ---- A file through the relay (/live/file, then /live/<id>/f) ----
|
|
2795
|
+
// A video file (not HLS) that needs headers the TV's player can't send (Origin, Accept,
|
|
2796
|
+
// Accept-Language; under TizenBrew the page's player sends none), or one asked for (hold OK ›
|
|
2797
|
+
// Play through StremioK's service): each of the player's requests passed on with the file's
|
|
2798
|
+
// headers and its byte range (seeking works), the answer streamed back as it comes, nothing kept.
|
|
2799
|
+
// Shares the relays' count (LIVE_MAX); dropped after LIVE_FILM_IDLE_MS unused. Redirects: the
|
|
2800
|
+
// downloads' host rule (never the TV itself), and into the home network only when allowed (lan).
|
|
2801
|
+
function liveFileSession(u, who, lan) {
|
|
2802
|
+
var ids = Object.keys(_live);
|
|
2803
|
+
if (ids.length >= LIVE_MAX) {
|
|
2804
|
+
ids.sort(function (x, y) { return _live[x].last - _live[y].last; });
|
|
2805
|
+
if (_live[ids[0]].stop) { _live[ids[0]].stop(); }
|
|
2806
|
+
delete _live[ids[0]];
|
|
2807
|
+
}
|
|
2808
|
+
var s = { id: crypto.randomBytes(16).toString('hex'), file: u, ua: who.ua, ref: who.ref, cookie: who.cookie || '', origin: who.origin || '', accept: who.accept || '', lang: who.lang || '',
|
|
2809
|
+
lan: !!lan, film: true, links: {}, last: Date.now() };
|
|
2810
|
+
_live[s.id] = s;
|
|
2811
|
+
return s;
|
|
2812
|
+
}
|
|
2813
|
+
// A host in the home network (by its name or address): a private, link-local or carrier-grade
|
|
2814
|
+
// address, a name without a dot, or a .local / .lan / .home.arpa / .internal one.
|
|
2815
|
+
function isLanName(host) {
|
|
2816
|
+
var h = String(host || '').toLowerCase().replace(/^\[|\]$/g, '').replace(/%.*$/, '').replace(/\.$/, '');
|
|
2817
|
+
if (!h) { return false; }
|
|
2818
|
+
if (isSelfAddr(h)) { return true; }
|
|
2819
|
+
if (h.indexOf(':') !== -1) { var w = ipv6Words(h); return !!w && ((w[0] & 0xfe00) === 0xfc00 || (w[0] & 0xffc0) === 0xfe80); }
|
|
2820
|
+
var n = ipv4Int(h);
|
|
2821
|
+
if (n >= 0) {
|
|
2822
|
+
var a = Math.floor(n / 16777216), b = Math.floor(n / 65536) % 256;
|
|
2823
|
+
return a === 10 || (a === 172 && b >= 16 && b <= 31) || (a === 192 && b === 168) || (a === 169 && b === 254) || (a === 100 && b >= 64 && b <= 127);
|
|
2824
|
+
}
|
|
2825
|
+
return h.indexOf('.') === -1 || /\.(local|lan|home\.arpa|internal|home)$/.test(h);
|
|
2826
|
+
}
|
|
2827
|
+
// May a redirect go from the file's own host to this one? Not into the home network from a host
|
|
2828
|
+
// outside it, unless Local-network links from internet addons allows it.
|
|
2829
|
+
function fileHopOk(firstHost, nextHost, lan) { return lan || isLanName(firstHost) || !isLanName(nextHost); }
|
|
2830
|
+
function liveFile(s, req, res) {
|
|
2831
|
+
var r = null, gone = false, hops = 0, firstHost = '';
|
|
2832
|
+
var range = /^bytes=\d*-\d*(,\s*\d*-\d*)*$/.test(String(req.headers.range || '')) ? String(req.headers.range) : '';
|
|
2833
|
+
function stop() { gone = true; try { if (r) { r.abort(); } } catch (e) {} }
|
|
2834
|
+
res.on('close', stop);
|
|
2835
|
+
function fail(code, why) { if (gone) { return; } if (!res.headersSent) { send(res, code, 'text/plain', 'failed: ' + why); } else { try { res.end(); } catch (e) {} } stop(); }
|
|
2836
|
+
var timer = setTimeout(function () { if (!res.headersSent) { fail(504, 'timed out'); } }, LIVE_MS);
|
|
2837
|
+
function get(url) {
|
|
2838
|
+
var pu;
|
|
2839
|
+
try { pu = urllib.parse(url); } catch (e) { fail(400, 'bad link'); return; }
|
|
2840
|
+
if ((pu.protocol !== 'http:' && pu.protocol !== 'https:') || !dlHostOk(pu.hostname)) { fail(400, 'a link it can\'t follow'); return; }
|
|
2841
|
+
if (!hops) { firstHost = pu.hostname; }
|
|
2842
|
+
else if (!fileHopOk(firstHost, pu.hostname, s.lan)) { fail(403, 'a link into your home network'); return; }
|
|
2843
|
+
var h = liveHeaders(s);
|
|
2844
|
+
if (range) { h.Range = range; }
|
|
2845
|
+
var opts = { hostname: pu.hostname, port: pu.port, path: pu.path, headers: h };
|
|
2846
|
+
if (pu.protocol === 'https:' && caList().length) { opts.ca = caList(); }
|
|
2847
|
+
try {
|
|
2848
|
+
r = (pu.protocol === 'https:' ? https : http).get(opts, function (resp) {
|
|
2849
|
+
if (gone) { resp.resume(); return; }
|
|
2850
|
+
var sc = resp.statusCode;
|
|
2851
|
+
if (sc >= 300 && sc < 400 && resp.headers.location && hops < 5) { resp.resume(); hops++; get(urllib.resolve(url, resp.headers.location)); return; }
|
|
2852
|
+
if (sc !== 200 && sc !== 206) { resp.resume(); clearTimeout(timer); fail(sc >= 400 && sc < 600 ? sc : 502, 'HTTP ' + sc); return; }
|
|
2853
|
+
clearTimeout(timer);
|
|
2854
|
+
var out = { 'Content-Type': String(resp.headers['content-type'] || 'application/octet-stream'), 'Cache-Control': 'no-store', 'X-Content-Type-Options': 'nosniff', 'Accept-Ranges': 'bytes' };
|
|
2855
|
+
if (resp.headers['content-length']) { out['Content-Length'] = resp.headers['content-length']; }
|
|
2856
|
+
if (resp.headers['content-range']) { out['Content-Range'] = resp.headers['content-range']; }
|
|
2857
|
+
res.writeHead(sc, out);
|
|
2858
|
+
resp.on('data', function (c) {
|
|
2859
|
+
if (gone) { return; }
|
|
2860
|
+
s.last = Date.now();
|
|
2861
|
+
if (!res.write(c)) { resp.pause(); res.once('drain', function () { if (!gone) { resp.resume(); } }); }
|
|
2862
|
+
});
|
|
2863
|
+
resp.on('end', function () { if (!gone) { try { res.end(); } catch (e) {} } });
|
|
2864
|
+
resp.on('error', function () { fail(502, 'the host stopped sending'); });
|
|
2865
|
+
});
|
|
2866
|
+
guardSelf(r, function () { fail(400, 'a link it can\'t follow'); });
|
|
2867
|
+
r.on('error', function (e) { clearTimeout(timer); fail(502, (e && e.message) || 'network error'); });
|
|
2868
|
+
} catch (e) { clearTimeout(timer); fail(400, 'bad link'); }
|
|
2869
|
+
}
|
|
2870
|
+
get(s.file);
|
|
2871
|
+
}
|
|
2688
2872
|
function liveHeader(v, max) { v = String(v || ''); return v.length <= (max || 300) && /^[\x20-\x7e]+$/.test(v) ? v : ''; }
|
|
2689
|
-
function liveWho(q) {
|
|
2873
|
+
function liveWho(q) { // (a stream's own headers, as the app sends them)
|
|
2874
|
+
var origin = liveHeader(q.origin, 2048);
|
|
2875
|
+
return { ua: liveHeader(q.ua), ref: liveHeader(q.ref), cookie: liveHeader(q.cookie, 4096), origin: /^https?:\/\/[^\s\/?#]+$/i.test(origin) ? origin : '', accept: liveHeader(q.accept, 512), lang: liveHeader(q.lang, 512) };
|
|
2876
|
+
}
|
|
2877
|
+
// The request headers a relay sends: the stream's own (the TV's User-Agent when it has none).
|
|
2878
|
+
function liveHeaders(who) {
|
|
2879
|
+
var h = { 'User-Agent': who.ua || TV_UA };
|
|
2880
|
+
if (who.ref) { h.Referer = who.ref; }
|
|
2881
|
+
if (who.cookie) { h.Cookie = who.cookie; }
|
|
2882
|
+
if (who.origin) { h.Origin = who.origin; }
|
|
2883
|
+
if (who.accept) { h.Accept = who.accept; }
|
|
2884
|
+
if (who.lang) { h['Accept-Language'] = who.lang; }
|
|
2885
|
+
return h;
|
|
2886
|
+
}
|
|
2690
2887
|
function liveControl(req, res, path, query, leaving) {
|
|
2691
2888
|
livePurge();
|
|
2692
2889
|
var q = {};
|
|
@@ -2721,6 +2918,22 @@ function liveControl(req, res, path, query, leaving) {
|
|
|
2721
2918
|
}, leaving);
|
|
2722
2919
|
return;
|
|
2723
2920
|
}
|
|
2921
|
+
if (path === '/live/file') { // a file through the relay (see liveFile)
|
|
2922
|
+
if (!entryAllowed(req, query)) { send(res, 403, 'text/plain', 'not allowed (token)'); return; }
|
|
2923
|
+
var fu = q.u || '';
|
|
2924
|
+
if (!/^https?:\/\/[^\s]+$/i.test(fu) || fu.length > 2000) { send(res, 400, 'text/plain', 'bad link'); return; }
|
|
2925
|
+
var fsn = liveFileSession(fu, liveWho(q), q.lan === '1');
|
|
2926
|
+
send(res, 200, 'application/json', JSON.stringify({ url: liveBase(fsn) + 'f' }));
|
|
2927
|
+
return;
|
|
2928
|
+
}
|
|
2929
|
+
var rf = /^\/live\/([0-9a-f]{32})\/f$/.exec(path);
|
|
2930
|
+
if (rf) {
|
|
2931
|
+
var fs0 = _live[rf[1]];
|
|
2932
|
+
if (!fs0 || !fs0.file) { send(res, 404, 'text/plain', 'not found'); return; }
|
|
2933
|
+
fs0.last = Date.now();
|
|
2934
|
+
liveFile(fs0, req, res);
|
|
2935
|
+
return;
|
|
2936
|
+
}
|
|
2724
2937
|
// (m: a playlist; p: the top one under its made-up quality list; s: a segment; c: a caption
|
|
2725
2938
|
// track's playlist; v: a segment's captions)
|
|
2726
2939
|
var rt = /^\/live\/([0-9a-f]{32})\/t$/.exec(path);
|
|
@@ -2739,7 +2952,7 @@ function liveControl(req, res, path, query, leaving) {
|
|
|
2739
2952
|
try { return ccSegment(s.c, body, link.seq); } catch (e) { log('live captions: ' + (e && e.message)); s.c = ccState(); return null; }
|
|
2740
2953
|
}
|
|
2741
2954
|
if (kind === 'v' && s.c.segs[link.seq]) { send(res, 200, 'text/vtt; charset=utf-8', ccVtt(s.c.segs[link.seq], link.ch)); return; }
|
|
2742
|
-
var who = link.range ? { ua: s.ua, ref: s.ref, cookie: s.cookie, range: link.range } : s; // (a byte range: asked as one)
|
|
2955
|
+
var who = link.range ? { ua: s.ua, ref: s.ref, cookie: s.cookie, origin: s.origin, accept: s.accept, lang: s.lang, range: link.range } : s; // (a byte range: asked as one)
|
|
2743
2956
|
leaving.push((seg && s.cc ? liveShared : liveGet)(link.url, who, seg ? LIVE_SEG_MAX : LIVE_LIST_MAX, function (err, body, at) {
|
|
2744
2957
|
if (err) { send(res, err.status || 502, 'text/plain', 'failed: ' + (err.message || 'unknown')); return; }
|
|
2745
2958
|
if (kind === 'v') { var cs = captions(body); send(res, 200, 'text/vtt; charset=utf-8', cs ? ccVtt(cs, link.ch) : 'WEBVTT\n'); return; }
|
|
@@ -4256,7 +4469,8 @@ var CONFIG_MAX = 262144, GIVE_MAX = 262144;
|
|
|
4256
4469
|
var ENTRY_OPEN_MAX = 2, ENTRY_OPENS = 12, ENTRY_CONNECTIONS = 8, ENTRY_VISIT_MS = 20000, ENTRY_QUIET_MS = 10000;
|
|
4257
4470
|
var ENTRY_TITLES = { link: 'Play a link on StremioK', addon: 'Add an addon to StremioK', playlist: 'Add an IPTV playlist to StremioK', config: 'Import a configuration file into StremioK', give: 'Your StremioK configuration',
|
|
4258
4471
|
search: 'Search on StremioK', youtube: 'Add a YouTube catalog to StremioK', aiom: 'Your AIOManager address for StremioK', aiomkey: 'Your AIOManager API key for StremioK',
|
|
4259
|
-
server: 'Your streaming server’s address for StremioK', mac: 'Your Stalker portal’s MAC address for StremioK', webdav: 'Your network folder’s address for StremioK'
|
|
4472
|
+
server: 'Your streaming server’s address for StremioK', mac: 'Your Stalker portal’s MAC address for StremioK', webdav: 'Your network folder’s address for StremioK',
|
|
4473
|
+
jellyfin: 'Your media server’s address for StremioK', plugins: 'Add a Nuvio plugin repository to StremioK' };
|
|
4260
4474
|
var ENTRY_TEXT = { search: 'Words to search for', youtube: 'A channel, a playlist link, or words to search YouTube for', aiomkey: 'Your account API key', mac: 'Its MAC address (00:1A:79:…)' }; // (plain text, not a link)
|
|
4261
4475
|
var _entries = Object.create(null), _entryServer = null, _entrySockets = [], _entryOpened = [];
|
|
4262
4476
|
function lanAddress() {
|
package/tizenbrew.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// from there: it opens this version's own copy (npm/stremiok@<version>/index.html), whose
|
|
11
11
|
// files all come from that address. build.sh stamps the ?v= below.
|
|
12
12
|
(function () {
|
|
13
|
-
var v = '?v=2.3.
|
|
13
|
+
var v = '?v=2.3.6'.slice(3), l = location, rest = (l.search || '') + (l.hash || '');
|
|
14
14
|
var m = /^(\/module\/npm%2F[^\/%@]+)\//i.exec(l.pathname || '');
|
|
15
15
|
l.replace(m ? m[1] + '%40' + v + '/index.html' + rest : 'index.html' + rest);
|
|
16
16
|
})();
|