stremiok 2.4.1 → 2.4.3
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/config.xml +1 -1
- package/css/style.css +1 -0
- package/index.html +46 -46
- package/js/lang/ar.js +7 -0
- package/js/lang/ca.js +7 -0
- package/js/lang/de.js +7 -0
- package/js/lang/es.js +7 -0
- package/js/lang/fi.js +7 -0
- package/js/lang/fr.js +7 -0
- package/js/lang/he.js +7 -0
- package/js/lang/hi.js +7 -0
- package/js/lang/it.js +7 -0
- package/js/lang/ja.js +7 -0
- package/js/lang/ko.js +7 -0
- package/js/lang/pl.js +7 -0
- package/js/lang/pt-BR.js +7 -0
- package/js/lang/ru.js +7 -0
- package/js/lang/tr.js +7 -0
- package/js/lang/zh-CN.js +7 -0
- package/js/player-audio.js +1 -0
- package/js/player-controls.js +7 -2
- package/js/player-core.js +123 -14
- package/js/player-lang.js +57 -9
- package/js/player-store.js +3 -1
- package/js/player-subs.js +70 -23
- package/js/view-settings.js +5 -2
- package/js/ytplay.js +4 -2
- package/package.json +1 -1
- package/service/index.js +271 -3
- package/tizenbrew.html +1 -1
package/service/index.js
CHANGED
|
@@ -3325,7 +3325,7 @@ function plugControl(res, query, text, leaving) {
|
|
|
3325
3325
|
// headers and its byte range (seeking works), the answer streamed back as it comes, nothing kept.
|
|
3326
3326
|
// Shares the relays' count (LIVE_MAX); dropped after LIVE_FILM_IDLE_MS unused. Redirects: the
|
|
3327
3327
|
// downloads' host rule (never the TV itself), and into the home network only when allowed (lan).
|
|
3328
|
-
function liveFileSession(u, who, lan) {
|
|
3328
|
+
function liveFileSession(u, who, lan, keep, audio) {
|
|
3329
3329
|
var ids = Object.keys(_live);
|
|
3330
3330
|
if (ids.length >= LIVE_MAX) {
|
|
3331
3331
|
ids.sort(function (x, y) { return _live[x].last - _live[y].last; });
|
|
@@ -3333,10 +3333,234 @@ function liveFileSession(u, who, lan) {
|
|
|
3333
3333
|
delete _live[ids[0]];
|
|
3334
3334
|
}
|
|
3335
3335
|
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() };
|
|
3336
|
+
lan: !!lan, film: true, links: {}, last: Date.now(), keep: keep || null, audio: audio || [] };
|
|
3337
3337
|
_live[s.id] = s;
|
|
3338
3338
|
return s;
|
|
3339
3339
|
}
|
|
3340
|
+
|
|
3341
|
+
// ---- An MKV's other subtitle tracks left out, as the file passes (blank: /live/file?blank=1) ----
|
|
3342
|
+
// The 2017 TV's player breaks after a forward jump in an MKV with dozens of subtitle tracks (the
|
|
3343
|
+
// picture stutters and loses frames; the same file with video and audio only plays clean), even
|
|
3344
|
+
// with subtitles off. So such a file can come through the relay with those tracks blanked: each
|
|
3345
|
+
// one's TrackEntry, each of its blocks (SimpleBlock or BlockGroup) and its Cues entries get the
|
|
3346
|
+
// one-byte ID of a Void element, which every reader skips. Nothing changes size: every offset
|
|
3347
|
+
// (Cues, SeekHead, cluster sizes, the player's byte ranges) stays the file's own. keep: the
|
|
3348
|
+
// subtitle tracks kept, by their place among the file's subtitle tracks (the app's choice: your
|
|
3349
|
+
// languages). The plan (blankPlan) is read once per session from the header and the Cues.
|
|
3350
|
+
var EBML_VOID = 0xEC, BLANK_BACK_MAX = 64 * 1048576, BLANK_HOLD_MAX = 262144;
|
|
3351
|
+
var MKV_TOP = { 0x1F43B675: 1, 0x1C53BB6B: 1, 0x1254C367: 1, 0x1043A770: 1, 0x1941A469: 1, 0x114D9B74: 1, 0x1549A966: 1, 0x1654AE6B: 1 };
|
|
3352
|
+
// cb(err, plan | null): { segData, firstCluster, clustersEnd, clusters: [abs], blank: { trackNo: 1 },
|
|
3353
|
+
// patches: [abs offsets of IDs made Void], subs, blanked }; null: nothing to blank (not an MKV,
|
|
3354
|
+
// too few subtitle tracks, or all kept).
|
|
3355
|
+
function blankPlan(s, cb) {
|
|
3356
|
+
cb = once(cb);
|
|
3357
|
+
var stops = [], r = miReader(miHttpReader(s.file, s, s.lan, stops)), I = MKV_IDS;
|
|
3358
|
+
var plan = { segData: 0, firstCluster: -1, clustersEnd: Infinity, clusters: [], blank: {}, patches: [], subs: 0, blanked: 0 };
|
|
3359
|
+
var seek = {}, steps = 0, keep = {};
|
|
3360
|
+
(s.keep || []).forEach(function (k) { keep[k] = 1; });
|
|
3361
|
+
var timer = setTimeout(function () { stops.forEach(function (f) { f(); }); cb(upError('timed out', 504)); }, MI_MS);
|
|
3362
|
+
function done(err, p) { clearTimeout(timer); cb(err, p); }
|
|
3363
|
+
r.get(0, 64, function (e, b) {
|
|
3364
|
+
var id = !e && ebmlId(b, 0), sz = id && ebmlSize(b, id.n);
|
|
3365
|
+
if (!sz || sz.v < 0 || id.v !== 0x1A45DFA3) { done(null, null); return; }
|
|
3366
|
+
var at = id.n + sz.n + sz.v;
|
|
3367
|
+
r.get(at, 16, function (e2, b2) {
|
|
3368
|
+
var sid = !e2 && ebmlId(b2, 0), ssz = sid && ebmlSize(b2, sid.n);
|
|
3369
|
+
if (!ssz || sid.v !== I.SEGMENT) { done(null, null); return; }
|
|
3370
|
+
plan.segData = at + sid.n + ssz.n;
|
|
3371
|
+
walk(plan.segData);
|
|
3372
|
+
});
|
|
3373
|
+
});
|
|
3374
|
+
// Each child of b[o..end) with its element's start: fn(id, start, dataStart, dataSize).
|
|
3375
|
+
function children(b, o, end, fn) {
|
|
3376
|
+
for (var n = 0; o < end && n < 65536; n++) {
|
|
3377
|
+
var id = ebmlId(b, o), sz = id && ebmlSize(b, o + id.n);
|
|
3378
|
+
if (!id || !sz) { return; }
|
|
3379
|
+
var d = o + id.n + sz.n, z = sz.v < 0 ? end - d : Math.min(sz.v, end - d);
|
|
3380
|
+
fn(id.v, o, d, z);
|
|
3381
|
+
o = d + z;
|
|
3382
|
+
}
|
|
3383
|
+
}
|
|
3384
|
+
// The track list: the others' entries made Void, and the kept subtitle tracks put in the
|
|
3385
|
+
// order asked for (keep: your languages first), right after the video and audio, so the TV's
|
|
3386
|
+
// first text track is the one wanted (the 2017 TV goes back to its first one now and then).
|
|
3387
|
+
// The same entries in another order: the list is as long as it was, nothing after it moves.
|
|
3388
|
+
function tracks(b, abs) { // abs: where b[0] is in the file
|
|
3389
|
+
var subs = 0, auds = 0, parts = [], odd = false;
|
|
3390
|
+
children(b, 0, b.length, function (id, st, d, z) {
|
|
3391
|
+
var piece = { st: st, end: d + z, sub: -1 };
|
|
3392
|
+
parts.push(piece);
|
|
3393
|
+
if (id !== 0xAE) { if (id !== EBML_VOID) { odd = true; } return; } // (a CRC or anything else: not reordered)
|
|
3394
|
+
var no = 0, type = 0;
|
|
3395
|
+
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); } });
|
|
3396
|
+
if (type === 2) { piece.aud = auds++; return; }
|
|
3397
|
+
if (type !== 17 || !no) { return; }
|
|
3398
|
+
piece.sub = subs;
|
|
3399
|
+
if (!keep[subs]) { plan.blank[no] = 1; piece.blank = true; plan.blanked++; }
|
|
3400
|
+
subs++;
|
|
3401
|
+
});
|
|
3402
|
+
plan.subs = subs;
|
|
3403
|
+
var whole = parts.length && parts[0].st === 0 && parts[parts.length - 1].end === b.length;
|
|
3404
|
+
if (odd || !whole) { // (as it is, only the others' IDs made Void)
|
|
3405
|
+
parts.forEach(function (p) { if (p.blank) { plan.patches.push(abs + p.st); } });
|
|
3406
|
+
return;
|
|
3407
|
+
}
|
|
3408
|
+
// (video first as it was; the audio tracks in the order asked for (your language first: no
|
|
3409
|
+
// switch to make), the rest after; the kept subtitle tracks; the others)
|
|
3410
|
+
var order = parts.filter(function (p) { return p.sub < 0 && p.aud === undefined; });
|
|
3411
|
+
s.audio.forEach(function (k) { parts.forEach(function (p) { if (p.aud === k && order.indexOf(p) === -1) { order.push(p); } }); });
|
|
3412
|
+
parts.forEach(function (p) { if (p.aud !== undefined && order.indexOf(p) === -1) { order.push(p); } });
|
|
3413
|
+
(s.keep || []).forEach(function (k) { parts.forEach(function (p) { if (p.sub === k && !p.blank && order.indexOf(p) === -1) { order.push(p); } }); });
|
|
3414
|
+
parts.forEach(function (p) { if (order.indexOf(p) === -1) { order.push(p); } });
|
|
3415
|
+
var out = allocBuffer(b.length), at = 0;
|
|
3416
|
+
order.forEach(function (p) {
|
|
3417
|
+
b.copy(out, at, p.st, p.end);
|
|
3418
|
+
if (p.blank) { out[at] = EBML_VOID; }
|
|
3419
|
+
at += p.end - p.st;
|
|
3420
|
+
});
|
|
3421
|
+
if (Buffer.compare(out, b) !== 0) { plan.rewrite = { at: abs, bytes: out }; }
|
|
3422
|
+
}
|
|
3423
|
+
function cues(b, abs) {
|
|
3424
|
+
children(b, 0, b.length, function (id, st, d, z) {
|
|
3425
|
+
if (id !== 0xBB) { return; }
|
|
3426
|
+
children(b, d, d + z, function (cid, cst, cd, cz) {
|
|
3427
|
+
if (cid !== 0xB7) { return; }
|
|
3428
|
+
var tr = 0, pos = -1;
|
|
3429
|
+
children(b, cd, cd + cz, function (x, xs, xd, xz) { if (x === 0xF7) { tr = ebmlUint(b, xd, xz); } else if (x === 0xF1) { pos = ebmlUint(b, xd, xz); } });
|
|
3430
|
+
if (plan.blank[tr]) { plan.patches.push(abs + cst); }
|
|
3431
|
+
if (pos >= 0) { plan.clusters.push(plan.segData + pos); }
|
|
3432
|
+
});
|
|
3433
|
+
});
|
|
3434
|
+
}
|
|
3435
|
+
function element(at, then) {
|
|
3436
|
+
r.get(at, 16, function (e, b) {
|
|
3437
|
+
var id = !e && ebmlId(b, 0), sz = id && ebmlSize(b, id.n);
|
|
3438
|
+
if (!sz) { then(-1, 0, 0); return; }
|
|
3439
|
+
var d = at + id.n + sz.n;
|
|
3440
|
+
if (id.v === I.CLUSTER) { then(-1, id.v, d); return; }
|
|
3441
|
+
if (sz.v < 0) { then(-1, 0, 0); return; }
|
|
3442
|
+
if ((id.v === I.TRACKS || id.v === I.SEEKHEAD || id.v === I.CUES) && sz.v <= MI_ELEMENT_MAX) {
|
|
3443
|
+
r.get(d, sz.v, function (e2, body) {
|
|
3444
|
+
if (!e2) {
|
|
3445
|
+
if (id.v === I.TRACKS) { tracks(body, d); seek.gotTracks = true; }
|
|
3446
|
+
else if (id.v === I.CUES) { cues(body, d); seek.gotCues = true; }
|
|
3447
|
+
else if (!seek.head) {
|
|
3448
|
+
seek.head = true;
|
|
3449
|
+
children(body, 0, body.length, function (cid, st, cd, cz) {
|
|
3450
|
+
if (cid !== I.SEEK) { return; }
|
|
3451
|
+
var sid = 0, pos = -1;
|
|
3452
|
+
children(body, cd, cd + cz, function (x, xs, xd, xz) { if (x === I.SEEKID) { sid = ebmlUint(body, xd, xz); } else if (x === I.SEEKPOS) { pos = ebmlUint(body, xd, xz); } });
|
|
3453
|
+
if (pos < 0) { return; }
|
|
3454
|
+
if (sid === I.TRACKS) { seek.tracks = pos; } else if (sid === I.CUES) { seek.cues = pos; }
|
|
3455
|
+
else if (sid === 0x1254C367 || sid === 0x1043A770 || sid === 0x1941A469) { seek.after = Math.min(seek.after === undefined ? Infinity : seek.after, pos); }
|
|
3456
|
+
});
|
|
3457
|
+
}
|
|
3458
|
+
}
|
|
3459
|
+
then(d + sz.v, id.v, d);
|
|
3460
|
+
});
|
|
3461
|
+
return;
|
|
3462
|
+
}
|
|
3463
|
+
then(d + sz.v, id.v, d);
|
|
3464
|
+
});
|
|
3465
|
+
}
|
|
3466
|
+
function walk(at) {
|
|
3467
|
+
if (at < 0 || steps++ > 64 || (r.size() !== null && at >= r.size())) { finish(); return; }
|
|
3468
|
+
element(at, function (next, id) {
|
|
3469
|
+
if (id === I.CLUSTER) { plan.firstCluster = at; finish(); return; }
|
|
3470
|
+
walk(next);
|
|
3471
|
+
});
|
|
3472
|
+
}
|
|
3473
|
+
function finish() {
|
|
3474
|
+
if (plan.firstCluster < 0) { done(null, null); return; }
|
|
3475
|
+
if (!seek.gotTracks && seek.tracks >= 0) { var t = seek.tracks; seek.tracks = -1; element(plan.segData + t, function () { finish(); }); return; }
|
|
3476
|
+
if (!seek.gotTracks || (!plan.blanked && !plan.rewrite)) { done(null, null); return; }
|
|
3477
|
+
if (!seek.gotCues && seek.cues >= 0) { var c = seek.cues; seek.cues = -1; element(plan.segData + c, function () { finish(); }); return; }
|
|
3478
|
+
var ends = [seek.cues >= 0 ? plan.segData + seek.cues : Infinity];
|
|
3479
|
+
if (seek.after !== undefined) { ends.push(plan.segData + seek.after); }
|
|
3480
|
+
ends.forEach(function (x) { if (x > plan.firstCluster && x < plan.clustersEnd) { plan.clustersEnd = x; } });
|
|
3481
|
+
if (seek.cuesAt > plan.firstCluster && seek.cuesAt < plan.clustersEnd) { plan.clustersEnd = seek.cuesAt; }
|
|
3482
|
+
plan.clusters.push(plan.firstCluster);
|
|
3483
|
+
plan.clusters = plan.clusters.filter(function (x) { return x >= plan.firstCluster && x < plan.clustersEnd; }).sort(function (a, b) { return a - b; });
|
|
3484
|
+
plan.patches.sort(function (a, b) { return a - b; });
|
|
3485
|
+
done(null, plan);
|
|
3486
|
+
}
|
|
3487
|
+
}
|
|
3488
|
+
// Where to start reading for a range from x: a cluster's start at or before it (the blocks are
|
|
3489
|
+
// read from there), else as asked (before the clusters, or past them: offsets only).
|
|
3490
|
+
function blankFrom(plan, x) {
|
|
3491
|
+
if (x < plan.firstCluster || x >= plan.clustersEnd) { return x; }
|
|
3492
|
+
var lo = 0, hi = plan.clusters.length - 1, best = plan.firstCluster;
|
|
3493
|
+
while (lo <= hi) { var mid = (lo + hi) >> 1; if (plan.clusters[mid] <= x) { best = plan.clusters[mid]; lo = mid + 1; } else { hi = mid - 1; } }
|
|
3494
|
+
return x - best > BLANK_BACK_MAX ? x : best;
|
|
3495
|
+
}
|
|
3496
|
+
// The bytes from start, blanked as they pass: { push(buf) -> Buffer, end() -> Buffer }, what's
|
|
3497
|
+
// returned following on from what came before. start: a cluster's start, or anywhere outside
|
|
3498
|
+
// the clusters (blankFrom); else only the offsets (TrackEntries, Cues) are blanked.
|
|
3499
|
+
function mkvBlanker(plan, start) {
|
|
3500
|
+
var pend = allocBuffer(0), base = start, mode, skipTo = 0, afterSkip = '', clusterEnd = Infinity, pi = 0, ended = false;
|
|
3501
|
+
while (pi < plan.patches.length && plan.patches[pi] < start) { pi++; }
|
|
3502
|
+
if (start < plan.firstCluster) { mode = 'skip'; skipTo = plan.firstCluster; afterSkip = 'seg'; }
|
|
3503
|
+
else if (start >= plan.clustersEnd || plan.clusters.indexOf(start) === -1) { mode = 'skip'; skipTo = Infinity; afterSkip = ''; }
|
|
3504
|
+
else { mode = 'seg'; }
|
|
3505
|
+
var out = [];
|
|
3506
|
+
var rw = plan.rewrite || null;
|
|
3507
|
+
function emit(n) {
|
|
3508
|
+
if (n <= 0) { return; }
|
|
3509
|
+
var piece = pend.slice(0, n);
|
|
3510
|
+
while (pi < plan.patches.length && plan.patches[pi] < base + n) { piece[plan.patches[pi] - base] = EBML_VOID; pi++; }
|
|
3511
|
+
if (rw && base < rw.at + rw.bytes.length && base + n > rw.at) { // (the track list, reordered)
|
|
3512
|
+
var from = Math.max(base, rw.at), to = Math.min(base + n, rw.at + rw.bytes.length);
|
|
3513
|
+
rw.bytes.copy(piece, from - base, from - rw.at, to - rw.at);
|
|
3514
|
+
}
|
|
3515
|
+
out.push(piece);
|
|
3516
|
+
pend = pend.slice(n); base += n;
|
|
3517
|
+
}
|
|
3518
|
+
function giveUp() { mode = 'skip'; skipTo = Infinity; afterSkip = ''; }
|
|
3519
|
+
function step() { // true: went on; false: needs more bytes
|
|
3520
|
+
if (mode === 'skip') {
|
|
3521
|
+
var n = Math.min(skipTo - base, pend.length);
|
|
3522
|
+
emit(n);
|
|
3523
|
+
if (base >= skipTo && afterSkip) { mode = afterSkip; return true; }
|
|
3524
|
+
return false;
|
|
3525
|
+
}
|
|
3526
|
+
if (mode === 'clu' && base >= clusterEnd) { mode = 'seg'; }
|
|
3527
|
+
if (base >= plan.clustersEnd) { giveUp(); return true; }
|
|
3528
|
+
var id = ebmlId(pend, 0), sz = id && ebmlSize(pend, id.n);
|
|
3529
|
+
if (!id || !sz) {
|
|
3530
|
+
if (pend.length >= 12 || (ended && pend.length)) { giveUp(); return true; }
|
|
3531
|
+
return false;
|
|
3532
|
+
}
|
|
3533
|
+
var hdr = id.n + sz.n;
|
|
3534
|
+
if (mode === 'seg' || (clusterEnd === Infinity && MKV_TOP[id.v])) {
|
|
3535
|
+
if (id.v === MKV_IDS.CLUSTER) { clusterEnd = sz.v < 0 ? Infinity : base + hdr + sz.v; emit(hdr); mode = 'clu'; return true; }
|
|
3536
|
+
if (sz.v < 0) { giveUp(); return true; }
|
|
3537
|
+
mode = 'skip'; skipTo = base + hdr + sz.v; afterSkip = 'seg'; return true;
|
|
3538
|
+
}
|
|
3539
|
+
if (sz.v < 0) { giveUp(); return true; }
|
|
3540
|
+
var tn = -1;
|
|
3541
|
+
if (id.v === 0xA3) {
|
|
3542
|
+
var t = ebmlSize(pend, hdr);
|
|
3543
|
+
if (!t) { if (ended || pend.length > BLANK_HOLD_MAX) { tn = 0; } else { return false; } } else { tn = t.v; }
|
|
3544
|
+
} else if (id.v === 0xA0) {
|
|
3545
|
+
var o = hdr, gEnd = hdr + sz.v;
|
|
3546
|
+
while (o < gEnd) {
|
|
3547
|
+
var cid = ebmlId(pend, o), csz = cid && ebmlSize(pend, o + cid.n);
|
|
3548
|
+
if (!cid || !csz) { break; }
|
|
3549
|
+
if (cid.v === 0xA1) { var bt = ebmlSize(pend, o + cid.n + csz.n); if (bt) { tn = bt.v; } break; }
|
|
3550
|
+
if (csz.v < 0) { tn = 0; break; }
|
|
3551
|
+
o += cid.n + csz.n + csz.v;
|
|
3552
|
+
}
|
|
3553
|
+
if (tn < 0 && o < gEnd) { if (ended || pend.length > BLANK_HOLD_MAX) { tn = 0; } else { return false; } }
|
|
3554
|
+
}
|
|
3555
|
+
if (tn > 0 && plan.blank[tn]) { pend[0] = EBML_VOID; }
|
|
3556
|
+
mode = 'skip'; skipTo = base + hdr + sz.v; afterSkip = 'clu'; return true;
|
|
3557
|
+
}
|
|
3558
|
+
function run() { while (pend.length && step()) { /* on */ } }
|
|
3559
|
+
return {
|
|
3560
|
+
push: function (buf) { pend = pend.length ? Buffer.concat([pend, buf]) : buf; out = []; run(); return out.length === 1 ? out[0] : Buffer.concat(out); },
|
|
3561
|
+
end: function () { ended = true; out = []; run(); if (pend.length) { mode = 'skip'; skipTo = Infinity; emit(pend.length); } return Buffer.concat(out); }
|
|
3562
|
+
};
|
|
3563
|
+
}
|
|
3340
3564
|
// A host in the home network (by its name or address): a private, link-local or carrier-grade
|
|
3341
3565
|
// address, a name without a dot, or a .local / .lan / .home.arpa / .internal one.
|
|
3342
3566
|
function isLanName(host) {
|
|
@@ -3355,8 +3579,24 @@ function isLanName(host) {
|
|
|
3355
3579
|
// outside it, unless Local-network links from internet addons allows it.
|
|
3356
3580
|
function fileHopOk(firstHost, nextHost, lan) { return lan || isLanName(firstHost) || !isLanName(nextHost); }
|
|
3357
3581
|
function liveFile(s, req, res) {
|
|
3582
|
+
if (s.keep && s.plan === undefined) { // (blanking: the plan first, once; meanwhile the player's requests wait)
|
|
3583
|
+
if (s.planWait) { s.planWait.push(function () { liveFile(s, req, res); }); return; }
|
|
3584
|
+
s.planWait = [function () { liveFile(s, req, res); }];
|
|
3585
|
+
blankPlan(s, function (err, plan) {
|
|
3586
|
+
s.plan = err ? null : plan;
|
|
3587
|
+
if (err) { log('file relay: the subtitle tracks couldn\'t be read, the file as it is (' + err.message + ')'); }
|
|
3588
|
+
else if (plan) { log('file relay: ' + plan.blanked + ' of ' + plan.subs + ' subtitle tracks left out'); }
|
|
3589
|
+
var w = s.planWait; s.planWait = null;
|
|
3590
|
+
w.forEach(function (f) { f(); });
|
|
3591
|
+
});
|
|
3592
|
+
return;
|
|
3593
|
+
}
|
|
3358
3594
|
var r = null, gone = false, hops = 0, firstHost = '';
|
|
3359
3595
|
var range = /^bytes=\d*-\d*(,\s*\d*-\d*)*$/.test(String(req.headers.range || '')) ? String(req.headers.range) : '';
|
|
3596
|
+
// (blanked: one range, read from a cluster's start at or before it: blankFrom)
|
|
3597
|
+
var plan = s.plan || null, want = plan ? /^bytes=(\d*)-(\d*)$/.exec(range || 'bytes=0-') : null, x = 0, y = '';
|
|
3598
|
+
if (plan && (!want || want[1] === '')) { plan = null; }
|
|
3599
|
+
if (plan) { x = +want[1]; y = want[2]; range = 'bytes=' + blankFrom(plan, x) + '-' + y; }
|
|
3360
3600
|
function stop() { gone = true; try { if (r) { r.abort(); } } catch (e) {} }
|
|
3361
3601
|
res.on('close', stop);
|
|
3362
3602
|
function fail(code, why) { if (gone) { return; } if (!res.headersSent) { send(res, code, 'text/plain', 'failed: ' + why); } else { try { res.end(); } catch (e) {} } stop(); }
|
|
@@ -3378,6 +3618,7 @@ function liveFile(s, req, res) {
|
|
|
3378
3618
|
if (sc >= 300 && sc < 400 && resp.headers.location && hops < 5) { resp.resume(); hops++; get(urllib.resolve(url, resp.headers.location)); return; }
|
|
3379
3619
|
if (sc !== 200 && sc !== 206) { resp.resume(); clearTimeout(timer); fail(sc >= 400 && sc < 600 ? sc : 502, 'HTTP ' + sc); return; }
|
|
3380
3620
|
clearTimeout(timer);
|
|
3621
|
+
if (plan) { blanked(resp, sc); return; }
|
|
3381
3622
|
var out = { 'Content-Type': String(resp.headers['content-type'] || 'application/octet-stream'), 'Cache-Control': 'no-store', 'X-Content-Type-Options': 'nosniff', 'Accept-Ranges': 'bytes' };
|
|
3382
3623
|
if (resp.headers['content-length']) { out['Content-Length'] = resp.headers['content-length']; }
|
|
3383
3624
|
if (resp.headers['content-range']) { out['Content-Range'] = resp.headers['content-range']; }
|
|
@@ -3394,6 +3635,31 @@ function liveFile(s, req, res) {
|
|
|
3394
3635
|
r.on('error', function (e) { clearTimeout(timer); fail(502, (e && e.message) || 'network error'); });
|
|
3395
3636
|
} catch (e) { clearTimeout(timer); fail(400, 'bad link'); }
|
|
3396
3637
|
}
|
|
3638
|
+
// The answer blanked (mkvBlanker) from where it starts, the player given its own range.
|
|
3639
|
+
function blanked(resp, sc) {
|
|
3640
|
+
var cr = /^bytes (\d+)-\d+\/(\d+)$/.exec(String(resp.headers['content-range'] || ''));
|
|
3641
|
+
var from = sc === 206 && cr ? +cr[1] : 0, total = cr ? +cr[2] : +(resp.headers['content-length'] || 0);
|
|
3642
|
+
if (from > x || !(total > 0)) { resp.resume(); fail(502, 'the host sent another part of the file'); return; }
|
|
3643
|
+
var last = y !== '' ? Math.min(+y, total - 1) : total - 1;
|
|
3644
|
+
var out = { 'Content-Type': String(resp.headers['content-type'] || 'application/octet-stream'), 'Cache-Control': 'no-store', 'X-Content-Type-Options': 'nosniff', 'Accept-Ranges': 'bytes', 'Content-Length': String(last - x + 1) };
|
|
3645
|
+
if (req.headers.range) { out['Content-Range'] = 'bytes ' + x + '-' + last + '/' + total; }
|
|
3646
|
+
res.writeHead(req.headers.range ? 206 : 200, out);
|
|
3647
|
+
var bl = mkvBlanker(plan, from), at = from;
|
|
3648
|
+
function give(b) { // (what comes before x, read only to follow the blocks: not sent)
|
|
3649
|
+
var n = b.length;
|
|
3650
|
+
if (at + n <= x) { at += n; return true; }
|
|
3651
|
+
if (at < x) { b = b.slice(x - at); }
|
|
3652
|
+
at += n;
|
|
3653
|
+
return b.length ? res.write(b) : true;
|
|
3654
|
+
}
|
|
3655
|
+
resp.on('data', function (c) {
|
|
3656
|
+
if (gone) { return; }
|
|
3657
|
+
s.last = Date.now();
|
|
3658
|
+
if (!give(bl.push(c))) { resp.pause(); res.once('drain', function () { if (!gone) { resp.resume(); } }); }
|
|
3659
|
+
});
|
|
3660
|
+
resp.on('end', function () { if (!gone) { give(bl.end()); try { res.end(); } catch (e) {} } });
|
|
3661
|
+
resp.on('error', function () { fail(502, 'the host stopped sending'); });
|
|
3662
|
+
}
|
|
3397
3663
|
get(s.file);
|
|
3398
3664
|
}
|
|
3399
3665
|
function liveHeader(v, max) { v = String(v || ''); return v.length <= (max || 300) && /^[\x20-\x7e]+$/.test(v) ? v : ''; }
|
|
@@ -3461,7 +3727,9 @@ function liveControl(req, res, path, query, leaving) {
|
|
|
3461
3727
|
if (!entryAllowed(req, query)) { send(res, 403, 'text/plain', 'not allowed (token)'); return; }
|
|
3462
3728
|
var fu = q.u || '';
|
|
3463
3729
|
if (!/^https?:\/\/[^\s]+$/i.test(fu) || fu.length > 2000) { send(res, 400, 'text/plain', 'bad link'); return; }
|
|
3464
|
-
var
|
|
3730
|
+
var keep = q.blank === '1' ? String(q.keep || '').split(',').filter(function (k) { return /^\d{1,3}$/.test(k); }).map(Number).slice(0, 16) : null;
|
|
3731
|
+
var aorder = q.blank === '1' ? String(q.audio || '').split(',').filter(function (k) { return /^\d{1,3}$/.test(k); }).map(Number).slice(0, 16) : [];
|
|
3732
|
+
var fsn = liveFileSession(fu, liveWho(q), q.lan === '1', keep, aorder);
|
|
3465
3733
|
send(res, 200, 'application/json', JSON.stringify({ url: liveBase(fsn) + 'f' }));
|
|
3466
3734
|
return;
|
|
3467
3735
|
}
|
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.3'.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
|
})();
|