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/xtvod.js
CHANGED
|
@@ -256,7 +256,7 @@ var XtVod = (function () {
|
|
|
256
256
|
var pic = link(i.cover_big || i.movie_image);
|
|
257
257
|
if (pic) { m.poster = pic; }
|
|
258
258
|
var secs = +i.duration_secs || 0;
|
|
259
|
-
if (secs > 0) { m.runtime = Math.round(secs / 60)
|
|
259
|
+
if (secs > 0) { m.runtime = U.t('{n} min', { n: Math.round(secs / 60) }); }
|
|
260
260
|
var y = yearOf(i.releasedate || i.release_date);
|
|
261
261
|
if (y) { m.releaseInfo = y; m.year = y; }
|
|
262
262
|
return m;
|
|
@@ -271,7 +271,7 @@ var XtVod = (function () {
|
|
|
271
271
|
var y = yearOf(i.releaseDate || i.release_date);
|
|
272
272
|
if (y) { m.releaseInfo = y; m.year = y; }
|
|
273
273
|
m.videos = episodes(r).map(function (e) {
|
|
274
|
-
var ei = e.info || {}, v = { id: showId + ':' + e.season + ':' + e.episode, season: e.season, episode: e.episode, title: ('' + (e.title || '')).trim() || 'Episode '
|
|
274
|
+
var ei = e.info || {}, v = { id: showId + ':' + e.season + ':' + e.episode, season: e.season, episode: e.episode, title: ('' + (e.title || '')).trim() || U.t('Episode {n}', { n: e.episode }) };
|
|
275
275
|
if (ei.plot) { v.overview = ('' + ei.plot).slice(0, 1000); }
|
|
276
276
|
if (link(ei.movie_image)) { v.thumbnail = link(ei.movie_image); }
|
|
277
277
|
var rel = Date.parse(ei.releasedate || ei.air_date || '');
|
package/js/youtube.js
CHANGED
|
@@ -12,17 +12,17 @@ var YouTube = (function () {
|
|
|
12
12
|
var MAX_CATALOGS = 40;
|
|
13
13
|
var KINDS = ['auto', 'videos', 'channels', 'live'];
|
|
14
14
|
var SORTS = ['relevance', 'date', 'views', 'rating'];
|
|
15
|
-
var KIND_NAMES = { auto: 'Auto (what the source is)', videos: 'Videos', channels: 'Channels', live: 'Live now' };
|
|
16
|
-
var SORT_NAMES = { relevance: 'Relevance', date: 'Upload date', views: 'View count', rating: 'Rating' };
|
|
15
|
+
var KIND_NAMES = { auto: U.t('Auto (what the source is)'), videos: U.t('Videos'), channels: U.t('Channels'), live: U.t('Live now') };
|
|
16
|
+
var SORT_NAMES = { relevance: U.t('Relevance'), date: U.t('Upload date'), views: U.t('View count'), rating: U.t('Rating') };
|
|
17
17
|
// SponsorBlock's sections, what each is called, and what's done with it by default:
|
|
18
18
|
// skip (jump over it), ask (a "Skip …" button), show (on the progress bar only), off.
|
|
19
19
|
// The highlight is a button on the UP bar; a whole-video label, a note when it starts.
|
|
20
20
|
var SB_CATS = ['sponsor', 'selfpromo', 'interaction', 'intro', 'outro', 'preview', 'music_offtopic', 'filler', 'poi_highlight', 'exclusive_access'];
|
|
21
|
-
var SB_NAMES = { sponsor: 'Sponsor', selfpromo: 'Self-promotion', interaction: 'Interaction reminder', intro: 'Intro', outro: 'Endcards / credits',
|
|
22
|
-
preview: 'Preview / recap', music_offtopic: 'Non-music section', filler: 'Filler / tangent', poi_highlight: 'Highlight', exclusive_access: 'Exclusive access' };
|
|
21
|
+
var SB_NAMES = { sponsor: U.t('Sponsor'), selfpromo: U.t('Self-promotion'), interaction: U.t('Interaction reminder'), intro: U.t('Intro'), outro: U.t('Endcards / credits'),
|
|
22
|
+
preview: U.t('Preview / recap'), music_offtopic: U.t('Non-music section'), filler: U.t('Filler / tangent'), poi_highlight: U.t('Highlight'), exclusive_access: U.t('Exclusive access') };
|
|
23
23
|
var SB_DEFAULTS = { sponsor: 'skip', selfpromo: 'ask', interaction: 'ask', intro: 'show', outro: 'show', preview: 'show', music_offtopic: 'show', filler: 'show',
|
|
24
24
|
poi_highlight: 'show', exclusive_access: 'show' };
|
|
25
|
-
var SB_MODE_NAMES = { skip: 'Skip', ask: 'Ask (a Skip button)', show: 'Show on the bar', off: 'Off' };
|
|
25
|
+
var SB_MODE_NAMES = { skip: U.t('Skip'), ask: U.t('Ask (a Skip button)'), show: U.t('Show on the bar'), off: U.t('Off') };
|
|
26
26
|
function sbModesFor(cat) { return (cat === 'poi_highlight' || cat === 'exclusive_access') ? ['show', 'off'] : ['skip', 'ask', 'show', 'off']; }
|
|
27
27
|
|
|
28
28
|
// ----- your catalogs -----
|
|
@@ -152,9 +152,9 @@ var YouTube = (function () {
|
|
|
152
152
|
extra: search ? [{ name: 'search', isRequired: true }, { name: 'skip' }] : [{ name: 'skip' }] });
|
|
153
153
|
});
|
|
154
154
|
if (searchOn()) {
|
|
155
|
-
out.push({ type: 'YouTube', id: 'ytk_search_videos', name: 'Videos', extra: [{ name: 'search', isRequired: true }, { name: 'skip' }] });
|
|
156
|
-
out.push({ type: 'YouTube', id: 'ytk_search_channels', name: 'Channels', extra: [{ name: 'search', isRequired: true }, { name: 'skip' }] });
|
|
157
|
-
out.push({ type: 'YouTube', id: 'ytk_search_live', name: 'Live now', extra: [{ name: 'search', isRequired: true }, { name: 'skip' }] });
|
|
155
|
+
out.push({ type: 'YouTube', id: 'ytk_search_videos', name: U.t('Videos'), extra: [{ name: 'search', isRequired: true }, { name: 'skip' }] });
|
|
156
|
+
out.push({ type: 'YouTube', id: 'ytk_search_channels', name: U.t('Channels'), extra: [{ name: 'search', isRequired: true }, { name: 'skip' }] });
|
|
157
|
+
out.push({ type: 'YouTube', id: 'ytk_search_live', name: U.t('Live now'), extra: [{ name: 'search', isRequired: true }, { name: 'skip' }] });
|
|
158
158
|
}
|
|
159
159
|
return out;
|
|
160
160
|
}
|
|
@@ -178,7 +178,7 @@ var YouTube = (function () {
|
|
|
178
178
|
return ready.then(function () { return U.getJSON(proxy() + '/ytlist?' + q + (wantBrand() ? '&brand=1' : '') + (originalTitles() ? '&orig=1' : ''), 25000, 4 * 1024 * 1024); });
|
|
179
179
|
}
|
|
180
180
|
// A video's title and picture, with DeArrow's (when it has them and they're turned on).
|
|
181
|
-
function titleOf(it) { var b = it.brand; return (b && typeof b.title === 'string' && b.title && dearrow().titles) ? b.title : (it.title || 'YouTube video'); }
|
|
181
|
+
function titleOf(it) { var b = it.brand; return (b && typeof b.title === 'string' && b.title && dearrow().titles) ? b.title : (it.title || U.t('YouTube video')); }
|
|
182
182
|
function thumbOf(it) { var b = it.brand; return (b && typeof b.thumbAt === 'number' && dearrow().thumbs) ? dearrowThumb(it.id, b.thumbAt) : it.thumb; }
|
|
183
183
|
|
|
184
184
|
// What a list item becomes on a card. Video items are kept (by id) for their pages.
|
|
@@ -187,10 +187,10 @@ var YouTube = (function () {
|
|
|
187
187
|
var desc = [it.by, it.length, it.views, it.ago].filter(Boolean).join(' · ');
|
|
188
188
|
if (it.kind === 'video') {
|
|
189
189
|
var name = titleOf(it), poster = thumbOf(it);
|
|
190
|
-
if (name !== it.title && it.title) { desc = 'On YouTube: “'
|
|
191
|
-
if (it.live) { desc = '● LIVE now' + (desc ? ' · ' + desc : ''); }
|
|
190
|
+
if (name !== it.title && it.title) { desc = U.t('On YouTube: “{title}”', { title: it.title }) + (desc ? ' · ' + desc : ''); }
|
|
191
|
+
if (it.live) { desc = '● ' + U.t('LIVE now') + (desc ? ' · ' + desc : ''); }
|
|
192
192
|
var m = { id: 'ytk:v:' + it.id, type: type, name: name, poster: it.thumb, posterShape: 'landscape',
|
|
193
|
-
background: 'https://i.ytimg.com/vi/' + it.id + '/hqdefault.jpg', description: desc, releaseInfo: it.live ? '● LIVE' : (it.ago || '') };
|
|
193
|
+
background: 'https://i.ytimg.com/vi/' + it.id + '/hqdefault.jpg', description: desc, releaseInfo: it.live ? '● ' + U.t('LIVE') : (it.ago || '') };
|
|
194
194
|
if (poster !== it.thumb) { m._cardImage = poster; m._posterAlt = it.thumb; } // (DeArrow's on the card; not made yet: YouTube's)
|
|
195
195
|
_known.set(m.id, { meta: m, item: it });
|
|
196
196
|
return m;
|
|
@@ -255,10 +255,10 @@ var YouTube = (function () {
|
|
|
255
255
|
: Promise.resolve(null));
|
|
256
256
|
var brand = (base || !dearrow().titles) ? Promise.resolve(null) : videoExtras(m[2]).then(function (x) { return x && x.brand; });
|
|
257
257
|
return Promise.all([details, brand]).then(function (both) {
|
|
258
|
-
var d = both[0], b = both[1], yt = (d && d.title) || 'YouTube video', better = b && b.title;
|
|
258
|
+
var d = both[0], b = both[1], yt = (d && d.title) || U.t('YouTube video'), better = b && b.title;
|
|
259
259
|
var out = base || { id: id, type: 'YouTube', name: better || yt, poster: 'https://i.ytimg.com/vi/' + m[2] + '/mqdefault.jpg',
|
|
260
260
|
posterShape: 'landscape', background: 'https://i.ytimg.com/vi/' + m[2] + '/hqdefault.jpg',
|
|
261
|
-
description: (better && d && d.title ? 'On YouTube: “'
|
|
261
|
+
description: (better && d && d.title ? U.t('On YouTube: “{title}”', { title: d.title }) + ' · ' : '') + (d ? [d.by, d.description].filter(Boolean).join(' · ') : '') };
|
|
262
262
|
out.videos = [{ id: id, title: out.name, streams: [{ name: 'YouTube', ytId: m[2] }] }];
|
|
263
263
|
return out;
|
|
264
264
|
});
|
|
@@ -275,8 +275,8 @@ var YouTube = (function () {
|
|
|
275
275
|
description: head.description || '',
|
|
276
276
|
videos: live.map(function (v) {
|
|
277
277
|
var vm = toMeta(v, 'YouTube');
|
|
278
|
-
return { id: vm.id, title: '● LIVE ' + vm.name, season: 1, episode: 0, released: now, thumbnail: v.thumb, live: true,
|
|
279
|
-
overview: ['Live now', v.views].filter(Boolean).join(' · ') };
|
|
278
|
+
return { id: vm.id, title: '● ' + U.t('LIVE') + ' ' + vm.name, season: 1, episode: 0, released: now, thumbnail: v.thumb, live: true,
|
|
279
|
+
overview: [U.t('Live now'), v.views].filter(Boolean).join(' · ') };
|
|
280
280
|
}).concat(vids.map(function (v, i) {
|
|
281
281
|
var vm = toMeta(v, 'YouTube');
|
|
282
282
|
return { id: vm.id, title: vm.name, season: 1, episode: i + 1, released: agoToDate(v.ago), thumbnail: v.thumb,
|
|
@@ -287,7 +287,7 @@ var YouTube = (function () {
|
|
|
287
287
|
// A video's source: its YouTube id (played through the service, see Stremio.youTubeSource).
|
|
288
288
|
function streams(id) {
|
|
289
289
|
var m = ('' + id).match(/^ytk:v:([A-Za-z0-9_-]{11})$/);
|
|
290
|
-
return Promise.resolve(m ? [{ name: 'YouTube', title: 'Plays through StremioK’s YouTube service', ytId: m[1] }] : []);
|
|
290
|
+
return Promise.resolve(m ? [{ name: 'YouTube', title: U.t('Plays through StremioK’s YouTube service'), ytId: m[1] }] : []);
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
// ----- copying a YouTubio addon's catalogs -----
|
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
|
}
|
|
@@ -278,15 +303,20 @@ var YTPlay = (function () {
|
|
|
278
303
|
|
|
279
304
|
// What to tell you when the service doesn't answer. what: 'channel' | 'trailer'
|
|
280
305
|
function unavailableMessage(what) {
|
|
281
|
-
|
|
306
|
+
// (each said whole: what plays through the service, and why it didn't answer)
|
|
282
307
|
if (MODE === 'tizenbrew') {
|
|
283
|
-
return
|
|
284
|
-
'Close StremioK and open it again from TizenBrew; if that doesn’t help, update TizenBrew.'
|
|
308
|
+
return what === 'trailer' ? U.t('Trailers play through StremioK’s YouTube service, which TizenBrew hasn’t started. Close StremioK and open it again from TizenBrew; if that doesn’t help, update TizenBrew.')
|
|
309
|
+
: what === 'video' ? U.t('YouTube videos play through StremioK’s YouTube service, which TizenBrew hasn’t started. Close StremioK and open it again from TizenBrew; if that doesn’t help, update TizenBrew.')
|
|
310
|
+
: U.t('YouTube channels play through StremioK’s YouTube service, which TizenBrew hasn’t started. Close StremioK and open it again from TizenBrew; if that doesn’t help, update TizenBrew.');
|
|
285
311
|
}
|
|
286
312
|
if (MODE === 'wgt') {
|
|
287
|
-
return
|
|
313
|
+
return what === 'trailer' ? U.t('Trailers play through StremioK’s YouTube service, which didn’t start. Try again, or restart StremioK.')
|
|
314
|
+
: what === 'video' ? U.t('YouTube videos play through StremioK’s YouTube service, which didn’t start. Try again, or restart StremioK.')
|
|
315
|
+
: U.t('YouTube channels play through StremioK’s YouTube service, which didn’t start. Try again, or restart StremioK.');
|
|
288
316
|
}
|
|
289
|
-
return
|
|
317
|
+
return what === 'trailer' ? U.t('Trailers play through StremioK’s YouTube service, which runs on the TV (not in a browser).')
|
|
318
|
+
: what === 'video' ? U.t('YouTube videos play through StremioK’s YouTube service, which runs on the TV (not in a browser).')
|
|
319
|
+
: U.t('YouTube channels play through StremioK’s YouTube service, which runs on the TV (not in a browser).');
|
|
290
320
|
}
|
|
291
321
|
|
|
292
322
|
// One look at the service, without starting it: resolves true / false.
|
|
@@ -296,9 +326,9 @@ var YTPlay = (function () {
|
|
|
296
326
|
|
|
297
327
|
// For Settings: how StremioK was installed.
|
|
298
328
|
function installLabel() {
|
|
299
|
-
return MODE === 'tizenbrew' ? 'TizenBrew module' : MODE === 'wgt' ? 'Sideloaded app (.wgt)' : 'Browser (development)';
|
|
329
|
+
return MODE === 'tizenbrew' ? U.t('TizenBrew module') : MODE === 'wgt' ? U.t('Sideloaded app (.wgt)') : U.t('Browser (development)');
|
|
300
330
|
}
|
|
301
331
|
|
|
302
|
-
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; },
|
|
303
333
|
installLabel: installLabel, unavailableMessage: unavailableMessage, isRunning: isRunning, port: PORT };
|
|
304
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
|
})();
|