stremiok 2.3.2 → 2.3.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 +18 -0
- package/README.md +10 -9
- package/config.xml +1 -1
- package/css/modern.css +1 -0
- package/css/style.css +5 -2
- package/index.html +39 -38
- package/js/jellyfin.js +59 -13
- package/js/local.js +99 -31
- package/js/netfolders.js +157 -0
- package/js/player-audio.js +25 -1
- package/js/player-controls.js +3 -2
- package/js/player-core.js +62 -15
- package/js/view-detail.js +4 -4
- package/js/view-home.js +18 -17
- package/js/view-settings.js +117 -3
- package/js/ytplay.js +1 -1
- package/package.json +1 -1
- package/service/index.js +353 -12
- package/tizenbrew.html +1 -1
package/js/player-core.js
CHANGED
|
@@ -401,7 +401,7 @@ var PlayerParts = {};
|
|
|
401
401
|
// is what's learned from it (s.stream, through ctx.learnFor); the title, its episodes and
|
|
402
402
|
// whether it's private stay.
|
|
403
403
|
var SOURCE_FIELDS = ['url', 'variantUrl', 'initialQualityHeight', 'yt', 'ytLang', '_headers', 'localSubs', 'localFile', 'subExtra', 'sourceSubs', 'formatInfo', 'onStarted', 'onFailed', 'stream',
|
|
404
|
-
'_reported', 'fromStart', 'resumeSec', 'switching', 'viaService', '_relay', '_relayFor', '_relayCc'];
|
|
404
|
+
'_reported', 'fromStart', 'resumeSec', 'switching', 'viaService', '_relay', '_relayFor', '_relayCc', '_relayFix'];
|
|
405
405
|
// keep: a source that didn't start gives way to the next (nextSourceOnFail): the same place to
|
|
406
406
|
// resume, and Play from the start as it was.
|
|
407
407
|
function replaceSource(s, keep) {
|
|
@@ -954,6 +954,7 @@ var PlayerParts = {};
|
|
|
954
954
|
if (loaded || !S.active || token !== _playToken) { return; }
|
|
955
955
|
reportStart(false, 'TIMEOUT');
|
|
956
956
|
U.spinner(false);
|
|
957
|
+
if (!drm) { U.log('player', 'Not played (the page’s video player): no start in ' + Math.round(HTML5_START_MS / 1000) + ' s (' + where(url) + ')'); }
|
|
957
958
|
U.toast('This stream didn\'t start'); exitLater();
|
|
958
959
|
}, drm ? SHAKA_START_MS : HTML5_START_MS);
|
|
959
960
|
S.videoEl.onloadedmetadata = function () {
|
|
@@ -977,7 +978,11 @@ var PlayerParts = {};
|
|
|
977
978
|
};
|
|
978
979
|
S.videoEl.onerror = function () {
|
|
979
980
|
if (!S.active || token !== _playToken || drm) { return; } // (Shaka's own errors: see shakaLoadInto)
|
|
980
|
-
|
|
981
|
+
var me = S.videoEl.error, mcode = me ? me.code : 0;
|
|
982
|
+
reportStart(false, mcode === 2 ? 'NETWORK' : 'MEDIA_ERR');
|
|
983
|
+
// (the page's player says little: its code, and a message where the engine has one)
|
|
984
|
+
U.log('player', (loaded ? 'Stopped' : 'Not played') + ' (the page’s video player): ' + (['', 'aborted', 'a network error', 'the file couldn’t be decoded', 'a format or link it can’t play'][mcode] || 'an error') +
|
|
985
|
+
(me && me.message ? ' (' + me.message + ')' : '') + ' (' + where(url) + ')');
|
|
981
986
|
U.toast('Playback error'); exitLater();
|
|
982
987
|
};
|
|
983
988
|
if (drm) {
|
|
@@ -1352,24 +1357,33 @@ var PlayerParts = {};
|
|
|
1352
1357
|
// there, remembered for the channel, or in your default subtitle language), the channel plays
|
|
1353
1358
|
// through the relay with them as subtitle tracks (ctx._relayCc), the sound as it is unless it
|
|
1354
1359
|
// needs repacking too.
|
|
1355
|
-
|
|
1360
|
+
// Your own choice for a channel (the audio menu: its sound straight from the server or repacked,
|
|
1361
|
+
// setLiveSound) is kept as its answer (mine), a year, over the look's.
|
|
1362
|
+
var LIVE_KEY = 'stremiok.livefix', LIVE_KEEP = 300, LIVE_DAYS = 14, LIVE_MINE_DAYS = 365;
|
|
1356
1363
|
function liveFixable(ctx) {
|
|
1357
1364
|
return useAV && S.isLive && !!ctx && !ctx.yt && !ctx.trailer && !(ctx.stream && ctx.stream._drm) && /^https?:\/\//i.test(ctx.url || '') &&
|
|
1358
1365
|
typeof YTPlay !== 'undefined' && !!YTPlay.liveOpen && YTPlay.installMode() !== 'browser';
|
|
1359
1366
|
}
|
|
1360
1367
|
function liveKnown(url) {
|
|
1361
1368
|
var k = (U.store.get(LIVE_KEY, {}) || {})[url];
|
|
1362
|
-
return (k && Date.now() - k.at < LIVE_DAYS * 86400000) ? k : null;
|
|
1369
|
+
return (k && Date.now() - k.at < (k.mine ? LIVE_MINE_DAYS : LIVE_DAYS) * 86400000) ? k : null;
|
|
1363
1370
|
}
|
|
1364
1371
|
// The caption channels kept for a link: [{ ch: 'CC1', lang: 'en' }], or null (not known yet).
|
|
1365
1372
|
function ccOf(k) {
|
|
1366
1373
|
if (!k || !Array.isArray(k.cc)) { return null; }
|
|
1367
1374
|
return k.cc.filter(function (c) { return c && /^CC[1-4]$/.test(c.ch) && (!c.lang || /^[a-z]{2,3}$/.test(c.lang)); }).slice(0, 4);
|
|
1368
1375
|
}
|
|
1369
|
-
|
|
1370
|
-
|
|
1376
|
+
// hls: whether its sound can be repacked at all (HLS of plain MPEG-TS segments, or a raw MPEG-TS
|
|
1377
|
+
// stream: raw, with AAC sound, as the look found; not encrypted or fMP4 ones), kept with it,
|
|
1378
|
+
// with the look's version (lv: one kept by an older look is looked at again).
|
|
1379
|
+
var LIVE_LOOK = 2;
|
|
1380
|
+
function liveKeep(url, fix, cc, mine, hls, raw) {
|
|
1381
|
+
var all = U.store.get(LIVE_KEY, {}) || {}, prev = all[url];
|
|
1371
1382
|
all[url] = { fix: fix ? 1 : 0, at: Date.now() };
|
|
1372
1383
|
if (cc) { all[url].cc = cc; }
|
|
1384
|
+
if (mine || (prev && prev.mine && !!prev.fix === !!fix)) { all[url].mine = 1; } // (yours stays yours)
|
|
1385
|
+
if (hls !== undefined) { all[url].hls = hls ? 1 : 0; all[url].lv = LIVE_LOOK; if (raw) { all[url].raw = 1; } }
|
|
1386
|
+
else if (prev && prev.hls !== undefined) { all[url].hls = prev.hls; if (prev.lv) { all[url].lv = prev.lv; } if (prev.raw) { all[url].raw = 1; } }
|
|
1373
1387
|
var keys = Object.keys(all);
|
|
1374
1388
|
if (keys.length > LIVE_KEEP) {
|
|
1375
1389
|
keys.sort(function (a, b) { return all[a].at - all[b].at; }).slice(0, keys.length - LIVE_KEEP).forEach(function (k) { delete all[k]; });
|
|
@@ -1386,11 +1400,42 @@ var PlayerParts = {};
|
|
|
1386
1400
|
return cc.some(function (c) { return c.lang && langs.some(function (l) { return P.langMatches(l, c.lang); }); });
|
|
1387
1401
|
}
|
|
1388
1402
|
function ccIndex(cc, w) { for (var i = 0; i < cc.length; i++) { if (cc[i].ch === w.ch) { return i; } } return 0; }
|
|
1389
|
-
|
|
1403
|
+
// fix: the sound repacked through it (not only captions).
|
|
1404
|
+
function relayed(ctx, r, cc, fix) {
|
|
1390
1405
|
if (!r || typeof r.url !== 'string' || !/^http:\/\/localhost:\d+\/live\//.test(r.url)) { return false; }
|
|
1391
|
-
ctx._relay = r.url; ctx._relayFor = ctx.url; ctx._relayCc = cc || null; ctx._ccOffer = cc ? null : ctx._ccOffer;
|
|
1406
|
+
ctx._relay = r.url; ctx._relayFor = ctx.url; ctx._relayCc = cc || null; ctx._ccOffer = cc ? null : ctx._ccOffer; ctx._relayFix = !!fix;
|
|
1392
1407
|
return true;
|
|
1393
1408
|
}
|
|
1409
|
+
// The audio menu's choice for a live channel (where its sound can be repacked: liveFixable):
|
|
1410
|
+
// null, or { repacked, mine }.
|
|
1411
|
+
// Only for a channel known to be repackable: an HLS link or format, or the look found HLS
|
|
1412
|
+
// segments (a raw MPEG-TS stream, an Xtream account's default, can't go through the relay).
|
|
1413
|
+
function liveSound() {
|
|
1414
|
+
var ctx = S.ctx;
|
|
1415
|
+
if (!S.active || !ctx || !liveFixable(ctx)) { return null; }
|
|
1416
|
+
var known = liveKnown(ctx.url);
|
|
1417
|
+
var hls = known && known.hls !== undefined ? known.hls === 1 : (HLS_LINK.test(ctx.url) || !!(ctx.formatInfo && ctx.formatInfo.container === 'hls'));
|
|
1418
|
+
if (!hls) { return null; }
|
|
1419
|
+
return { repacked: !!(ctx._relay && ctx._relayFix), mine: !!(known && known.mine) };
|
|
1420
|
+
}
|
|
1421
|
+
// Your choice: the channel again, its sound repacked by the service's relay or straight from
|
|
1422
|
+
// the server (captions through the relay stay), kept for it (liveKeep, mine).
|
|
1423
|
+
function setLiveSound(repack) {
|
|
1424
|
+
var ctx = S.ctx;
|
|
1425
|
+
if (!S.active || !ctx || !liveFixable(ctx)) { return; }
|
|
1426
|
+
var known = liveKnown(ctx.url), cc = ctx._relayCc || null, raw = !!(known && known.raw);
|
|
1427
|
+
liveKeep(ctx.url, repack, known ? ccOf(known) : null, true); // (its hls answer kept)
|
|
1428
|
+
U.log('player', 'Live sound ' + (repack ? 'repacked by StremioK\'s service' : 'straight from the server') + ': your choice for this channel');
|
|
1429
|
+
var msg = repack ? 'Repacking this channel’s sound…' : 'Playing the sound straight from the server…';
|
|
1430
|
+
if (!repack && !cc) { ctx._relay = null; ctx._relayFor = null; ctx._relayFix = false; reopen(msg); return; }
|
|
1431
|
+
function failed() { if (S.ctx === ctx && S.active) { U.toast('StremioK’s service didn’t answer: the sound stays as it was', 5000); } }
|
|
1432
|
+
YTPlay.liveOpen(ctx.url, ctx._headers, true, { fix: !!repack, cc: raw ? null : cc, raw: raw }).then(function (r) {
|
|
1433
|
+
if (S.ctx !== ctx || !S.active) { return; }
|
|
1434
|
+
if (!relayed(ctx, r, cc, repack)) { failed(); return; }
|
|
1435
|
+
reopen(msg);
|
|
1436
|
+
}, failed);
|
|
1437
|
+
}
|
|
1438
|
+
P.liveSound = liveSound; P.setLiveSound = setLiveSound;
|
|
1394
1439
|
// HLS through StremioK's service (Settings › Playback › Seeking & buffering: 'off' | 'headers':
|
|
1395
1440
|
// sources with their own User-Agent, Referer or Cookie | 'all'; or ctx.viaService, hold OK on a
|
|
1396
1441
|
// source): the relay without the look, so every playlist and piece is fetched with the source's
|
|
@@ -1411,7 +1456,7 @@ var PlayerParts = {};
|
|
|
1411
1456
|
var live = !!S.isLive, known = live && liveFixable(ctx) ? liveKnown(ctx.url) : null;
|
|
1412
1457
|
YTPlay.liveOpen(ctx.url, ctx._headers, true, { fix: !!(known && known.fix), film: !live }).then(function (r) {
|
|
1413
1458
|
if (S.ctx !== ctx || !S.active) { return; }
|
|
1414
|
-
relayed(ctx, r, null);
|
|
1459
|
+
relayed(ctx, r, null, !!(known && known.fix));
|
|
1415
1460
|
startAV(ctx.url, settle);
|
|
1416
1461
|
}, function () { if (S.ctx === ctx && S.active) { startAV(ctx.url, settle); } });
|
|
1417
1462
|
}
|
|
@@ -1422,9 +1467,9 @@ var PlayerParts = {};
|
|
|
1422
1467
|
var withCc = ccWanted(ctx, cc) ? cc : null;
|
|
1423
1468
|
if (cc) { ctx._liveChecked = true; } // (both answers in: not asked again)
|
|
1424
1469
|
if (!known || (!known.fix && !withCc)) { startAV(ctx.url, settle); return; }
|
|
1425
|
-
YTPlay.liveOpen(ctx.url, ctx._headers, true, { fix: !!known.fix, cc: withCc }).then(function (r) {
|
|
1470
|
+
YTPlay.liveOpen(ctx.url, ctx._headers, true, { fix: !!known.fix, cc: withCc, raw: !!known.raw }).then(function (r) {
|
|
1426
1471
|
if (S.ctx !== ctx || !S.active) { return; }
|
|
1427
|
-
relayed(ctx, r, withCc);
|
|
1472
|
+
relayed(ctx, r, withCc, !!known.fix);
|
|
1428
1473
|
startAV(ctx.url, settle);
|
|
1429
1474
|
}, function () { if (S.ctx === ctx && S.active) { startAV(ctx.url, settle); } });
|
|
1430
1475
|
}
|
|
@@ -1439,7 +1484,7 @@ var PlayerParts = {};
|
|
|
1439
1484
|
if (!ctx || ctx._liveChecked || !liveFixable(ctx)) { return; }
|
|
1440
1485
|
ctx._liveChecked = true;
|
|
1441
1486
|
var known = liveKnown(ctx.url);
|
|
1442
|
-
if (known && ccOf(known)) { return; }
|
|
1487
|
+
if (known && ccOf(known) && known.lv === LIVE_LOOK) { return; } // (one kept by an older look: looked at again, once)
|
|
1443
1488
|
var url = ctx.url;
|
|
1444
1489
|
stopLiveLook();
|
|
1445
1490
|
var look = _liveLook = U.cancelToken();
|
|
@@ -1447,11 +1492,12 @@ var PlayerParts = {};
|
|
|
1447
1492
|
if (_liveLook === look) { _liveLook = null; }
|
|
1448
1493
|
if (!r || !r.sure) { return; } // (couldn't tell: asked again next time)
|
|
1449
1494
|
var cc = (r.ccSure || r.cc === undefined) ? (ccOf(r) || []) : null, fix = known ? !!known.fix : !!r.fix; // (captions with no text yet: asked again next time; the sound's answer: as first found)
|
|
1450
|
-
|
|
1495
|
+
var hls = !/not an HLS playlist|no variant|encrypted or fMP4|not MPEG-TS|no AAC sound|clock is on the sound/i.test(r.why || ''); // (repackable: its AAC sound reached)
|
|
1496
|
+
liveKeep(url, fix, cc, false, hls, !!r.raw);
|
|
1451
1497
|
if (S.ctx !== ctx || !S.active || ctx.url !== url) { return; }
|
|
1452
1498
|
if (cc && cc.length && !ctx._relayCc) { ctx._ccOffer = cc; }
|
|
1453
1499
|
if (cc && cc.length && ccWanted(ctx, cc)) { ccOn(ctx, 'Adding this channel’s captions…'); return; }
|
|
1454
|
-
if (known || !fix || ctx._relay || !relayed(ctx, r, null)) { return; } // (the sound: restarted for on its first look only)
|
|
1500
|
+
if (known || !fix || ctx._relay || !relayed(ctx, r, null, true)) { return; } // (the sound: restarted for on its first look only)
|
|
1455
1501
|
U.log('player', 'Live sound repacked by StremioK\'s service (' + (r.why || '') + ')');
|
|
1456
1502
|
reopen('Fixing this channel’s sound…');
|
|
1457
1503
|
}, function () {});
|
|
@@ -1463,7 +1509,7 @@ var PlayerParts = {};
|
|
|
1463
1509
|
var known = liveKnown(ctx.url), cc = ccOf(known) || ctx._ccOffer;
|
|
1464
1510
|
if (!cc || !cc.length || !liveFixable(ctx)) { return Promise.resolve(false); }
|
|
1465
1511
|
return YTPlay.liveOpen(ctx.url, ctx._headers, true, { fix: !!(known && known.fix), cc: cc }).then(function (r) {
|
|
1466
|
-
if (S.ctx !== ctx || !S.active || !relayed(ctx, r, cc)) { return false; }
|
|
1512
|
+
if (S.ctx !== ctx || !S.active || !relayed(ctx, r, cc, !!(known && known.fix))) { return false; }
|
|
1467
1513
|
var w = want || cc.filter(function (c) { return ccWanted(ctx, [c]); })[0] || null;
|
|
1468
1514
|
U.log('player', 'Live captions through StremioK\'s service (' + cc.map(function (c) { return c.ch; }).join(', ') + ')');
|
|
1469
1515
|
reopen(message);
|
|
@@ -1602,6 +1648,7 @@ var PlayerParts = {};
|
|
|
1602
1648
|
shakaStop();
|
|
1603
1649
|
try { S.videoEl.pause(); } catch (e3) {}
|
|
1604
1650
|
S.videoEl.removeAttribute('src');
|
|
1651
|
+
try { S.videoEl.load(); } catch (e4) {} // (src removed alone doesn't release the file: it stayed loaded, playable behind the menus)
|
|
1605
1652
|
S.videoEl.className = '';
|
|
1606
1653
|
}
|
|
1607
1654
|
useAV = hasAV; P.useAV = hasAV; // (the next playback the TV's player's, unless it's ClearKey too)
|
package/js/view-detail.js
CHANGED
|
@@ -219,7 +219,7 @@
|
|
|
219
219
|
// retries end there too, one press from another source.
|
|
220
220
|
function startResume(p) {
|
|
221
221
|
// (a file on a USB drive: its source again, with its subtitle files, from whichever drive has it now)
|
|
222
|
-
var local = (typeof LocalMedia !== 'undefined' && /^file:\/\//i.test(p.url || '')) ? LocalMedia.streamForUrl(p.url) : null;
|
|
222
|
+
var local = (typeof LocalMedia !== 'undefined' && (/^file:\/\//i.test(p.url || '') || (LocalMedia.isFolderUrl && LocalMedia.isFolderUrl(p.url)))) ? LocalMedia.streamForUrl(p.url) : null;
|
|
223
223
|
var how = p.fromStart ? { fromStart: true } : null; // (Play from start: the same source, from 0:00)
|
|
224
224
|
if (local) { resumeSources(startPlayback(local, p.id, p.name, how), p.id); return; }
|
|
225
225
|
var st = { url: p.url, name: p.name, _headers: U.sanitizeHeaders(p.headers) || undefined,
|
|
@@ -1433,8 +1433,8 @@
|
|
|
1433
1433
|
// then ones with a format marked "not working" on this TV (Settings > Formats), then
|
|
1434
1434
|
// links that don't play here.
|
|
1435
1435
|
var TIERS = ['2160', '1440', '1080', '720', 'sd', 'other'];
|
|
1436
|
-
var GROUPS = ['local', 'server', 'emby', 'plex', 'played'].concat(TIERS, ['ranked', 'unsuitable', 'worded', 'sized', 'bad', 'where']);
|
|
1437
|
-
var GROUP_TITLES = { local: 'On your USB drive', server: 'On your Jellyfin server', emby: 'On your Emby server', plex: 'On your Plex server', played: 'Played before', '2160': '4K', '1440': '1440p', '1080': '1080p', '720': '720p',
|
|
1436
|
+
var GROUPS = ['local', 'net', 'server', 'emby', 'plex', 'played'].concat(TIERS, ['ranked', 'unsuitable', 'worded', 'sized', 'bad', 'where']);
|
|
1437
|
+
var GROUP_TITLES = { local: 'On your USB drive', net: 'On your network folder', server: 'On your Jellyfin server', emby: 'On your Emby server', plex: 'On your Plex server', played: 'Played before', '2160': '4K', '1440': '1440p', '1080': '1080p', '720': '720p',
|
|
1438
1438
|
sd: 'SD', other: 'Other', ranked: 'Sources', unsuitable: 'Marked not suitable', worded: 'Hidden by your words', sized: 'Outside your size limits', bad: 'Not working or not allowed on this TV', where: 'Where to watch · other apps' };
|
|
1439
1439
|
var KIND_SCORE = { remux: 4, bluray: 3, web: 2, hdtv: 1, '': 1.5, cam: -5 };
|
|
1440
1440
|
function tierOf(info) {
|
|
@@ -1470,7 +1470,7 @@
|
|
|
1470
1470
|
var bad = usable ? Stremio.badFormats(st, info) : [];
|
|
1471
1471
|
var blocked = usable ? Stremio.blockedRes(st, info) : ''; // a resolution you don't allow
|
|
1472
1472
|
var pr = (usable && !unsuitable && !worded && !sized && !bad.length && !blocked) ? playedIndex(hist, st, info) : -1;
|
|
1473
|
-
var group = !usable ? 'where' : unsuitable ? 'unsuitable' : worded ? 'worded' : sized ? 'sized' : (bad.length || blocked) ? 'bad' : st._localFile ? 'local' : st._jf ? (st._jf.kind === 'emby' ? 'emby' : st._jf.kind === 'plex' ? 'plex' : 'server') : pr >= 0 ? 'played' : byRes ? tierOf(info) : 'ranked';
|
|
1473
|
+
var group = !usable ? 'where' : unsuitable ? 'unsuitable' : worded ? 'worded' : sized ? 'sized' : (bad.length || blocked) ? 'bad' : st._localFile ? (st._localFile.dav ? 'net' : 'local') : st._jf ? (st._jf.kind === 'emby' ? 'emby' : st._jf.kind === 'plex' ? 'plex' : 'server') : pr >= 0 ? 'played' : byRes ? tierOf(info) : 'ranked';
|
|
1474
1474
|
var app = group === 'where' ? whereApp(st) : null; // links that open an app here come first
|
|
1475
1475
|
return { st: st, i: i, info: info, bad: bad, blocked: blocked, pr: pr, group: group, tier: tierOf(info), app: app, unsuitable: unsuitable, worded: worded, sized: sized };
|
|
1476
1476
|
});
|
package/js/view-home.js
CHANGED
|
@@ -295,7 +295,7 @@
|
|
|
295
295
|
return art;
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
-
// ----- Local: a USB drive's folders and videos (see LocalMedia) -----
|
|
298
|
+
// ----- Local: a USB drive's (or a network folder's) folders and videos (see LocalMedia) -----
|
|
299
299
|
// One folder at a time, as a grid: its folders, then its videos (posters once matched to a
|
|
300
300
|
// title). OK on a folder opens it, BACK goes up (then to the top menu as on any tab); OK on
|
|
301
301
|
// a video plays it (a matched one through its title's page); long-press: match it by hand.
|
|
@@ -306,12 +306,12 @@
|
|
|
306
306
|
return null;
|
|
307
307
|
}
|
|
308
308
|
function localTitle(d) {
|
|
309
|
-
var name = LocalMedia.knownDrives().length > 1 ? 'USB · ' + d.label.replace(/^removable_/, '') : 'USB drive';
|
|
309
|
+
var name = d.dav ? '🌐 ' + d.label : LocalMedia.knownDrives().length > 1 ? 'USB · ' + d.label.replace(/^removable_/, '') : 'USB drive';
|
|
310
310
|
return [name].concat(_local.rel ? _local.rel.split('/') : []).join(' › ');
|
|
311
311
|
}
|
|
312
312
|
function localRows(rows) {
|
|
313
313
|
if (!LocalMedia.isRead()) { // (read when the tab opens, not at launch)
|
|
314
|
-
rows.appendChild(U.el('div', 'row-empty', 'Reading
|
|
314
|
+
rows.appendChild(U.el('div', 'row-empty', 'Reading your drives and folders…'));
|
|
315
315
|
LocalMedia.ensure().then(redrawLocal);
|
|
316
316
|
return;
|
|
317
317
|
}
|
|
@@ -321,12 +321,12 @@
|
|
|
321
321
|
if (!localDrive()) { _local.root = ds.length === 1 ? ds[0].root : null; _local.rel = ''; _local.listing = null; _local.key = ''; }
|
|
322
322
|
var d = localDrive();
|
|
323
323
|
if (!d) { // several drives: one card each
|
|
324
|
-
rows.appendChild(buildGrid('USB drives', ds.map(function (x) {
|
|
325
|
-
var c = posterCard({ id: 'drive:' + x.root, name: '💾 ' + x.label.replace(/^removable_/, '') }, 'local');
|
|
324
|
+
rows.appendChild(buildGrid(ds.some(function (x) { return x.dav; }) ? 'Drives and network folders' : 'USB drives', ds.map(function (x) {
|
|
325
|
+
var c = posterCard({ id: 'drive:' + x.root, name: (x.dav ? '🌐 ' + x.label : '💾 ' + x.label.replace(/^removable_/, '')) }, 'local');
|
|
326
326
|
c.className += ' local-folder';
|
|
327
327
|
c.__onselect = function () { _local.root = x.root; _local.rel = ''; _local.listing = null; _local.key = ''; _local.focusRel = '__first'; renderHome(); };
|
|
328
328
|
c.__onlongpress = null;
|
|
329
|
-
c.__meta = { name: x.label, description: x.root };
|
|
329
|
+
c.__meta = { name: x.label, description: x.dav ? 'Network folder · ' + x.dav.url : x.root };
|
|
330
330
|
return c;
|
|
331
331
|
})));
|
|
332
332
|
return;
|
|
@@ -384,26 +384,27 @@
|
|
|
384
384
|
// drive stays as it was indexed before, if it was); while matching, the listing and the
|
|
385
385
|
// matches so far stay.
|
|
386
386
|
function confirmStopIndexing(d, st, after) {
|
|
387
|
-
|
|
388
|
-
|
|
387
|
+
var what = d.dav ? 'folder' : 'drive';
|
|
388
|
+
confirm(st.phase === 'matching' ? 'Stop matching this ' + what + '’s videos? The listing and what’s been matched so far are kept; the rest can be matched later (Continue matching).'
|
|
389
|
+
: 'Stop indexing this ' + what + '? It hasn’t been listed yet, so nothing new is kept: it stays as it was indexed before (if it was).',
|
|
389
390
|
'Stop', function () { LocalMedia.stopScan(d); after(); }, { noLabel: 'Keep going', plain: true });
|
|
390
391
|
}
|
|
391
392
|
V.confirmStopIndexing = confirmStopIndexing;
|
|
392
393
|
// The drive's index (so title pages know what's on it): read only when asked.
|
|
393
394
|
function indexCard(d) {
|
|
394
|
-
var st = LocalMedia.status(d), busy = st.state === 'scanning';
|
|
395
|
-
var busyName = st.phase === 'matching' ? '⏳ Matching ' + st.done + ' / ' + st.total : '⏳ Listing the
|
|
396
|
-
var c = posterCard({ id: 'index:' + d.root, name: busy ? busyName : st.state === 'none' ? '🔍 Index this
|
|
395
|
+
var st = LocalMedia.status(d), busy = st.state === 'scanning', what = d.dav ? 'folder' : 'drive';
|
|
396
|
+
var busyName = st.phase === 'matching' ? '⏳ Matching ' + st.done + ' / ' + st.total : '⏳ Listing the ' + what + '…';
|
|
397
|
+
var c = posterCard({ id: 'index:' + d.root, name: busy ? busyName : st.state === 'none' ? '🔍 Index this ' + what : st.left ? '🔍 Continue matching (' + st.left + ' left)' : '🔍 Index again' }, 'local');
|
|
397
398
|
c.className += ' local-folder';
|
|
398
399
|
c.__onlongpress = null;
|
|
399
|
-
c.__meta = { name: 'Index this
|
|
400
|
+
c.__meta = { name: 'Index this ' + what, description: (st.state === 'none' ? 'Not indexed yet. ' : st.state === 'failed' ? 'Indexing failed: ' + st.error + '. ' :
|
|
400
401
|
busy ? 'Indexing… (OK: stop) ' : st.videos + ' videos, ' + st.matched + ' matched to titles, indexed ' + U.dayLabel(st.at) + '. ') +
|
|
401
|
-
(LocalMedia.matchingAllowed() ? 'Indexing lists the
|
|
402
|
-
: 'Indexing lists the
|
|
402
|
+
(LocalMedia.matchingAllowed() ? 'Indexing lists the ' + what + '’s videos and matches them to titles, so their title pages offer them (“On your ' + (d.dav ? 'network folder' : 'USB drive') + '”).'
|
|
403
|
+
: 'Indexing lists the ' + what + '’s videos (matching them to titles is off: Settings › Content › USB drive).') };
|
|
403
404
|
c.__onselect = function () {
|
|
404
405
|
if (busy) { confirmStopIndexing(d, st, function () { renderHome(); }); return; }
|
|
405
406
|
if (st.left) {
|
|
406
|
-
pickList('Index this
|
|
407
|
+
pickList('Index this ' + what, [['more', 'Continue matching (' + st.left + ' titles left)'], ['again', 'Index again (list the ' + what + ' afresh)']], 'more', function (k) {
|
|
407
408
|
_local.focusRel = 'index:' + d.root;
|
|
408
409
|
if (k === 'more') { LocalMedia.continueMatching(d); } else { LocalMedia.scan(d); }
|
|
409
410
|
renderHome();
|
|
@@ -411,7 +412,7 @@
|
|
|
411
412
|
return;
|
|
412
413
|
}
|
|
413
414
|
_local.focusRel = 'index:' + d.root;
|
|
414
|
-
LocalMedia.scan(d).then(function () { var s2 = LocalMedia.status(d); U.toast(s2.state === 'failed' ? 'Indexing failed' : 'Indexed: ' + s2.videos + ' videos, ' + s2.matched + ' matched',
|
|
415
|
+
LocalMedia.scan(d).then(function () { var s2 = LocalMedia.status(d); U.toast(s2.state === 'failed' ? 'Indexing failed' + (s2.error ? ': ' + s2.error : '') : 'Indexed: ' + s2.videos + ' videos, ' + s2.matched + ' matched', 5000); });
|
|
415
416
|
renderHome();
|
|
416
417
|
};
|
|
417
418
|
return c;
|
|
@@ -677,7 +678,7 @@
|
|
|
677
678
|
var c = posterCard({ id: e.id, name: e.name || ('' + e.id).split('/').pop() }, 'local');
|
|
678
679
|
c.className += ' local-video';
|
|
679
680
|
c.__cwKey = showKey(e);
|
|
680
|
-
c.__meta = { name: e.name, description: (e.position ? 'Resume at ' + U.fmtTime(e.position) + (e.duration ? ' of ' + U.fmtTime(e.duration) : '') : 'Added, not started yet') + ' · on your USB drive' };
|
|
681
|
+
c.__meta = { name: e.name, description: (e.position ? 'Resume at ' + U.fmtTime(e.position) + (e.duration ? ' of ' + U.fmtTime(e.duration) : '') : 'Added, not started yet') + (/^local:\d+:@dav:/.test(e.id) ? ' · in your network folder' : ' · on your USB drive') };
|
|
681
682
|
c.__onselect = function () { LocalMedia.resumePlain(e, function () { renderHome(); }); };
|
|
682
683
|
c.__onlongpress = function () { continueActions(e, null, null, null, c); };
|
|
683
684
|
if (e.duration) { var p = U.el('div', 'prog'); p.style.width = Math.min(100, (e.position / e.duration * 100)) + '%'; c.appendChild(p); }
|
package/js/view-settings.js
CHANGED
|
@@ -179,6 +179,9 @@
|
|
|
179
179
|
wrap.appendChild(U.el('div', 'hint',
|
|
180
180
|
'The track in your preferred language plays on its own; with none, the second choice. The red key switches while watching. ' +
|
|
181
181
|
'Switching to it: Quick starts in your language at once. Safe is for files where Quick names your language but you hear another (the 2017 TV needs 10 seconds).'));
|
|
182
|
+
if (typeof YTPlay !== 'undefined' && YTPlay.installMode && YTPlay.installMode() === 'tizenbrew') {
|
|
183
|
+
wrap.appendChild(U.el('div', 'hint', '⚠ Under TizenBrew none of this applies: StremioK has no TV player there, and only a file’s first audio track plays. The sideloaded app can switch.'));
|
|
184
|
+
}
|
|
182
185
|
focusSettings();
|
|
183
186
|
}
|
|
184
187
|
|
|
@@ -382,6 +385,7 @@
|
|
|
382
385
|
['YouTube', 'Your YouTube channels, playlists and searches; YouTube in Search', 'youtube'],
|
|
383
386
|
['Streaming apps', 'Your apps (Prime Video, Netflix, …) that open a title\'s "where to watch" sources', 'appshortcuts'],
|
|
384
387
|
['USB drive', 'The Local tab: what\'s on your drive, matched to titles; hidden files', 'usb'],
|
|
388
|
+
['Network folders', 'Folders a NAS or computer shares over WebDAV, in the Local tab: their videos as sources', 'netfolders'],
|
|
385
389
|
['Media servers', 'Your Jellyfin or Emby server: its libraries on Home, its files as sources', 'mediaservers'],
|
|
386
390
|
['Import configuration file', 'Import addons, API keys & IPTV playlists', 'import'],
|
|
387
391
|
['Export configuration', 'Your addons, playlists, API keys and settings, to your phone', 'export']] },
|
|
@@ -444,6 +448,7 @@
|
|
|
444
448
|
else if (_settingsSection === 'storage') { settingsStorage(wrap); }
|
|
445
449
|
else if (_settingsSection === 'tvapps') { settingsTvApps(wrap); }
|
|
446
450
|
else if (_settingsSection === 'usb') { settingsUsb(wrap); }
|
|
451
|
+
else if (_settingsSection === 'netfolders') { settingsNetFolders(wrap); }
|
|
447
452
|
else if (_settingsSection === 'mediaservers') { settingsMediaServers(wrap); }
|
|
448
453
|
else if (_settingsSection === 'private') { settingsPrivate(wrap); }
|
|
449
454
|
else if (_settingsSection === 'appshortcuts') { settingsAppShortcuts(wrap); }
|
|
@@ -516,10 +521,12 @@
|
|
|
516
521
|
if (typeof YTPlay !== 'undefined' && YTPlay.installMode && YTPlay.installMode() === 'tizenbrew') { wrap.appendChild(U.el('div', 'hint', TIZENBREW_NOTE)); }
|
|
517
522
|
// How StremioK was installed, and whether its YouTube service (channels, trailers) answers
|
|
518
523
|
if (typeof YTPlay !== 'undefined' && YTPlay.installLabel) {
|
|
519
|
-
|
|
524
|
+
// (and which video player plays: the TV's own, or the page's, as under TizenBrew)
|
|
525
|
+
var player = ' · Video player: ' + ((window.webapis && webapis.avplay) ? 'the TV’s own' : YTPlay.installMode() === 'tizenbrew' ? 'the page’s (TizenBrew has no TV player: one audio track)' : 'the browser’s');
|
|
526
|
+
var about = U.el('div', 'hint settings-about', 'Installed as: ' + YTPlay.installLabel() + player + ' · YouTube service: checking…');
|
|
520
527
|
wrap.appendChild(about);
|
|
521
528
|
YTPlay.isRunning().then(function (up) {
|
|
522
|
-
about.textContent = 'Installed as: ' + YTPlay.installLabel() + ' · YouTube service: ' +
|
|
529
|
+
about.textContent = 'Installed as: ' + YTPlay.installLabel() + player + ' · YouTube service: ' +
|
|
523
530
|
(up ? 'running' : YTPlay.installMode() === 'wgt' ? 'starts when needed' : 'not running');
|
|
524
531
|
});
|
|
525
532
|
}
|
|
@@ -1957,6 +1964,113 @@
|
|
|
1957
1964
|
return st.videos + ' video' + (st.videos === 1 ? '' : 's') + ', ' + st.matched + ' matched to titles' + (st.truncated ? ' (a very large drive: only part of it)' : '') +
|
|
1958
1965
|
(st.left ? ', ' + st.left + ' titles left to match' : '') + ' · indexed ' + U.dayLabel(st.at) + ' ' + new Date(st.at).toTimeString().slice(0, 5);
|
|
1959
1966
|
}
|
|
1967
|
+
// ---- Network folders (WebDAV): NetFolders ----
|
|
1968
|
+
var _netListening = false;
|
|
1969
|
+
function settingsNetFolders(wrap) {
|
|
1970
|
+
wrap.appendChild(U.el('h2', null, 'Network folders'));
|
|
1971
|
+
if (typeof NetFolders === 'undefined' || typeof LocalMedia === 'undefined') { focusSettings(); return; }
|
|
1972
|
+
if (!_netListening) {
|
|
1973
|
+
_netListening = true;
|
|
1974
|
+
LocalMedia.onChange(function (what) {
|
|
1975
|
+
if (_settingsSection !== 'netfolders' || /\bhidden\b/.test(scr('settings').className || '') || isModalOpen()) { return; }
|
|
1976
|
+
if (what === 'status' || what === 'matches' || what === 'index') {
|
|
1977
|
+
var rows = scr('settings').querySelectorAll('.settings-wrap .addon-item');
|
|
1978
|
+
for (var i = 0; i < rows.length; i++) { if (rows[i].__netFolder) { rows[i].querySelector('.a-url').textContent = netFolderLine(rows[i].__netFolder); } }
|
|
1979
|
+
}
|
|
1980
|
+
});
|
|
1981
|
+
}
|
|
1982
|
+
var add = U.el('div', 'addon-item focusable cfg-row');
|
|
1983
|
+
add.appendChild(U.el('div', 'a-name', '+ Add a network folder'));
|
|
1984
|
+
add.appendChild(U.el('div', 'a-url', 'Its WebDAV address, then the user name and password it asks for, if any'));
|
|
1985
|
+
add.__onselect = function () { askNetAddress(''); };
|
|
1986
|
+
wrap.appendChild(add);
|
|
1987
|
+
var focus = null;
|
|
1988
|
+
NetFolders.all().forEach(function (f) {
|
|
1989
|
+
var r = U.el('div', 'addon-item focusable cfg-row');
|
|
1990
|
+
r.__netFolder = f;
|
|
1991
|
+
r.appendChild(U.el('div', 'a-name', '🌐 ' + f.name + (f.off ? ' · Off' : '')));
|
|
1992
|
+
r.appendChild(U.el('div', 'a-url', netFolderLine(f)));
|
|
1993
|
+
r.__onselect = function () {
|
|
1994
|
+
var d = NetFolders.driveOf(f), st = LocalMedia.status(d);
|
|
1995
|
+
if (!f.off && st.state === 'scanning') { V.confirmStopIndexing(d, st, renderSettings); return; }
|
|
1996
|
+
var opts = f.off ? [['on', 'Turn on']] : [['off', 'Turn off'], ['index', st.left ? 'Continue matching (' + st.left + ' titles left)' : 'Index again']];
|
|
1997
|
+
pickList(f.name, opts.concat([['remove', 'Remove']]), null, function (v) {
|
|
1998
|
+
_focusChild = 'nf:' + f.id;
|
|
1999
|
+
if (v === 'on' || v === 'off') {
|
|
2000
|
+
NetFolders.setOn(f.id, v === 'on');
|
|
2001
|
+
markHomeDirty();
|
|
2002
|
+
U.toast('“' + f.name + '” ' + (v === 'on' ? 'on' : 'off'));
|
|
2003
|
+
renderSettings();
|
|
2004
|
+
} else if (v === 'index') {
|
|
2005
|
+
(st.left ? LocalMedia.continueMatching(d) : LocalMedia.scan(d)).then(function () {
|
|
2006
|
+
var s2 = LocalMedia.status(d);
|
|
2007
|
+
U.toast(s2.state === 'failed' ? 'Indexing failed' + (s2.error ? ': ' + s2.error : '') : 'Indexed: ' + s2.videos + ' videos, ' + s2.matched + ' matched', 5000);
|
|
2008
|
+
});
|
|
2009
|
+
renderSettings();
|
|
2010
|
+
} else if (v === 'remove') {
|
|
2011
|
+
confirm('Remove “' + f.name + '”? Its index goes too; the folder itself isn’t touched.', 'Remove', function () { NetFolders.remove(f.id); markHomeDirty(); renderSettings(); });
|
|
2012
|
+
}
|
|
2013
|
+
});
|
|
2014
|
+
};
|
|
2015
|
+
if (_focusChild === 'nf:' + f.id) { focus = r; }
|
|
2016
|
+
wrap.appendChild(r);
|
|
2017
|
+
});
|
|
2018
|
+
wrap.appendChild(U.el('div', 'hint', 'A NAS (Synology, QNAP), Nextcloud, or a computer running rclone (rclone serve webdav). Home › Local shows each folder; its videos play as they are (nothing converted), so the TV must play their format.'));
|
|
2019
|
+
if (focus) { _focusChild = null; Focus.setScope(scr('settings'), focus); } else { focusSettings(); }
|
|
2020
|
+
}
|
|
2021
|
+
function netFolderLine(f) {
|
|
2022
|
+
if (f.off) { return f.url + ' · its sources set aside, its index kept'; }
|
|
2023
|
+
var st = LocalMedia.status(NetFolders.driveOf(f));
|
|
2024
|
+
return f.url + (f.user ? ' · as ' + f.user : '') + (f.cert ? ' · its certificate trusted' : '') + ' · ' + usbDriveLine(st).replace('listing the drive', 'listing the folder').replace('a very large drive', 'a very large folder');
|
|
2025
|
+
}
|
|
2026
|
+
function askNetAddress(value) {
|
|
2027
|
+
App.openEntry({
|
|
2028
|
+
title: 'Network folder: address',
|
|
2029
|
+
hint: 'Its WebDAV address, like http://192.168.0.50:8080/media (https:// too). RETURN cancels.',
|
|
2030
|
+
value: value || 'http://', placeholder: 'http://192.168.0.50:8080/media', phone: 'webdav',
|
|
2031
|
+
validate: function (v) { return NetFolders.addressProblem(v); },
|
|
2032
|
+
onConfirm: function (url) {
|
|
2033
|
+
App.back();
|
|
2034
|
+
App.openEntry({
|
|
2035
|
+
title: 'Network folder: user name', hint: 'The user name it asks for; leave it empty if it asks for none. RETURN cancels.', value: '', placeholder: 'user name',
|
|
2036
|
+
validate: function () { return null; },
|
|
2037
|
+
onConfirm: function (user) {
|
|
2038
|
+
App.back();
|
|
2039
|
+
if (!('' + user).trim()) { netProbe(url, '', '', ''); return; }
|
|
2040
|
+
App.openEntry({
|
|
2041
|
+
title: 'Network folder: password', hint: 'Its password (kept on the TV, sent only to that folder). RETURN cancels.', value: '', placeholder: 'password', secret: true,
|
|
2042
|
+
validate: function () { return null; },
|
|
2043
|
+
onConfirm: function (pass) { App.back(); netProbe(url, ('' + user).trim(), '' + pass, ''); }
|
|
2044
|
+
});
|
|
2045
|
+
}
|
|
2046
|
+
});
|
|
2047
|
+
}
|
|
2048
|
+
});
|
|
2049
|
+
}
|
|
2050
|
+
// Ask the folder with that sign-in; a certificate it made itself: asked about first.
|
|
2051
|
+
function netProbe(url, user, pass, cert) {
|
|
2052
|
+
U.spinner(true, 'Asking the folder…');
|
|
2053
|
+
NetFolders.probe(url, user, pass, cert).then(function (p) {
|
|
2054
|
+
U.spinner(false);
|
|
2055
|
+
var f;
|
|
2056
|
+
try { f = NetFolders.add(p); } catch (e) { U.toast(e.message, 5000); return; }
|
|
2057
|
+
markHomeDirty();
|
|
2058
|
+
_settingsSection = 'netfolders';
|
|
2059
|
+
_focusChild = 'nf:' + f.id;
|
|
2060
|
+
renderSettings();
|
|
2061
|
+
U.toast('✓ Added “' + f.name + '”: Home › Local shows it', 5000);
|
|
2062
|
+
}, function (e) {
|
|
2063
|
+
U.spinner(false);
|
|
2064
|
+
if (e && e.why === 'untrusted' && e.cert && !cert) {
|
|
2065
|
+
confirm('“' + url + '”: trust this certificate? It isn’t from a known authority (one the folder made itself?)' + (e.name ? ', for ' + e.name : '') + (e.until ? ', until ' + e.until : '') +
|
|
2066
|
+
'. Its fingerprint (SHA-256): ' + e.fp + '. StremioK then accepts this certificate only, for this folder.', 'Trust this certificate', function () { netProbe(url, user, pass, e.cert); }, { noLabel: 'Cancel', plain: true });
|
|
2067
|
+
return;
|
|
2068
|
+
}
|
|
2069
|
+
U.toast((e && e.message) || 'It failed', 7000);
|
|
2070
|
+
if (_settingsSection === 'netfolders') { renderSettings(); }
|
|
2071
|
+
});
|
|
2072
|
+
}
|
|
2073
|
+
|
|
1960
2074
|
function settingsUsb(wrap) {
|
|
1961
2075
|
wrap.appendChild(U.el('h2', null, 'USB drive'));
|
|
1962
2076
|
if (typeof LocalMedia === 'undefined' || !LocalMedia.available()) {
|
|
@@ -1984,7 +2098,7 @@
|
|
|
1984
2098
|
focusSettings();
|
|
1985
2099
|
return;
|
|
1986
2100
|
}
|
|
1987
|
-
var ds = LocalMedia.knownDrives(), first = null;
|
|
2101
|
+
var ds = LocalMedia.knownDrives().filter(function (d) { return !d.dav; }), first = null; // (network folders: their own page)
|
|
1988
2102
|
if (!ds.length) { wrap.appendChild(U.el('div', 'hint', 'No USB drive plugged in.')); }
|
|
1989
2103
|
ds.forEach(function (d) {
|
|
1990
2104
|
var r = U.el('div', 'addon-item focusable');
|
package/js/ytplay.js
CHANGED
|
@@ -87,7 +87,7 @@ var YTPlay = (function () {
|
|
|
87
87
|
var cc = opts && opts.cc ? opts.cc.map(function (c) { return c.ch + (c.lang ? '-' + c.lang : ''); }).join(',') : '';
|
|
88
88
|
return ensureService().then(entryAuth).then(function (a) {
|
|
89
89
|
var q = '/live/open?u=' + encodeURIComponent(url) + (h && h.ua ? '&ua=' + encodeURIComponent(h.ua) : '') + (h && h.ref ? '&ref=' + encodeURIComponent(h.ref) : '') + (h && h.cookie ? '&cookie=' + encodeURIComponent(h.cookie) : '') + (force ? '&force=1' : '') +
|
|
90
|
-
(force && opts && opts.fix === false ? '&fix=0' : '') + (force && cc ? '&cc=' + encodeURIComponent(cc) : '') + (force && opts && opts.film ? '&film=1' : '');
|
|
90
|
+
(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
91
|
return U.getJSON(PROXY + q + a.q, force ? 5000 : 30000, 65536, cancel || null, a.h);
|
|
92
92
|
});
|
|
93
93
|
}
|