stremiok 2.4.1 → 2.4.2
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 +9 -0
- package/config.xml +1 -1
- package/index.html +46 -46
- package/js/lang/ar.js +6 -0
- package/js/lang/ca.js +6 -0
- package/js/lang/de.js +6 -0
- package/js/lang/es.js +6 -0
- package/js/lang/fi.js +6 -0
- package/js/lang/fr.js +6 -0
- package/js/lang/he.js +6 -0
- package/js/lang/hi.js +6 -0
- package/js/lang/it.js +6 -0
- package/js/lang/ja.js +6 -0
- package/js/lang/ko.js +6 -0
- package/js/lang/pl.js +6 -0
- package/js/lang/pt-BR.js +6 -0
- package/js/lang/ru.js +6 -0
- package/js/lang/tr.js +6 -0
- package/js/lang/zh-CN.js +6 -0
- package/js/player-controls.js +4 -1
- package/js/player-core.js +92 -9
- package/js/player-lang.js +54 -8
- package/js/player-store.js +3 -1
- package/js/player-subs.js +16 -5
- package/js/view-settings.js +5 -2
- package/js/ytplay.js +4 -2
- package/package.json +1 -1
- package/service/index.js +238 -3
- package/tizenbrew.html +1 -1
package/js/ytplay.js
CHANGED
|
@@ -112,10 +112,12 @@ var YTPlay = (function () {
|
|
|
112
112
|
// A file (not HLS) through the service's file relay, with its headers and the player's byte
|
|
113
113
|
// range: { url } the player opens. lan: redirects into the home network allowed
|
|
114
114
|
// (Settings › Content › Addons › Local-network links from internet addons).
|
|
115
|
-
|
|
115
|
+
// keep: an MKV's subtitle tracks to keep, by their place among its subtitle tracks; the others
|
|
116
|
+
// are blanked (the service's mkvBlanker); none: the file as it is.
|
|
117
|
+
function fileOpen(url, h, lan, keep) {
|
|
116
118
|
if (MODE === 'browser') { return Promise.reject(new Error('no service')); }
|
|
117
119
|
return ensureService().then(entryAuth).then(function (a) {
|
|
118
|
-
return U.getJSON(PROXY + '/live/file?u=' + encodeURIComponent(url) + headerQuery(h) + (lan ? '&lan=1' : '') + a.q, 5000, 65536, null, a.h);
|
|
120
|
+
return U.getJSON(PROXY + '/live/file?u=' + encodeURIComponent(url) + headerQuery(h) + (lan ? '&lan=1' : '') + (keep ? '&blank=1&keep=' + keep.join(',') : '') + a.q, 5000, 65536, null, a.h);
|
|
119
121
|
});
|
|
120
122
|
}
|
|
121
123
|
// What's in a source's file, from its header (the service's /live/mi: its container, codecs,
|
package/package.json
CHANGED
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) {
|
|
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,202 @@ 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 };
|
|
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
|
+
function tracks(b, abs) { // abs: where b[0] is in the file
|
|
3385
|
+
var subs = 0;
|
|
3386
|
+
children(b, 0, b.length, function (id, st, d, z) {
|
|
3387
|
+
if (id !== 0xAE) { return; }
|
|
3388
|
+
var no = 0, type = 0;
|
|
3389
|
+
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); } });
|
|
3390
|
+
if (type !== 17 || !no) { return; }
|
|
3391
|
+
if (!keep[subs]) { plan.blank[no] = 1; plan.patches.push(abs + st); plan.blanked++; }
|
|
3392
|
+
subs++;
|
|
3393
|
+
});
|
|
3394
|
+
plan.subs = subs;
|
|
3395
|
+
}
|
|
3396
|
+
function cues(b, abs) {
|
|
3397
|
+
children(b, 0, b.length, function (id, st, d, z) {
|
|
3398
|
+
if (id !== 0xBB) { return; }
|
|
3399
|
+
children(b, d, d + z, function (cid, cst, cd, cz) {
|
|
3400
|
+
if (cid !== 0xB7) { return; }
|
|
3401
|
+
var tr = 0, pos = -1;
|
|
3402
|
+
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); } });
|
|
3403
|
+
if (plan.blank[tr]) { plan.patches.push(abs + cst); }
|
|
3404
|
+
if (pos >= 0) { plan.clusters.push(plan.segData + pos); }
|
|
3405
|
+
});
|
|
3406
|
+
});
|
|
3407
|
+
}
|
|
3408
|
+
function element(at, then) {
|
|
3409
|
+
r.get(at, 16, function (e, b) {
|
|
3410
|
+
var id = !e && ebmlId(b, 0), sz = id && ebmlSize(b, id.n);
|
|
3411
|
+
if (!sz) { then(-1, 0, 0); return; }
|
|
3412
|
+
var d = at + id.n + sz.n;
|
|
3413
|
+
if (id.v === I.CLUSTER) { then(-1, id.v, d); return; }
|
|
3414
|
+
if (sz.v < 0) { then(-1, 0, 0); return; }
|
|
3415
|
+
if ((id.v === I.TRACKS || id.v === I.SEEKHEAD || id.v === I.CUES) && sz.v <= MI_ELEMENT_MAX) {
|
|
3416
|
+
r.get(d, sz.v, function (e2, body) {
|
|
3417
|
+
if (!e2) {
|
|
3418
|
+
if (id.v === I.TRACKS) { tracks(body, d); seek.gotTracks = true; }
|
|
3419
|
+
else if (id.v === I.CUES) { cues(body, d); seek.gotCues = true; }
|
|
3420
|
+
else if (!seek.head) {
|
|
3421
|
+
seek.head = true;
|
|
3422
|
+
children(body, 0, body.length, function (cid, st, cd, cz) {
|
|
3423
|
+
if (cid !== I.SEEK) { return; }
|
|
3424
|
+
var sid = 0, pos = -1;
|
|
3425
|
+
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); } });
|
|
3426
|
+
if (pos < 0) { return; }
|
|
3427
|
+
if (sid === I.TRACKS) { seek.tracks = pos; } else if (sid === I.CUES) { seek.cues = pos; }
|
|
3428
|
+
else if (sid === 0x1254C367 || sid === 0x1043A770 || sid === 0x1941A469) { seek.after = Math.min(seek.after === undefined ? Infinity : seek.after, pos); }
|
|
3429
|
+
});
|
|
3430
|
+
}
|
|
3431
|
+
}
|
|
3432
|
+
then(d + sz.v, id.v, d);
|
|
3433
|
+
});
|
|
3434
|
+
return;
|
|
3435
|
+
}
|
|
3436
|
+
then(d + sz.v, id.v, d);
|
|
3437
|
+
});
|
|
3438
|
+
}
|
|
3439
|
+
function walk(at) {
|
|
3440
|
+
if (at < 0 || steps++ > 64 || (r.size() !== null && at >= r.size())) { finish(); return; }
|
|
3441
|
+
element(at, function (next, id) {
|
|
3442
|
+
if (id === I.CLUSTER) { plan.firstCluster = at; finish(); return; }
|
|
3443
|
+
walk(next);
|
|
3444
|
+
});
|
|
3445
|
+
}
|
|
3446
|
+
function finish() {
|
|
3447
|
+
if (plan.firstCluster < 0) { done(null, null); return; }
|
|
3448
|
+
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; }
|
|
3450
|
+
if (!seek.gotCues && seek.cues >= 0) { var c = seek.cues; seek.cues = -1; element(plan.segData + c, function () { finish(); }); return; }
|
|
3451
|
+
var ends = [seek.cues >= 0 ? plan.segData + seek.cues : Infinity];
|
|
3452
|
+
if (seek.after !== undefined) { ends.push(plan.segData + seek.after); }
|
|
3453
|
+
ends.forEach(function (x) { if (x > plan.firstCluster && x < plan.clustersEnd) { plan.clustersEnd = x; } });
|
|
3454
|
+
if (seek.cuesAt > plan.firstCluster && seek.cuesAt < plan.clustersEnd) { plan.clustersEnd = seek.cuesAt; }
|
|
3455
|
+
plan.clusters.push(plan.firstCluster);
|
|
3456
|
+
plan.clusters = plan.clusters.filter(function (x) { return x >= plan.firstCluster && x < plan.clustersEnd; }).sort(function (a, b) { return a - b; });
|
|
3457
|
+
plan.patches.sort(function (a, b) { return a - b; });
|
|
3458
|
+
done(null, plan);
|
|
3459
|
+
}
|
|
3460
|
+
}
|
|
3461
|
+
// Where to start reading for a range from x: a cluster's start at or before it (the blocks are
|
|
3462
|
+
// read from there), else as asked (before the clusters, or past them: offsets only).
|
|
3463
|
+
function blankFrom(plan, x) {
|
|
3464
|
+
if (x < plan.firstCluster || x >= plan.clustersEnd) { return x; }
|
|
3465
|
+
var lo = 0, hi = plan.clusters.length - 1, best = plan.firstCluster;
|
|
3466
|
+
while (lo <= hi) { var mid = (lo + hi) >> 1; if (plan.clusters[mid] <= x) { best = plan.clusters[mid]; lo = mid + 1; } else { hi = mid - 1; } }
|
|
3467
|
+
return x - best > BLANK_BACK_MAX ? x : best;
|
|
3468
|
+
}
|
|
3469
|
+
// The bytes from start, blanked as they pass: { push(buf) -> Buffer, end() -> Buffer }, what's
|
|
3470
|
+
// returned following on from what came before. start: a cluster's start, or anywhere outside
|
|
3471
|
+
// the clusters (blankFrom); else only the offsets (TrackEntries, Cues) are blanked.
|
|
3472
|
+
function mkvBlanker(plan, start) {
|
|
3473
|
+
var pend = allocBuffer(0), base = start, mode, skipTo = 0, afterSkip = '', clusterEnd = Infinity, pi = 0, ended = false;
|
|
3474
|
+
while (pi < plan.patches.length && plan.patches[pi] < start) { pi++; }
|
|
3475
|
+
if (start < plan.firstCluster) { mode = 'skip'; skipTo = plan.firstCluster; afterSkip = 'seg'; }
|
|
3476
|
+
else if (start >= plan.clustersEnd || plan.clusters.indexOf(start) === -1) { mode = 'skip'; skipTo = Infinity; afterSkip = ''; }
|
|
3477
|
+
else { mode = 'seg'; }
|
|
3478
|
+
var out = [];
|
|
3479
|
+
function emit(n) {
|
|
3480
|
+
if (n <= 0) { return; }
|
|
3481
|
+
var piece = pend.slice(0, n);
|
|
3482
|
+
while (pi < plan.patches.length && plan.patches[pi] < base + n) { piece[plan.patches[pi] - base] = EBML_VOID; pi++; }
|
|
3483
|
+
out.push(piece);
|
|
3484
|
+
pend = pend.slice(n); base += n;
|
|
3485
|
+
}
|
|
3486
|
+
function giveUp() { mode = 'skip'; skipTo = Infinity; afterSkip = ''; }
|
|
3487
|
+
function step() { // true: went on; false: needs more bytes
|
|
3488
|
+
if (mode === 'skip') {
|
|
3489
|
+
var n = Math.min(skipTo - base, pend.length);
|
|
3490
|
+
emit(n);
|
|
3491
|
+
if (base >= skipTo && afterSkip) { mode = afterSkip; return true; }
|
|
3492
|
+
return false;
|
|
3493
|
+
}
|
|
3494
|
+
if (mode === 'clu' && base >= clusterEnd) { mode = 'seg'; }
|
|
3495
|
+
if (base >= plan.clustersEnd) { giveUp(); return true; }
|
|
3496
|
+
var id = ebmlId(pend, 0), sz = id && ebmlSize(pend, id.n);
|
|
3497
|
+
if (!id || !sz) {
|
|
3498
|
+
if (pend.length >= 12 || (ended && pend.length)) { giveUp(); return true; }
|
|
3499
|
+
return false;
|
|
3500
|
+
}
|
|
3501
|
+
var hdr = id.n + sz.n;
|
|
3502
|
+
if (mode === 'seg' || (clusterEnd === Infinity && MKV_TOP[id.v])) {
|
|
3503
|
+
if (id.v === MKV_IDS.CLUSTER) { clusterEnd = sz.v < 0 ? Infinity : base + hdr + sz.v; emit(hdr); mode = 'clu'; return true; }
|
|
3504
|
+
if (sz.v < 0) { giveUp(); return true; }
|
|
3505
|
+
mode = 'skip'; skipTo = base + hdr + sz.v; afterSkip = 'seg'; return true;
|
|
3506
|
+
}
|
|
3507
|
+
if (sz.v < 0) { giveUp(); return true; }
|
|
3508
|
+
var tn = -1;
|
|
3509
|
+
if (id.v === 0xA3) {
|
|
3510
|
+
var t = ebmlSize(pend, hdr);
|
|
3511
|
+
if (!t) { if (ended || pend.length > BLANK_HOLD_MAX) { tn = 0; } else { return false; } } else { tn = t.v; }
|
|
3512
|
+
} else if (id.v === 0xA0) {
|
|
3513
|
+
var o = hdr, gEnd = hdr + sz.v;
|
|
3514
|
+
while (o < gEnd) {
|
|
3515
|
+
var cid = ebmlId(pend, o), csz = cid && ebmlSize(pend, o + cid.n);
|
|
3516
|
+
if (!cid || !csz) { break; }
|
|
3517
|
+
if (cid.v === 0xA1) { var bt = ebmlSize(pend, o + cid.n + csz.n); if (bt) { tn = bt.v; } break; }
|
|
3518
|
+
if (csz.v < 0) { tn = 0; break; }
|
|
3519
|
+
o += cid.n + csz.n + csz.v;
|
|
3520
|
+
}
|
|
3521
|
+
if (tn < 0 && o < gEnd) { if (ended || pend.length > BLANK_HOLD_MAX) { tn = 0; } else { return false; } }
|
|
3522
|
+
}
|
|
3523
|
+
if (tn > 0 && plan.blank[tn]) { pend[0] = EBML_VOID; }
|
|
3524
|
+
mode = 'skip'; skipTo = base + hdr + sz.v; afterSkip = 'clu'; return true;
|
|
3525
|
+
}
|
|
3526
|
+
function run() { while (pend.length && step()) { /* on */ } }
|
|
3527
|
+
return {
|
|
3528
|
+
push: function (buf) { pend = pend.length ? Buffer.concat([pend, buf]) : buf; out = []; run(); return out.length === 1 ? out[0] : Buffer.concat(out); },
|
|
3529
|
+
end: function () { ended = true; out = []; run(); if (pend.length) { mode = 'skip'; skipTo = Infinity; emit(pend.length); } return Buffer.concat(out); }
|
|
3530
|
+
};
|
|
3531
|
+
}
|
|
3340
3532
|
// A host in the home network (by its name or address): a private, link-local or carrier-grade
|
|
3341
3533
|
// address, a name without a dot, or a .local / .lan / .home.arpa / .internal one.
|
|
3342
3534
|
function isLanName(host) {
|
|
@@ -3355,8 +3547,24 @@ function isLanName(host) {
|
|
|
3355
3547
|
// outside it, unless Local-network links from internet addons allows it.
|
|
3356
3548
|
function fileHopOk(firstHost, nextHost, lan) { return lan || isLanName(firstHost) || !isLanName(nextHost); }
|
|
3357
3549
|
function liveFile(s, req, res) {
|
|
3550
|
+
if (s.keep && s.plan === undefined) { // (blanking: the plan first, once; meanwhile the player's requests wait)
|
|
3551
|
+
if (s.planWait) { s.planWait.push(function () { liveFile(s, req, res); }); return; }
|
|
3552
|
+
s.planWait = [function () { liveFile(s, req, res); }];
|
|
3553
|
+
blankPlan(s, function (err, plan) {
|
|
3554
|
+
s.plan = err ? null : plan;
|
|
3555
|
+
if (err) { log('file relay: the subtitle tracks couldn\'t be read, the file as it is (' + err.message + ')'); }
|
|
3556
|
+
else if (plan) { log('file relay: ' + plan.blanked + ' of ' + plan.subs + ' subtitle tracks left out'); }
|
|
3557
|
+
var w = s.planWait; s.planWait = null;
|
|
3558
|
+
w.forEach(function (f) { f(); });
|
|
3559
|
+
});
|
|
3560
|
+
return;
|
|
3561
|
+
}
|
|
3358
3562
|
var r = null, gone = false, hops = 0, firstHost = '';
|
|
3359
3563
|
var range = /^bytes=\d*-\d*(,\s*\d*-\d*)*$/.test(String(req.headers.range || '')) ? String(req.headers.range) : '';
|
|
3564
|
+
// (blanked: one range, read from a cluster's start at or before it: blankFrom)
|
|
3565
|
+
var plan = s.plan || null, want = plan ? /^bytes=(\d*)-(\d*)$/.exec(range || 'bytes=0-') : null, x = 0, y = '';
|
|
3566
|
+
if (plan && (!want || want[1] === '')) { plan = null; }
|
|
3567
|
+
if (plan) { x = +want[1]; y = want[2]; range = 'bytes=' + blankFrom(plan, x) + '-' + y; }
|
|
3360
3568
|
function stop() { gone = true; try { if (r) { r.abort(); } } catch (e) {} }
|
|
3361
3569
|
res.on('close', stop);
|
|
3362
3570
|
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 +3586,7 @@ function liveFile(s, req, res) {
|
|
|
3378
3586
|
if (sc >= 300 && sc < 400 && resp.headers.location && hops < 5) { resp.resume(); hops++; get(urllib.resolve(url, resp.headers.location)); return; }
|
|
3379
3587
|
if (sc !== 200 && sc !== 206) { resp.resume(); clearTimeout(timer); fail(sc >= 400 && sc < 600 ? sc : 502, 'HTTP ' + sc); return; }
|
|
3380
3588
|
clearTimeout(timer);
|
|
3589
|
+
if (plan) { blanked(resp, sc); return; }
|
|
3381
3590
|
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
3591
|
if (resp.headers['content-length']) { out['Content-Length'] = resp.headers['content-length']; }
|
|
3383
3592
|
if (resp.headers['content-range']) { out['Content-Range'] = resp.headers['content-range']; }
|
|
@@ -3394,6 +3603,31 @@ function liveFile(s, req, res) {
|
|
|
3394
3603
|
r.on('error', function (e) { clearTimeout(timer); fail(502, (e && e.message) || 'network error'); });
|
|
3395
3604
|
} catch (e) { clearTimeout(timer); fail(400, 'bad link'); }
|
|
3396
3605
|
}
|
|
3606
|
+
// The answer blanked (mkvBlanker) from where it starts, the player given its own range.
|
|
3607
|
+
function blanked(resp, sc) {
|
|
3608
|
+
var cr = /^bytes (\d+)-\d+\/(\d+)$/.exec(String(resp.headers['content-range'] || ''));
|
|
3609
|
+
var from = sc === 206 && cr ? +cr[1] : 0, total = cr ? +cr[2] : +(resp.headers['content-length'] || 0);
|
|
3610
|
+
if (from > x || !(total > 0)) { resp.resume(); fail(502, 'the host sent another part of the file'); return; }
|
|
3611
|
+
var last = y !== '' ? Math.min(+y, total - 1) : total - 1;
|
|
3612
|
+
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) };
|
|
3613
|
+
if (req.headers.range) { out['Content-Range'] = 'bytes ' + x + '-' + last + '/' + total; }
|
|
3614
|
+
res.writeHead(req.headers.range ? 206 : 200, out);
|
|
3615
|
+
var bl = mkvBlanker(plan, from), at = from;
|
|
3616
|
+
function give(b) { // (what comes before x, read only to follow the blocks: not sent)
|
|
3617
|
+
var n = b.length;
|
|
3618
|
+
if (at + n <= x) { at += n; return true; }
|
|
3619
|
+
if (at < x) { b = b.slice(x - at); }
|
|
3620
|
+
at += n;
|
|
3621
|
+
return b.length ? res.write(b) : true;
|
|
3622
|
+
}
|
|
3623
|
+
resp.on('data', function (c) {
|
|
3624
|
+
if (gone) { return; }
|
|
3625
|
+
s.last = Date.now();
|
|
3626
|
+
if (!give(bl.push(c))) { resp.pause(); res.once('drain', function () { if (!gone) { resp.resume(); } }); }
|
|
3627
|
+
});
|
|
3628
|
+
resp.on('end', function () { if (!gone) { give(bl.end()); try { res.end(); } catch (e) {} } });
|
|
3629
|
+
resp.on('error', function () { fail(502, 'the host stopped sending'); });
|
|
3630
|
+
}
|
|
3397
3631
|
get(s.file);
|
|
3398
3632
|
}
|
|
3399
3633
|
function liveHeader(v, max) { v = String(v || ''); return v.length <= (max || 300) && /^[\x20-\x7e]+$/.test(v) ? v : ''; }
|
|
@@ -3461,7 +3695,8 @@ function liveControl(req, res, path, query, leaving) {
|
|
|
3461
3695
|
if (!entryAllowed(req, query)) { send(res, 403, 'text/plain', 'not allowed (token)'); return; }
|
|
3462
3696
|
var fu = q.u || '';
|
|
3463
3697
|
if (!/^https?:\/\/[^\s]+$/i.test(fu) || fu.length > 2000) { send(res, 400, 'text/plain', 'bad link'); return; }
|
|
3464
|
-
var
|
|
3698
|
+
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 fsn = liveFileSession(fu, liveWho(q), q.lan === '1', keep);
|
|
3465
3700
|
send(res, 200, 'application/json', JSON.stringify({ url: liveBase(fsn) + 'f' }));
|
|
3466
3701
|
return;
|
|
3467
3702
|
}
|
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.2'.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
|
})();
|