stremiok 2.3.1 → 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 +33 -0
- package/README.md +10 -9
- package/config.xml +1 -1
- package/css/modern.css +1 -0
- package/css/style.css +7 -2
- package/index.html +39 -38
- package/js/app.js +21 -0
- package/js/jellyfin.js +267 -31
- 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/player-store.js +9 -4
- package/js/plex.js +63 -14
- package/js/stremio.js +2 -0
- package/js/util.js +11 -6
- package/js/view-core.js +28 -5
- package/js/view-detail.js +4 -4
- package/js/view-discover.js +6 -2
- package/js/view-home.js +22 -17
- package/js/view-settings.js +143 -9
- package/js/views.js +1 -1
- package/js/ytplay.js +1 -1
- package/package.json +3 -2
- package/service/index.js +353 -12
- package/tizenbrew.html +20 -0
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/player-store.js
CHANGED
|
@@ -11,10 +11,15 @@
|
|
|
11
11
|
var WATCHED_KEY = 'stremiok.watched';
|
|
12
12
|
function watchedAll() { return U.store.get(WATCHED_KEY, {}) || {}; }
|
|
13
13
|
// A mark made here: watched at (ms, > 0), or not watched at (−ms; false: an older "not
|
|
14
|
-
// watched", at 0). Trakt's history (when connected)
|
|
15
|
-
// watched here: watched; marked not watched here: watched only if
|
|
16
|
-
// since (on another device); no mark here: as
|
|
17
|
-
|
|
14
|
+
// watched", at 0). Trakt's history (when connected) and your media servers' marks are weighed
|
|
15
|
+
// against it by time: marked watched here: watched; marked not watched here: watched only if
|
|
16
|
+
// Trakt or a server has it watched since (on another device); no mark here: as they have it.
|
|
17
|
+
// null: none knows it.
|
|
18
|
+
function traktAt(type, id) {
|
|
19
|
+
var t = (typeof Trakt !== 'undefined' && Trakt.isConnected && Trakt.isConnected() && Trakt.watchedAt) ? Trakt.watchedAt(type, id) : 0;
|
|
20
|
+
var s = (typeof Jellyfin !== 'undefined' && Jellyfin.watchedAt) ? Jellyfin.watchedAt(type, id) : 0; // (Jellyfin, Emby and Plex: js/jellyfin.js)
|
|
21
|
+
return Math.max(t || 0, s || 0);
|
|
22
|
+
}
|
|
18
23
|
function watchedState(type, id) {
|
|
19
24
|
var v = watchedAll()[type + ':' + id], t = traktAt(type, id);
|
|
20
25
|
if (typeof v === 'number' && v > 0) { return true; }
|
package/js/plex.js
CHANGED
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
- Played as the file is (a part's own link: nothing converted), its SRT / VTT files with it;
|
|
14
14
|
what you play goes back to Plex (/:/timeline; watched: /:/scrobble), except during private
|
|
15
15
|
viewing. Sources carry _jf (kind 'plex'), as a Jellyfin one does: place, chapters, markers,
|
|
16
|
-
seek pictures.
|
|
16
|
+
seek pictures.
|
|
17
|
+
- Its watched marks (marksOf, kept with Jellyfin's and Emby's in js/jellyfin.js): films with a
|
|
18
|
+
viewCount, shows whose episodes are all watched, and each watched episode. */
|
|
17
19
|
var Plex = (function () {
|
|
18
20
|
'use strict';
|
|
19
21
|
|
|
@@ -32,11 +34,28 @@ var Plex = (function () {
|
|
|
32
34
|
function mc(r) { return (r && r.MediaContainer) || {}; } // (every Plex answer is in one)
|
|
33
35
|
|
|
34
36
|
// ---- Your servers ----
|
|
35
|
-
|
|
37
|
+
// (every one kept, on or off; servers: the ones on, as js/jellyfin.js)
|
|
38
|
+
function allServers() {
|
|
36
39
|
var l = U.store.get(KEY, []);
|
|
37
40
|
return Array.isArray(l) ? l.filter(function (s) { return s && s.id && s.url && s.token && s.machineId; }) : [];
|
|
38
41
|
}
|
|
42
|
+
function servers() { return allServers().filter(function (s) { return !s.off; }); }
|
|
39
43
|
function server(id) { return servers().filter(function (s) { return s.id === id; })[0] || null; }
|
|
44
|
+
function anyServer(id) { return allServers().filter(function (s) { return s.id === id; })[0] || null; }
|
|
45
|
+
function setOn(id, on) {
|
|
46
|
+
if (!anyServer(id)) { return; }
|
|
47
|
+
U.store.set(KEY, allServers().map(function (s) {
|
|
48
|
+
if (s.id !== id) { return s; }
|
|
49
|
+
var t = {};
|
|
50
|
+
Object.keys(s).forEach(function (k) { if (k !== 'off') { t[k] = s[k]; } });
|
|
51
|
+
if (!on) { t.off = true; }
|
|
52
|
+
return t;
|
|
53
|
+
}));
|
|
54
|
+
forget(id);
|
|
55
|
+
fillCatalogs();
|
|
56
|
+
if (on) { delete _libsAsked[id]; refreshLibs(true, id); }
|
|
57
|
+
changed();
|
|
58
|
+
}
|
|
40
59
|
function isEnabled() { return servers().length > 0; }
|
|
41
60
|
function deviceId() {
|
|
42
61
|
var d = U.store.get(DEV_KEY, '');
|
|
@@ -58,7 +77,7 @@ var Plex = (function () {
|
|
|
58
77
|
if (token) { h['X-Plex-Token'] = token; }
|
|
59
78
|
return h;
|
|
60
79
|
}
|
|
61
|
-
function get(srv, path, max) { return U.getJSON(srv.url + path, 20000, max || 4 * 1048576, null, headers(srv.token)); }
|
|
80
|
+
function get(srv, path, max) { return U.getJSON(srv.url + path, (typeof Jellyfin !== 'undefined' && Jellyfin.waitMs) ? Jellyfin.waitMs() : 20000, max || 4 * 1048576, null, headers(srv.token)); } // (Wait for a server)
|
|
62
81
|
function tell(srv, path) { return U.getText(srv.url + path, 15000, 65536, null, true, headers(srv.token)); }
|
|
63
82
|
function linkOf(srv, path) { return srv.url + path + (path.indexOf('?') === -1 ? '?' : '&') + 'X-Plex-Token=' + enc(srv.token); }
|
|
64
83
|
|
|
@@ -131,7 +150,7 @@ var Plex = (function () {
|
|
|
131
150
|
}).then(null, function (e) { tried.push(list[i]); U.log('plex', '“' + res.name + '” didn’t answer at ' + list[i] + ' (' + U.problem(e) + ')'); return next(i + 1); });
|
|
132
151
|
}
|
|
133
152
|
return next(0).then(function (url) {
|
|
134
|
-
var all =
|
|
153
|
+
var all = allServers(), old = all.filter(function (s) { return s.machineId === res.machineId; })[0];
|
|
135
154
|
var srv = { id: old ? old.id : 'p' + rand(8), kind: 'plex', url: url, machineId: res.machineId, name: res.name, version: res.version,
|
|
136
155
|
user: res.user, owned: res.owned, token: res.token, at: Date.now() };
|
|
137
156
|
all = all.filter(function (s) { return s !== old; });
|
|
@@ -143,8 +162,8 @@ var Plex = (function () {
|
|
|
143
162
|
});
|
|
144
163
|
}
|
|
145
164
|
function remove(id) {
|
|
146
|
-
if (!
|
|
147
|
-
U.store.set(KEY,
|
|
165
|
+
if (!anyServer(id)) { return; }
|
|
166
|
+
U.store.set(KEY, allServers().filter(function (s) { return s.id !== id; }));
|
|
148
167
|
var libs = libsAll();
|
|
149
168
|
delete libs[id];
|
|
150
169
|
U.store.set(LIBS_KEY, libs);
|
|
@@ -182,7 +201,7 @@ var Plex = (function () {
|
|
|
182
201
|
});
|
|
183
202
|
if (!server(srv.id)) { return; }
|
|
184
203
|
var all = libsAll(), keep = {}, before = JSON.stringify(all[srv.id] && all[srv.id].list);
|
|
185
|
-
|
|
204
|
+
allServers().forEach(function (s) { if (all[s.id]) { keep[s.id] = all[s.id]; } });
|
|
186
205
|
keep[srv.id] = { at: Date.now(), list: list };
|
|
187
206
|
_libs = keep;
|
|
188
207
|
U.store.set(LIBS_KEY, keep);
|
|
@@ -370,25 +389,55 @@ var Plex = (function () {
|
|
|
370
389
|
return U.listOf(mc(r).Metadata, 100000).map(function (it) { return { t: lib.type, it: it }; });
|
|
371
390
|
});
|
|
372
391
|
})).then(function (lists) {
|
|
373
|
-
var map = { __ids: {} };
|
|
392
|
+
var map = { __ids: {}, __tm: {}, __played: [] }; // (__played: its watched films and shows)
|
|
374
393
|
function add(k, v) { (map[k] = map[k] || []).push(v); }
|
|
375
394
|
flat(lists).forEach(function (e) {
|
|
376
|
-
var it = e.it, tt = imdbOf(it), tm = tmdbOf(it);
|
|
395
|
+
var it = e.it, tt = imdbOf(it), tm = tmdbOf(it), rk = '' + it.ratingKey;
|
|
377
396
|
if (it.ratingKey == null) { return; }
|
|
378
|
-
if (tt) { add(e.t + '|' + tt,
|
|
379
|
-
if (tm) { add(e.t + '|tmdb:' + tm,
|
|
397
|
+
if (tt) { add(e.t + '|' + tt, rk); map.__ids[rk] = tt; }
|
|
398
|
+
if (tm) { add(e.t + '|tmdb:' + tm, rk); map.__tm[rk] = tm; }
|
|
399
|
+
var played = e.t === 'movie' ? +it.viewCount > 0 : +it.leafCount > 0 && +it.viewedLeafCount >= +it.leafCount;
|
|
400
|
+
if (played) { map.__played.push({ t: e.t, ids: titleIds(map, (e.t === 'movie' ? 'pxm.' : 'pxs.') + srv.id + '.', rk), at: (+it.lastViewedAt || 0) * 1000 }); }
|
|
380
401
|
});
|
|
381
402
|
if (_index[srv.id] && _index[srv.id].p === p) { _index[srv.id] = { at: Date.now(), map: map }; }
|
|
382
403
|
return map;
|
|
383
404
|
}, function (e) {
|
|
384
405
|
U.log('plex', '“' + srv.name + '”: its titles couldn’t be read (' + U.problem(e) + ')');
|
|
385
|
-
var old = _index[srv.id], map = (old && old.map) || { __ids: {} };
|
|
406
|
+
var old = _index[srv.id], map = (old && old.map) || { __ids: {}, __tm: {}, __played: [], __err: true };
|
|
386
407
|
if (old && old.p === p) { _index[srv.id] = { at: Date.now() - INDEX_FRESH_MS + INDEX_RETRY_MS, map: map }; }
|
|
387
408
|
return map;
|
|
388
409
|
});
|
|
389
410
|
_index[srv.id] = { at: x ? x.at : 0, map: x ? x.map : null, p: p };
|
|
390
411
|
return x && x.map ? Promise.resolve(x.map) : p;
|
|
391
412
|
}
|
|
413
|
+
function indexFresh(srv) { var p = index(srv), x = _index[srv.id]; return x && x.p ? x.p : p; }
|
|
414
|
+
function titleIds(map, own, rk) {
|
|
415
|
+
var l = [own + rk];
|
|
416
|
+
if (map.__ids[rk]) { l.unshift(map.__ids[rk]); }
|
|
417
|
+
if (map.__tm[rk]) { l.push('tmdb:' + map.__tm[rk]); }
|
|
418
|
+
return l;
|
|
419
|
+
}
|
|
420
|
+
// ---- Watched marks ----
|
|
421
|
+
// Its watched films and shows (its list of titles), and the watched episodes of each Shows
|
|
422
|
+
// library (unwatched=0; a server that won't filter: all of them, the watched ones kept).
|
|
423
|
+
function watchedEpisodes(srv, lib) {
|
|
424
|
+
var path = '/library/sections/' + enc(lib.id) + '/all?type=4';
|
|
425
|
+
return get(srv, path + '&unwatched=0', 16 * 1048576).then(null, function () { return get(srv, path, 16 * 1048576); }).then(function (r) {
|
|
426
|
+
return U.listOf(mc(r).Metadata, 100000, function (e) { return +e.viewCount > 0 && e.grandparentRatingKey != null && e.parentIndex >= 0 && e.index >= 0; });
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
function marksOf(srv) {
|
|
430
|
+
var shows = libsOf(srv).filter(function (l) { return l.type === 'series'; });
|
|
431
|
+
if (!libsOf(srv).length) { return Promise.reject(new Error('its libraries aren’t read yet')); } // (not kept as "none": asked again)
|
|
432
|
+
return Promise.all([indexFresh(srv)].concat(shows.map(function (lib) { return watchedEpisodes(srv, lib); }))).then(function (r) {
|
|
433
|
+
var map = r[0], list = map.__played.slice(), sh = share();
|
|
434
|
+
if (map.__err || !sh || !sh.marksFrom) { throw new Error('its titles couldn’t be read'); }
|
|
435
|
+
flat(r.slice(1)).forEach(function (e) {
|
|
436
|
+
list.push({ t: 'series', ids: titleIds(map, 'pxs.' + srv.id + '.', '' + e.grandparentRatingKey), s: +e.parentIndex, e: +e.index, at: (+e.lastViewedAt || 0) * 1000 });
|
|
437
|
+
});
|
|
438
|
+
return sh.marksFrom(list);
|
|
439
|
+
});
|
|
440
|
+
}
|
|
392
441
|
function copies(type, id) {
|
|
393
442
|
var key = '', season = null, episode = null;
|
|
394
443
|
if (type === 'movie') { key = /^(tt\d+|tmdb:\d+)$/.test('' + id) ? '' + id : ''; }
|
|
@@ -523,8 +572,8 @@ var Plex = (function () {
|
|
|
523
572
|
}
|
|
524
573
|
|
|
525
574
|
return {
|
|
526
|
-
servers: servers, server: server, isEnabled: isEnabled, onChange: onChange, link: link, add: add, remove: remove, reload: reload,
|
|
575
|
+
servers: servers, allServers: allServers, server: server, setOn: setOn, isEnabled: isEnabled, onChange: onChange, link: link, add: add, remove: remove, reload: reload,
|
|
527
576
|
libraries: libsOf, synthAddon: synthAddon, synthAddons: synthAddons, catalog: catalog, meta: meta, streams: streams, isPlexId: isPlexId,
|
|
528
|
-
onPlayer: onPlayer, candidates: candidates
|
|
577
|
+
onPlayer: onPlayer, candidates: candidates, marksOf: marksOf
|
|
529
578
|
};
|
|
530
579
|
})();
|
package/js/stremio.js
CHANGED
|
@@ -169,6 +169,7 @@ var Stremio = (function () {
|
|
|
169
169
|
formatsAuto: p.formatsAuto !== false, // Settings > Formats: mark "Not working" on its own
|
|
170
170
|
allowLocal: p.allowLocal === true, // Settings > Addons: home-network links from internet addons
|
|
171
171
|
addonWait: ADDON_WAITS.indexOf(p.addonWait) !== -1 ? p.addonWait : 0, // Settings > Addons: seconds to wait for an addon (0: Normal)
|
|
172
|
+
serverWait: [45, 90, 180].indexOf(p.serverWait) !== -1 ? p.serverWait : 0, // Settings > Media servers: seconds to wait for one's answer (0: Normal, 20)
|
|
172
173
|
autoSkip: [5, 10, 15, 30].indexOf(p.autoSkip) !== -1 ? p.autoSkip : 0, // Settings > Skipping: intros / recaps after a countdown (0: ask)
|
|
173
174
|
autoNext: [5, 10, 15, 30].indexOf(p.autoNext) !== -1 ? p.autoNext : 0, // Settings > Skipping: the next episode at the credits after a countdown (0: ask)
|
|
174
175
|
spoilers: p.spoilers === 'pictures' || p.spoilers === 'all' ? p.spoilers : 'off', // Settings > Appearance: unwatched episodes' stills (and synopses) hidden
|
|
@@ -177,6 +178,7 @@ var Stremio = (function () {
|
|
|
177
178
|
nextOnFail: p.nextOnFail !== false, // Settings > Source ranking: a source that doesn't start gives way to the next
|
|
178
179
|
sizeLimits: { movie: sizeLimits(p.sizeLimits, 'movie'), series: sizeLimits(p.sizeLimits, 'series') }, // Settings > Source ranking (GB; 0: none)
|
|
179
180
|
posterRatings: p.posterRatings === true, // Settings > Appearance: IMDb rating on cards
|
|
181
|
+
watchedCards: p.watchedCards === 'dim' || p.watchedCards === 'hide' ? p.watchedCards : 'show', // Settings > Appearance: watched titles' cards ticked, dimmed too, or left out of rows
|
|
180
182
|
homePreview: p.homePreview !== false, // Settings > Home: Continue Watching on the TV's home bar (js/hubpreview.js)
|
|
181
183
|
homePreviewOrder: p.homePreviewOrder === 'watching' ? 'watching' : 'recent', // ...its tiles: the latest first, or as in Watching
|
|
182
184
|
hiddenTabs: wordList(p.hiddenTabs, 20, 20), // Settings > Home > Menu: tabs hidden
|
package/js/util.js
CHANGED
|
@@ -490,7 +490,8 @@ var U = (function () {
|
|
|
490
490
|
// the YouTube service's while it starts; the caller says so if it matters).
|
|
491
491
|
// headers (optional): { name: value } sent with it.
|
|
492
492
|
// body (optional): sent as a POST (text), else it's a GET.
|
|
493
|
-
|
|
493
|
+
// (bytes: the answer as a Uint8Array, not text: getBytes)
|
|
494
|
+
function getText(url, timeoutMs, maxBytes, cancel, quiet, headers, body, bytes) {
|
|
494
495
|
var priv = privateNow(); // (asked during a private playback: logged as one, however late it fails)
|
|
495
496
|
function logged(err) { return quiet ? err : noteNetwork(err, priv); }
|
|
496
497
|
maxBytes = maxBytes || TEXT_MAX;
|
|
@@ -510,12 +511,13 @@ var U = (function () {
|
|
|
510
511
|
}
|
|
511
512
|
try {
|
|
512
513
|
xhr.open(body == null ? 'GET' : 'POST', url, true);
|
|
514
|
+
if (bytes) { xhr.responseType = 'arraybuffer'; }
|
|
513
515
|
if (headers) { Object.keys(headers).forEach(function (h) { xhr.setRequestHeader(h, headers[h]); }); }
|
|
514
516
|
} catch (e) { reject(e); return; }
|
|
515
517
|
xhr.timeout = timeoutMs || 15000;
|
|
516
518
|
if (maxBytes) {
|
|
517
519
|
xhr.onprogress = function (ev) {
|
|
518
|
-
var got = (ev && ev.loaded) || ('' + (xhr.responseText || '')).length;
|
|
520
|
+
var got = (ev && ev.loaded) || (bytes ? 0 : ('' + (xhr.responseText || '')).length);
|
|
519
521
|
if (!done && got > maxBytes) {
|
|
520
522
|
done = true;
|
|
521
523
|
try { xhr.abort(); } catch (e2) {}
|
|
@@ -526,7 +528,7 @@ var U = (function () {
|
|
|
526
528
|
xhr.onreadystatechange = function () {
|
|
527
529
|
if (xhr.readyState !== 4 || done) { return; }
|
|
528
530
|
done = true;
|
|
529
|
-
var body = xhr.responseText;
|
|
531
|
+
var body = bytes ? (xhr.response ? new Uint8Array(xhr.response) : null) : xhr.responseText;
|
|
530
532
|
if (body && body.length > maxBytes) { reject(logged(new Error('Too large (over ' + mb(maxBytes) + '): ' + redactUrl(url)))); return; } // (no progress events)
|
|
531
533
|
var landed = xhr.responseURL; // where the redirects (if any) ended
|
|
532
534
|
if (landed && landed !== url && urlIsPrivate(landed) && !urlIsPrivate(url) && !_localOk()) {
|
|
@@ -541,7 +543,7 @@ var U = (function () {
|
|
|
541
543
|
if (xhr.status >= 200 && xhr.status < 300) { resolve(body); }
|
|
542
544
|
else {
|
|
543
545
|
var err = new Error('HTTP ' + xhr.status + ' for ' + redactUrl(url));
|
|
544
|
-
var said = serverMessage(body);
|
|
546
|
+
var said = bytes ? '' : serverMessage(body);
|
|
545
547
|
if (said) { err.serverMessage = said; err.message += ': ' + said; }
|
|
546
548
|
reject(logged(err));
|
|
547
549
|
}
|
|
@@ -552,6 +554,9 @@ var U = (function () {
|
|
|
552
554
|
});
|
|
553
555
|
}
|
|
554
556
|
|
|
557
|
+
// A file's bytes (a Uint8Array), up to maxBytes: Emby's seek pictures (js/jellyfin.js).
|
|
558
|
+
function getBytes(url, timeoutMs, maxBytes, quiet) { return getText(url, timeoutMs || 30000, maxBytes, null, quiet, null, null, true); }
|
|
559
|
+
|
|
555
560
|
// No answer at all: the connection refused or dropped, blocked, a certificate the TV doesn't
|
|
556
561
|
// trust (its browser says only "status 0").
|
|
557
562
|
function noAnswer(url) { return new Error('No answer (connection refused, blocked or certificate): ' + redactUrl(url)); }
|
|
@@ -704,7 +709,7 @@ var U = (function () {
|
|
|
704
709
|
var LEFTOVER_SHARE = 0.5, _busy = null, _refusalTidy = false;
|
|
705
710
|
// Use the TV's database (Settings › Diagnostics › Storage; on unless turned off):
|
|
706
711
|
// off, the big copies are kept in the settings storage (BIG_KEY: the ones that go here).
|
|
707
|
-
var USE_KEY = 'stremiok.bigdb', BIG_KEY = /^stremiok\.(homecache|local\.index|iptv\.cache\.|trakt\.watched)/;
|
|
712
|
+
var USE_KEY = 'stremiok.bigdb', BIG_KEY = /^stremiok\.(homecache|local\.index|iptv\.cache\.|trakt\.watched|media\.watched)/;
|
|
708
713
|
function enabled() { return store.get(USE_KEY, true) !== false; }
|
|
709
714
|
function lsBigKeys() {
|
|
710
715
|
var out = [];
|
|
@@ -1677,7 +1682,7 @@ var U = (function () {
|
|
|
1677
1682
|
}
|
|
1678
1683
|
|
|
1679
1684
|
return {
|
|
1680
|
-
byId: byId, el: el, clear: clear, moveIn: moveIn, getJSON: getJSON, getText: getText,
|
|
1685
|
+
byId: byId, el: el, clear: clear, moveIn: moveIn, getJSON: getJSON, getText: getText, getBytes: getBytes,
|
|
1681
1686
|
postJSON: postJSON, redactUrl: redactUrl, problem: problem, problemDetail: problemDetail, listOf: listOf, lru: lru, randomHex: randomHex, cachedJSON: cachedJSON,
|
|
1682
1687
|
parseUrl: parseUrl, urlProblem: urlProblem, isPlaylistUrl: isPlaylistUrl, isManifestUrl: isManifestUrl,
|
|
1683
1688
|
isPrivateHost: isPrivateHost, urlIsPrivate: urlIsPrivate, setLocalPolicy: setLocalPolicy, sanitizeHeaders: sanitizeHeaders, drawable: drawable,
|
package/js/view-core.js
CHANGED
|
@@ -645,7 +645,8 @@ var ViewParts = {};
|
|
|
645
645
|
c.appendChild(U.el('div', 'cap', meta.name || meta.title || ''));
|
|
646
646
|
c.__meta = meta; // shown above the rows on Home while focused
|
|
647
647
|
var kind = meta.type || fallbackType;
|
|
648
|
-
|
|
648
|
+
c.__kind = kind;
|
|
649
|
+
if ((kind === 'movie' || kind === 'series') && meta.id && Player.isWatched(kind, meta.id)) { markCard(c, true); }
|
|
649
650
|
var rating = parseFloat(meta.imdbRating); // (Ratings on posters: the catalog's own, nothing downloaded)
|
|
650
651
|
if (rating > 0 && rating <= 10 && Stremio.getPrefs().posterRatings) { c.appendChild(U.el('div', 'card-rating', '★ ' + rating.toFixed(1))); } // (a series: marked watched whole, see setTitleWatched / the title page)
|
|
651
652
|
if (kind === 'movie' || kind === 'series') { c.__onlongpress = function () { posterActions(meta, kind, c); }; }
|
|
@@ -871,12 +872,34 @@ var ViewParts = {};
|
|
|
871
872
|
function watchedTicks(id, on) {
|
|
872
873
|
var cards = document.querySelectorAll('.card');
|
|
873
874
|
for (var i = 0; i < cards.length; i++) {
|
|
874
|
-
if (cards[i].getAttribute('data-id')
|
|
875
|
-
var badge = cards[i].querySelector('.card-watched');
|
|
876
|
-
if (on && !badge) { cards[i].appendChild(U.el('div', 'card-watched', '✓')); }
|
|
877
|
-
if (!on && badge) { cards[i].removeChild(badge); }
|
|
875
|
+
if (cards[i].getAttribute('data-id') === id) { markCard(cards[i], on); }
|
|
878
876
|
}
|
|
879
877
|
}
|
|
878
|
+
// A card watched or not: its ✓, and dimmed too with Settings › Appearance › Watched titles: Dim.
|
|
879
|
+
function markCard(card, on) {
|
|
880
|
+
var badge = card.querySelector('.card-watched'), dim = on && Stremio.getPrefs().watchedCards === 'dim';
|
|
881
|
+
if (on && !badge) { card.appendChild(U.el('div', 'card-watched', '✓')); }
|
|
882
|
+
if (!on && badge) { card.removeChild(badge); }
|
|
883
|
+
var cls = ('' + card.className).replace(/\s*\bwatched-dim\b/g, '');
|
|
884
|
+
card.className = dim ? cls + ' watched-dim' : cls;
|
|
885
|
+
}
|
|
886
|
+
// Marks that came from elsewhere (your media servers): every movie or series card on screen
|
|
887
|
+
// as it now is; Home's other tabs rebuilt when next opened.
|
|
888
|
+
function watchedChanged() {
|
|
889
|
+
var cards = document.querySelectorAll('.card');
|
|
890
|
+
for (var i = 0; i < cards.length; i++) {
|
|
891
|
+
var m = cards[i].__meta, k = cards[i].__kind;
|
|
892
|
+
if (m && m.id && (k === 'movie' || k === 'series')) { markCard(cards[i], Player.isWatched(k, m.id)); }
|
|
893
|
+
}
|
|
894
|
+
markHomeDirty();
|
|
895
|
+
}
|
|
896
|
+
V.watchedChanged = watchedChanged;
|
|
897
|
+
// Left out of Home's and Discover's rows (Settings › Appearance › Watched titles: Hide).
|
|
898
|
+
function watchedHidden(meta, type) {
|
|
899
|
+
var k = (meta && meta.type) || type;
|
|
900
|
+
return Stremio.getPrefs().watchedCards === 'hide' && !!meta && !!meta.id && (k === 'movie' || k === 'series') && Player.isWatched(k, meta.id);
|
|
901
|
+
}
|
|
902
|
+
V.watchedHidden = watchedHidden;
|
|
880
903
|
|
|
881
904
|
// ----- Add to Continue Watching -----
|
|
882
905
|
// Lists a title in Continue Watching without playing it:
|
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-discover.js
CHANGED
|
@@ -309,7 +309,7 @@
|
|
|
309
309
|
function startLoad() {
|
|
310
310
|
leaveDiscover();
|
|
311
311
|
_dvCancel = U.cancelToken ? U.cancelToken() : null;
|
|
312
|
-
_dv.items = []; _dv.seen = {}; _dv.done = false; _dv.error = false; _dv.loading = false; _dv.offset = 0; _dv.page = 0; _dv.stale = false;
|
|
312
|
+
_dv.items = []; _dv.seen = {}; _dv.hidden = 0; _dv.done = false; _dv.error = false; _dv.loading = false; _dv.offset = 0; _dv.page = 0; _dv.stale = false;
|
|
313
313
|
_dv.gen++; _dv.focusFirst = true;
|
|
314
314
|
drawGrid();
|
|
315
315
|
loadMore();
|
|
@@ -472,6 +472,10 @@
|
|
|
472
472
|
});
|
|
473
473
|
}
|
|
474
474
|
function gotItems(fresh) {
|
|
475
|
+
var all = fresh.length;
|
|
476
|
+
fresh = fresh.filter(function (m) { return !V.watchedHidden(m, _dv.cat && _dv.cat.type); }); // (Settings › Appearance › Watched titles: Hide)
|
|
477
|
+
_dv.hidden = (_dv.hidden || 0) + all - fresh.length;
|
|
478
|
+
if (all && !fresh.length && !_dv.items.length && !_dv.done) { var g = _dv.gen; setTimeout(function () { if (g === _dv.gen) { loadMore(); } }, 0); return; } // (a first page all watched: the next one)
|
|
475
479
|
var reachesEnd = (_dv.offset + _dv.cardEls.length === _dv.items.length); // (else they join as you scroll down, extendDown)
|
|
476
480
|
_dv.items = _dv.items.concat(fresh);
|
|
477
481
|
if (reachesEnd) { appendCards(fresh); }
|
|
@@ -519,7 +523,7 @@
|
|
|
519
523
|
if (_dv.value && genre) { extra.genre = _dv.value; }
|
|
520
524
|
if (_dv.items.length || (cat.addon && cat.addon.__local)) {
|
|
521
525
|
if (_dv.items.length && !pages(cat)) { _dv.done = true; updateCount(); return; }
|
|
522
|
-
extra.skip = _dv.items.length;
|
|
526
|
+
extra.skip = _dv.items.length + (_dv.hidden || 0); // (the watched ones left out counted: Watched titles: Hide)
|
|
523
527
|
}
|
|
524
528
|
_dv.loading = true;
|
|
525
529
|
updateCount();
|