stremiok 2.4.2 → 2.4.4
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 +14 -0
- package/config.xml +1 -1
- package/css/style.css +2 -0
- package/index.html +46 -46
- package/js/lang/ar.js +11 -1
- package/js/lang/ca.js +10 -0
- package/js/lang/de.js +10 -0
- package/js/lang/es.js +10 -0
- package/js/lang/fi.js +10 -0
- package/js/lang/fr.js +10 -0
- package/js/lang/he.js +10 -0
- package/js/lang/hi.js +11 -1
- package/js/lang/it.js +10 -0
- package/js/lang/ja.js +11 -1
- package/js/lang/ko.js +11 -1
- package/js/lang/pl.js +11 -1
- package/js/lang/pt-BR.js +10 -0
- package/js/lang/ru.js +10 -0
- package/js/lang/tr.js +11 -1
- package/js/lang/zh-CN.js +11 -1
- package/js/player-audio.js +1 -0
- package/js/player-controls.js +4 -2
- package/js/player-core.js +35 -9
- package/js/player-lang.js +4 -2
- package/js/player-subs.js +54 -18
- package/js/profiles.js +13 -3
- package/js/view-core.js +6 -1
- package/js/view-settings.js +49 -2
- package/js/ytplay.js +8 -3
- package/package.json +1 -1
- package/service/index.js +84 -9
- package/tizenbrew.html +1 -1
package/service/index.js
CHANGED
|
@@ -2386,6 +2386,7 @@ function handle(req, res) {
|
|
|
2386
2386
|
if (/^\/smb\//.test(path)) { smbControl(req, res, path, parts[1], leaving); return; } // (a Windows / NAS share: see smbControl)
|
|
2387
2387
|
if (/^\/dlna\//.test(path)) { dlnaControl(req, res, path, parts[1], leaving); return; } // (a DLNA media server: see dlnaControl) // (a network folder's file, for the player: its ticket) // (a network folder: see davControl)
|
|
2388
2388
|
if (path === '/aiom/addons') { aiomControl(req, res, parts[1], leaving); return; }
|
|
2389
|
+
if (path === '/img') { imgControl(req, res, parts[1], leaving); return; } // (an image's link, for a profile picture: see imgControl)
|
|
2389
2390
|
if (path === '/xtvod/list' || path === '/xtvod/find') { xtvControl(req, res, path, parts[1]); return; } // (an Xtream account's films and series: see xtvControl)
|
|
2390
2391
|
if (path === '/stalker/list' || path === '/stalker/link' || path === '/stalker/genres' || path === '/stalker/vod' || path === '/stalker/play') { stalkerControl(req, res, path, parts[1], leaving); return; } // (a Stalker portal: see stalkerControl) // (AIOManager's addons: see aiomControl) // (a live channel's sound repacked: see liveControl) // (the phone's one-time page: see below)
|
|
2391
2392
|
if (path === '/fsfile') { // a USB file over HTTP, with Range: the player reads a big one from here (see fsfile in the header)
|
|
@@ -3325,7 +3326,7 @@ function plugControl(res, query, text, leaving) {
|
|
|
3325
3326
|
// headers and its byte range (seeking works), the answer streamed back as it comes, nothing kept.
|
|
3326
3327
|
// Shares the relays' count (LIVE_MAX); dropped after LIVE_FILM_IDLE_MS unused. Redirects: the
|
|
3327
3328
|
// downloads' host rule (never the TV itself), and into the home network only when allowed (lan).
|
|
3328
|
-
function liveFileSession(u, who, lan, keep) {
|
|
3329
|
+
function liveFileSession(u, who, lan, keep, audio) {
|
|
3329
3330
|
var ids = Object.keys(_live);
|
|
3330
3331
|
if (ids.length >= LIVE_MAX) {
|
|
3331
3332
|
ids.sort(function (x, y) { return _live[x].last - _live[y].last; });
|
|
@@ -3333,7 +3334,7 @@ function liveFileSession(u, who, lan, keep) {
|
|
|
3333
3334
|
delete _live[ids[0]];
|
|
3334
3335
|
}
|
|
3335
3336
|
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 || '',
|
|
3336
|
-
lan: !!lan, film: true, links: {}, last: Date.now(), keep: keep || null };
|
|
3337
|
+
lan: !!lan, film: true, links: {}, last: Date.now(), keep: keep || null, audio: audio || [] };
|
|
3337
3338
|
_live[s.id] = s;
|
|
3338
3339
|
return s;
|
|
3339
3340
|
}
|
|
@@ -3381,17 +3382,44 @@ function blankPlan(s, cb) {
|
|
|
3381
3382
|
o = d + z;
|
|
3382
3383
|
}
|
|
3383
3384
|
}
|
|
3385
|
+
// The track list: the others' entries made Void, and the kept subtitle tracks put in the
|
|
3386
|
+
// order asked for (keep: your languages first), right after the video and audio, so the TV's
|
|
3387
|
+
// first text track is the one wanted (the 2017 TV goes back to its first one now and then).
|
|
3388
|
+
// The same entries in another order: the list is as long as it was, nothing after it moves.
|
|
3384
3389
|
function tracks(b, abs) { // abs: where b[0] is in the file
|
|
3385
|
-
var subs = 0;
|
|
3390
|
+
var subs = 0, auds = 0, parts = [], odd = false;
|
|
3386
3391
|
children(b, 0, b.length, function (id, st, d, z) {
|
|
3387
|
-
|
|
3392
|
+
var piece = { st: st, end: d + z, sub: -1 };
|
|
3393
|
+
parts.push(piece);
|
|
3394
|
+
if (id !== 0xAE) { if (id !== EBML_VOID) { odd = true; } return; } // (a CRC or anything else: not reordered)
|
|
3388
3395
|
var no = 0, type = 0;
|
|
3389
3396
|
children(b, d, d + z, function (cid, cst, cd, cz) { if (cid === 0xD7) { no = ebmlUint(b, cd, cz); } else if (cid === 0x83) { type = ebmlUint(b, cd, cz); } });
|
|
3397
|
+
if (type === 2) { piece.aud = auds++; return; }
|
|
3390
3398
|
if (type !== 17 || !no) { return; }
|
|
3391
|
-
|
|
3399
|
+
piece.sub = subs;
|
|
3400
|
+
if (!keep[subs]) { plan.blank[no] = 1; piece.blank = true; plan.blanked++; }
|
|
3392
3401
|
subs++;
|
|
3393
3402
|
});
|
|
3394
3403
|
plan.subs = subs;
|
|
3404
|
+
var whole = parts.length && parts[0].st === 0 && parts[parts.length - 1].end === b.length;
|
|
3405
|
+
if (odd || !whole) { // (as it is, only the others' IDs made Void)
|
|
3406
|
+
parts.forEach(function (p) { if (p.blank) { plan.patches.push(abs + p.st); } });
|
|
3407
|
+
return;
|
|
3408
|
+
}
|
|
3409
|
+
// (video first as it was; the audio tracks in the order asked for (your language first: no
|
|
3410
|
+
// switch to make), the rest after; the kept subtitle tracks; the others)
|
|
3411
|
+
var order = parts.filter(function (p) { return p.sub < 0 && p.aud === undefined; });
|
|
3412
|
+
s.audio.forEach(function (k) { parts.forEach(function (p) { if (p.aud === k && order.indexOf(p) === -1) { order.push(p); } }); });
|
|
3413
|
+
parts.forEach(function (p) { if (p.aud !== undefined && order.indexOf(p) === -1) { order.push(p); } });
|
|
3414
|
+
(s.keep || []).forEach(function (k) { parts.forEach(function (p) { if (p.sub === k && !p.blank && order.indexOf(p) === -1) { order.push(p); } }); });
|
|
3415
|
+
parts.forEach(function (p) { if (order.indexOf(p) === -1) { order.push(p); } });
|
|
3416
|
+
var out = allocBuffer(b.length), at = 0;
|
|
3417
|
+
order.forEach(function (p) {
|
|
3418
|
+
b.copy(out, at, p.st, p.end);
|
|
3419
|
+
if (p.blank) { out[at] = EBML_VOID; }
|
|
3420
|
+
at += p.end - p.st;
|
|
3421
|
+
});
|
|
3422
|
+
if (Buffer.compare(out, b) !== 0) { plan.rewrite = { at: abs, bytes: out }; }
|
|
3395
3423
|
}
|
|
3396
3424
|
function cues(b, abs) {
|
|
3397
3425
|
children(b, 0, b.length, function (id, st, d, z) {
|
|
@@ -3446,7 +3474,7 @@ function blankPlan(s, cb) {
|
|
|
3446
3474
|
function finish() {
|
|
3447
3475
|
if (plan.firstCluster < 0) { done(null, null); return; }
|
|
3448
3476
|
if (!seek.gotTracks && seek.tracks >= 0) { var t = seek.tracks; seek.tracks = -1; element(plan.segData + t, function () { finish(); }); return; }
|
|
3449
|
-
if (!seek.gotTracks || !plan.blanked) { done(null, null); return; }
|
|
3477
|
+
if (!seek.gotTracks || (!plan.blanked && !plan.rewrite)) { done(null, null); return; }
|
|
3450
3478
|
if (!seek.gotCues && seek.cues >= 0) { var c = seek.cues; seek.cues = -1; element(plan.segData + c, function () { finish(); }); return; }
|
|
3451
3479
|
var ends = [seek.cues >= 0 ? plan.segData + seek.cues : Infinity];
|
|
3452
3480
|
if (seek.after !== undefined) { ends.push(plan.segData + seek.after); }
|
|
@@ -3476,10 +3504,15 @@ function mkvBlanker(plan, start) {
|
|
|
3476
3504
|
else if (start >= plan.clustersEnd || plan.clusters.indexOf(start) === -1) { mode = 'skip'; skipTo = Infinity; afterSkip = ''; }
|
|
3477
3505
|
else { mode = 'seg'; }
|
|
3478
3506
|
var out = [];
|
|
3507
|
+
var rw = plan.rewrite || null;
|
|
3479
3508
|
function emit(n) {
|
|
3480
3509
|
if (n <= 0) { return; }
|
|
3481
3510
|
var piece = pend.slice(0, n);
|
|
3482
3511
|
while (pi < plan.patches.length && plan.patches[pi] < base + n) { piece[plan.patches[pi] - base] = EBML_VOID; pi++; }
|
|
3512
|
+
if (rw && base < rw.at + rw.bytes.length && base + n > rw.at) { // (the track list, reordered)
|
|
3513
|
+
var from = Math.max(base, rw.at), to = Math.min(base + n, rw.at + rw.bytes.length);
|
|
3514
|
+
rw.bytes.copy(piece, from - base, from - rw.at, to - rw.at);
|
|
3515
|
+
}
|
|
3483
3516
|
out.push(piece);
|
|
3484
3517
|
pend = pend.slice(n); base += n;
|
|
3485
3518
|
}
|
|
@@ -3696,7 +3729,8 @@ function liveControl(req, res, path, query, leaving) {
|
|
|
3696
3729
|
var fu = q.u || '';
|
|
3697
3730
|
if (!/^https?:\/\/[^\s]+$/i.test(fu) || fu.length > 2000) { send(res, 400, 'text/plain', 'bad link'); return; }
|
|
3698
3731
|
var keep = q.blank === '1' ? String(q.keep || '').split(',').filter(function (k) { return /^\d{1,3}$/.test(k); }).map(Number).slice(0, 16) : null;
|
|
3699
|
-
var
|
|
3732
|
+
var aorder = q.blank === '1' ? String(q.audio || '').split(',').filter(function (k) { return /^\d{1,3}$/.test(k); }).map(Number).slice(0, 16) : [];
|
|
3733
|
+
var fsn = liveFileSession(fu, liveWho(q), q.lan === '1', keep, aorder);
|
|
3700
3734
|
send(res, 200, 'application/json', JSON.stringify({ url: liveBase(fsn) + 'f' }));
|
|
3701
3735
|
return;
|
|
3702
3736
|
}
|
|
@@ -6298,6 +6332,7 @@ function epgControl(req, res, path, query) {
|
|
|
6298
6332
|
// minute. The port is open only while one is: ENTRY_CONNECTIONS at a time, each given
|
|
6299
6333
|
// ENTRY_VISIT_MS (ENTRY_QUIET_MS of silence). It's plain HTTP: the page says so.
|
|
6300
6334
|
var ENTRY_PORT = PORT + 10, ENTRY_MS = 5 * 60 * 1000, ENTRY_IDLE_MS = 30000, ENTRY_MAX = 8192;
|
|
6335
|
+
var PICTURE_PX = 240, PICTURE_MAX = 262144; // (a profile picture from the phone: made that small there, sent as a JPEG data: link)
|
|
6301
6336
|
// A configuration file: pasted on the import's page (CONFIG_MAX, sent %-encoded: 3 times that), or
|
|
6302
6337
|
// given by the TV to the export's page (GIVE_MAX, POSTed to /entry/give), shown to copy or download.
|
|
6303
6338
|
var CONFIG_MAX = 1572864, GIVE_MAX = 1572864; // (1.5 MB: a file with your history too; the page reads it as JSON, 2 MB at most)
|
|
@@ -6305,7 +6340,7 @@ var ENTRY_OPEN_MAX = 2, ENTRY_OPENS = 12, ENTRY_CONNECTIONS = 8, ENTRY_VISIT_MS
|
|
|
6305
6340
|
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', givelog: 'Your StremioK logs',
|
|
6306
6341
|
search: 'Search on StremioK', youtube: 'Add a YouTube catalog to StremioK', aiom: 'Your AIOManager address for StremioK', aiomkey: 'Your AIOManager API key for StremioK',
|
|
6307
6342
|
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',
|
|
6308
|
-
jellyfin: 'Your media server’s address for StremioK', plugins: 'Add a Nuvio plugin repository to StremioK' };
|
|
6343
|
+
jellyfin: 'Your media server’s address for StremioK', plugins: 'Add a Nuvio plugin repository to StremioK', picture: 'A profile picture for StremioK' };
|
|
6309
6344
|
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)
|
|
6310
6345
|
var _entries = Object.create(null), _entryServer = null, _entrySockets = [], _entryOpened = [];
|
|
6311
6346
|
function lanAddress() {
|
|
@@ -6324,6 +6359,34 @@ function lanAddress() {
|
|
|
6324
6359
|
// folder, or, where it can't read it (TizenBrew has nowhere private to keep one; on Tizen 6
|
|
6325
6360
|
// the service's folder isn't the app's), an X-StremioK header: a web page can't send one
|
|
6326
6361
|
// without a pre-check naming where it comes from, and that's refused.
|
|
6362
|
+
// ---- An image's link, for a profile picture (/img?u=) ----
|
|
6363
|
+
// StremioK only (its token or header). The image downloaded (the downloads' host rule, redirects
|
|
6364
|
+
// followed: liveGet), IMG_MAX at most, and passed on only if it is one (JPEG, PNG, GIF, WebP,
|
|
6365
|
+
// BMP: by its first bytes); the app makes it small and keeps that, never the link.
|
|
6366
|
+
var IMG_MAX = 8 * 1048576;
|
|
6367
|
+
function imgType(b) {
|
|
6368
|
+
if (!b || b.length < 12) { return ''; }
|
|
6369
|
+
if (b[0] === 0xFF && b[1] === 0xD8) { return 'image/jpeg'; }
|
|
6370
|
+
if (b[0] === 0x89 && b[1] === 0x50 && b[2] === 0x4E && b[3] === 0x47) { return 'image/png'; }
|
|
6371
|
+
if (b[0] === 0x47 && b[1] === 0x49 && b[2] === 0x46) { return 'image/gif'; }
|
|
6372
|
+
if (b.toString('binary', 0, 4) === 'RIFF' && b.toString('binary', 8, 12) === 'WEBP') { return 'image/webp'; }
|
|
6373
|
+
if (b[0] === 0x42 && b[1] === 0x4D) { return 'image/bmp'; }
|
|
6374
|
+
return '';
|
|
6375
|
+
}
|
|
6376
|
+
function imgControl(req, res, query, leaving) {
|
|
6377
|
+
if (!entryAllowed(req, query)) { send(res, 403, 'text/plain', 'not allowed (token)'); return; }
|
|
6378
|
+
var m = /(?:^|&)u=([^&]*)/.exec(query || ''), u = '';
|
|
6379
|
+
try { u = m ? decodeURIComponent(m[1]) : ''; } catch (e) { u = ''; }
|
|
6380
|
+
if (!/^https?:\/\/[^\s]+$/i.test(u) || u.length > 2000) { send(res, 400, 'text/plain', 'bad link'); return; }
|
|
6381
|
+
var stop = liveGet(u, { ua: '' }, IMG_MAX, function (err, body) {
|
|
6382
|
+
if (err) { send(res, err.status || 502, 'text/plain', 'failed: ' + err.message); return; }
|
|
6383
|
+
var type = imgType(body);
|
|
6384
|
+
if (!type) { send(res, 415, 'text/plain', 'not an image'); return; }
|
|
6385
|
+
res.writeHead(200, { 'Content-Type': type, 'Content-Length': body.length, 'Cache-Control': 'no-store', 'X-Content-Type-Options': 'nosniff' });
|
|
6386
|
+
res.end(body);
|
|
6387
|
+
});
|
|
6388
|
+
if (leaving && stop) { leaving.push(stop); }
|
|
6389
|
+
}
|
|
6327
6390
|
function entryAllowed(req, query) {
|
|
6328
6391
|
return hasToken(query) || !!(req.headers && req.headers['x-stremiok']);
|
|
6329
6392
|
}
|
|
@@ -6417,7 +6480,19 @@ function entryPage(req, res) {
|
|
|
6417
6480
|
return;
|
|
6418
6481
|
}
|
|
6419
6482
|
if (m[2]) { send(res, 404, 'text/plain', 'Not here'); return; }
|
|
6420
|
-
var config = e.what === 'config', max = config ? CONFIG_MAX * 3 : ENTRY_MAX; // (a pasted file: its lines kept, %-encoded as sent)
|
|
6483
|
+
var config = e.what === 'config', max = config ? CONFIG_MAX * 3 : e.what === 'picture' ? PICTURE_MAX : ENTRY_MAX; // (a pasted file: its lines kept, %-encoded as sent)
|
|
6484
|
+
if (req.method === 'GET' && e.what === 'picture') { // (a photo from the phone, made small here, on the phone: or an image's link)
|
|
6485
|
+
send(res, 200, 'text/html; charset=utf-8', entryHtml(title, '<form method="post" id="fm"><p>A photo from this phone</p><input id="pick" type="file" accept="image/*">' +
|
|
6486
|
+
'<img id="pv" alt="" style="display:none;width:120px;height:120px;border-radius:50%;margin:8px 0;object-fit:cover">' +
|
|
6487
|
+
'<p>Or an image\'s link</p><input id="ln" type="url" autocomplete="off" placeholder="https://…/picture.jpg">' +
|
|
6488
|
+
'<input type="hidden" name="text" id="t"><button type="submit">Send to the TV</button></form>' +
|
|
6489
|
+
'<p>A photo is cut to a square and made small (' + PICTURE_PX + ' × ' + PICTURE_PX + ') on this phone before it goes. It goes straight to your TV over your home network, <b>unencrypted</b>. This page stops working once it has been sent.</p>' +
|
|
6490
|
+
'<script>var t=document.getElementById("t");document.getElementById("pick").onchange=function(){var f=this.files&&this.files[0];if(!f){return;}var r=new FileReader();' +
|
|
6491
|
+
'r.onload=function(){var i=new Image();i.onload=function(){var s=Math.min(i.naturalWidth,i.naturalHeight),c=document.createElement("canvas");c.width=c.height=' + PICTURE_PX + ';' +
|
|
6492
|
+
'c.getContext("2d").drawImage(i,(i.naturalWidth-s)/2,(i.naturalHeight-s)/2,s,s,0,0,' + PICTURE_PX + ',' + PICTURE_PX + ');t.value=c.toDataURL("image/jpeg",0.85);var p=document.getElementById("pv");p.src=t.value;p.style.display="block";};i.src=r.result;};r.readAsDataURL(f);};' +
|
|
6493
|
+
'document.getElementById("fm").onsubmit=function(){if(!t.value){t.value=document.getElementById("ln").value.trim();}if(!t.value){return false;}};</script>'));
|
|
6494
|
+
return;
|
|
6495
|
+
}
|
|
6421
6496
|
if (req.method === 'GET' && config) { // (its link, as before; or the file itself, chosen from the phone's files or pasted)
|
|
6422
6497
|
send(res, 200, 'text/html; charset=utf-8', entryHtml(title, '<form method="post"><p>A link to the file</p><input name="link" type="url" autocomplete="off" placeholder="https://…">' +
|
|
6423
6498
|
'<p>Or the file itself (an export\'s stremiok.txt)</p><input id="pick" type="file" accept=".txt,.cfg,.conf,text/plain">' +
|
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.4.
|
|
13
|
+
var v = '?v=2.4.4'.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
|
})();
|