stremiok 2.2.8 → 2.3.0
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 +1 -0
- package/config.xml +1 -1
- package/css/modern.css +146 -0
- package/css/style.css +17 -5
- package/index.html +39 -36
- package/js/focus.js +13 -2
- package/js/jellyfin.js +642 -0
- package/js/player-controls.js +29 -1
- package/js/player-core.js +78 -6
- package/js/player-store.js +2 -1
- package/js/plex.js +530 -0
- package/js/stremio.js +45 -6
- package/js/stvod.js +7 -2
- package/js/util.js +61 -8
- package/js/view-core.js +6 -2
- package/js/view-detail.js +35 -8
- package/js/view-discover.js +10 -5
- package/js/view-home.js +74 -7
- package/js/view-settings.js +197 -6
- package/js/ytplay.js +1 -1
- package/package.json +1 -1
- package/service/index.js +48 -14
package/js/stvod.js
CHANGED
|
@@ -27,10 +27,15 @@ var StVod = (function () {
|
|
|
27
27
|
for (var i = 0; i < l.length; i++) { if (l[i].id === id) { return l[i]; } }
|
|
28
28
|
return null;
|
|
29
29
|
}
|
|
30
|
+
// How long the service keeps what it read of a portal (Settings › Content › IPTV › Stalker films
|
|
31
|
+
// and series): 10 minutes, 5, or 0 (not kept).
|
|
32
|
+
var KEEP_KEY = 'stremiok.iptv.stalkerkeep', KEEPS = [10, 5, 0];
|
|
33
|
+
function keepMinutes() { var m = U.store.get(KEEP_KEY, 10); return KEEPS.indexOf(m) !== -1 ? m : 10; }
|
|
34
|
+
function setKeepMinutes(m) { U.store.set(KEEP_KEY, KEEPS.indexOf(+m) !== -1 ? +m : 10); }
|
|
30
35
|
// The service's answer ({ why }: an error).
|
|
31
36
|
function ask(acc, more) {
|
|
32
37
|
if (typeof YTPlay === 'undefined' || !YTPlay.stalkerVod) { return Promise.reject(new Error('Stalker portals are read by StremioK’s service (not in a desktop browser)')); }
|
|
33
|
-
return YTPlay.stalkerVod(acc.url, acc.mac, more).then(function (r) {
|
|
38
|
+
return YTPlay.stalkerVod(acc.url, acc.mac, more + '&keep=' + keepMinutes()).then(function (r) {
|
|
34
39
|
if (!r || r.why) { throw new Error((r && r.why) || 'no answer'); }
|
|
35
40
|
return r;
|
|
36
41
|
});
|
|
@@ -285,5 +290,5 @@ var StVod = (function () {
|
|
|
285
290
|
})).then(function (all) { return [].concat.apply([], all).filter(Boolean); });
|
|
286
291
|
}
|
|
287
292
|
|
|
288
|
-
return { accounts: accounts, isEnabled: isEnabled, onChange: onChange, reload: reload, synthAddon: synthAddon, catalog: catalog, meta: meta, streams: streams, refreshCats: refreshCats };
|
|
293
|
+
return { accounts: accounts, keepMinutes: keepMinutes, setKeepMinutes: setKeepMinutes, isEnabled: isEnabled, onChange: onChange, reload: reload, synthAddon: synthAddon, catalog: catalog, meta: meta, streams: streams, refreshCats: refreshCats };
|
|
289
294
|
})();
|
package/js/util.js
CHANGED
|
@@ -21,7 +21,7 @@ var U = (function () {
|
|
|
21
21
|
are read %-decoded (%70assword is password), and a #fragment is masked the same way
|
|
22
22
|
(name=value pairs, or one token). Scheme, host, port and the rest of the path stay
|
|
23
23
|
readable. */
|
|
24
|
-
var SECRET_PARAM = /^(pass(word)?|pwd|passwd|user(name)?|login|token|access_token|refresh_token|auth(orization)?|key|apikey|api_key|api-key|secret|client_secret|sig|signature|session|sid|hash|mac)$/i;
|
|
24
|
+
var SECRET_PARAM = /^(pass(word)?|pwd|passwd|user(name)?|login|token|access_token|refresh_token|auth(orization)?|key|apikey|api_key|api-key|secret|client_secret|sig|signature|session|sid|hash|mac|x-plex-token)$/i;
|
|
25
25
|
function looksLikeToken(seg) {
|
|
26
26
|
if (seg.length < 20 || !/^[A-Za-z0-9._~+=%-]+$/.test(seg)) { return false; }
|
|
27
27
|
if (/%3A%2F%2F/i.test(seg)) { return false; } // an encoded URL (a YouTube page for the service), not a token
|
|
@@ -603,6 +603,25 @@ var U = (function () {
|
|
|
603
603
|
});
|
|
604
604
|
}
|
|
605
605
|
|
|
606
|
+
/* n random hex digits, for ids sent to servers (a device id, a playback session's): the TV's
|
|
607
|
+
secure random numbers (crypto.getRandomValues); without them (tests), a generator seeded
|
|
608
|
+
by the clock and a count, so two ids still differ. */
|
|
609
|
+
var _randSeed = 0;
|
|
610
|
+
function randomHex(n) {
|
|
611
|
+
var out = '', bytes = null, i;
|
|
612
|
+
try {
|
|
613
|
+
var c = typeof crypto !== 'undefined' ? crypto : (typeof window !== 'undefined' ? window.crypto : null);
|
|
614
|
+
if (c && c.getRandomValues) { bytes = new Uint8Array(Math.ceil(n / 2)); c.getRandomValues(bytes); }
|
|
615
|
+
} catch (e) { bytes = null; }
|
|
616
|
+
if (!bytes) {
|
|
617
|
+
bytes = [];
|
|
618
|
+
var x = ((Date.now() % 2147483647) ^ (++_randSeed * 2654435761)) >>> 0 || 1;
|
|
619
|
+
for (i = 0; i < Math.ceil(n / 2); i++) { x ^= x << 13; x ^= x >>> 17; x ^= x << 5; x >>>= 0; bytes.push(x & 255); }
|
|
620
|
+
}
|
|
621
|
+
for (i = 0; i < bytes.length; i++) { out += (bytes[i] < 16 ? '0' : '') + bytes[i].toString(16); }
|
|
622
|
+
return out.slice(0, n);
|
|
623
|
+
}
|
|
624
|
+
|
|
606
625
|
/* A small most-recently-used cache: keeps the last `max` entries. The TV keeps the
|
|
607
626
|
app running for days, so session caches must not grow without limit. */
|
|
608
627
|
function lru(max) {
|
|
@@ -1115,8 +1134,9 @@ var U = (function () {
|
|
|
1115
1134
|
function showOn(item) { // the image is in the browser now: put it on this node
|
|
1116
1135
|
if (item.bg) { item.img.style.backgroundImage = cssUrl(item.src); } else { item.img.src = item.src; }
|
|
1117
1136
|
}
|
|
1118
|
-
function failOn(item) { // it can't load: this node's own fallback
|
|
1119
|
-
|
|
1137
|
+
function failOn(item) { // it can't load: this node's own fallback (a background's: its __bgFail)
|
|
1138
|
+
var f = item.bg ? item.img.__bgFail : item.img.onerror;
|
|
1139
|
+
if (typeof f === 'function') { try { f.call(item.img); } catch (e) {} }
|
|
1120
1140
|
}
|
|
1121
1141
|
// A download that neither loads nor fails (a stalled host) gives up after this, so a
|
|
1122
1142
|
// few of them can't hold every slot and stop all later artwork.
|
|
@@ -1243,7 +1263,7 @@ var U = (function () {
|
|
|
1243
1263
|
function done(ok) {
|
|
1244
1264
|
if (finished) { return; }
|
|
1245
1265
|
stop();
|
|
1246
|
-
if (ok) { markLoaded(it.src); if (it.bg) { showOn(it); } } else { _failedAt.set(it.src, Date.now()); }
|
|
1266
|
+
if (ok) { markLoaded(it.src); if (it.bg) { showOn(it); } } else { _failedAt.set(it.src, Date.now()); if (it.bg) { failOn(it); } }
|
|
1247
1267
|
var waiting = _inflight[it.src] || [];
|
|
1248
1268
|
delete _inflight[it.src];
|
|
1249
1269
|
waiting.forEach(function (w) { if (ok) { showOn(w); } else { failOn(w); } });
|
|
@@ -1307,6 +1327,16 @@ var U = (function () {
|
|
|
1307
1327
|
// role: 'poster' | 'landscape' | 'still' (episode thumbnail) | 'hero' (a title page's
|
|
1308
1328
|
// backdrop) | 'logo' | 'cast' (a cast card) | 'profile' (a person page's photo)
|
|
1309
1329
|
var TMDB_W = { poster: 342, landscape: 780, still: 300, hero: 1280, logo: 500, cast: 185, profile: 342 };
|
|
1330
|
+
// A backdrop behind a page (the Modern look's Home, a title's page): its pictures to try, the
|
|
1331
|
+
// best first. A YouTube video's thumbnail (hqdefault: 480x360, bars above and below) gives
|
|
1332
|
+
// way to its 1280x720 ones (maxresdefault, else hq720; an older video may have neither, so
|
|
1333
|
+
// the thumbnail last). Anything else: its 'hero' size.
|
|
1334
|
+
function heroImages(url) {
|
|
1335
|
+
var yt = typeof url === 'string' && url.match(/^(https:\/\/i\.ytimg\.com\/vi\/[\w-]{6,20}\/)(?:hq|mq|sd)?default\.jpg$/);
|
|
1336
|
+
if (yt) { return [yt[1] + 'maxresdefault.jpg', yt[1] + 'hq720.jpg', url]; }
|
|
1337
|
+
var one = cardImage(url, 'hero');
|
|
1338
|
+
return one ? [one] : [];
|
|
1339
|
+
}
|
|
1310
1340
|
function cardImage(url, role) {
|
|
1311
1341
|
if (!url || typeof url !== 'string') { return null; }
|
|
1312
1342
|
if (/^\/\//.test(url)) { url = 'https:' + url; } // (a scheme-relative link)
|
|
@@ -1410,7 +1440,7 @@ var U = (function () {
|
|
|
1410
1440
|
[[255, 210, 87], [138, 90, 0]] // gold ratings
|
|
1411
1441
|
];
|
|
1412
1442
|
// Drawn over video or pictures: keep their own (light-on-dark) look.
|
|
1413
|
-
var KEEP_DARK = /#osd|#player-|#subs|#sub-menu|#skip-prompt|#stream-info|#cast-strip|#yt-links|#yt-card|#toast|#hold-hint|#spinner|\.skip-btn|\.pb-btn|\.sm-|\.si-|\.card \.cap|\.card-new|\.card-watched|\.card-rating|\.grid-cell|\.r-|\.spin\b/;
|
|
1443
|
+
var KEEP_DARK = /#osd|#player-|#subs|#sub-menu|#skip-prompt|#stream-info|#cast-strip|#yt-links|#yt-card|#toast|#hold-hint|#spinner|\.skip-btn|\.pb-btn|\.sm-|\.si-|\.card \.cap|\.card-new|\.card-watched|\.card-rating|\.card-epg|\.grid-cell|\.r-|\.spin\b/;
|
|
1414
1444
|
var LIGHT_EXTRA = '.card .cap { color: #ffffff }\n' +
|
|
1415
1445
|
// title logos are made for dark backgrounds: a soft dark outline keeps them readable
|
|
1416
1446
|
'.detail-logo, .home-info-logo { -webkit-filter: drop-shadow(0 0 2px rgba(0,0,0,0.85)) drop-shadow(0 0 6px rgba(0,0,0,0.45)); ' +
|
|
@@ -1430,6 +1460,26 @@ var U = (function () {
|
|
|
1430
1460
|
s.height = on ? Math.ceil(1080 / _zoom) + 'px' : '';
|
|
1431
1461
|
s.webkitTransform = s.transform = on ? 'scale(' + _zoom + ')' : '';
|
|
1432
1462
|
s.webkitTransformOrigin = s.transformOrigin = on ? '0 0' : '';
|
|
1463
|
+
var cl = document.body.classList; // (zoom-110 … zoom-140: the Modern look's room for each, css/modern.css)
|
|
1464
|
+
if (cl) { [110, 120, 130, 140].forEach(function (z) { cl.remove('zoom-' + z); }); if (on) { cl.add('zoom-' + Math.round(_zoom * 100)); } }
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
// Look (Settings › Appearance): 'modern' puts look-modern on the page (css/modern.css), and
|
|
1468
|
+
// fx-full for its blur and motion: 'auto' where the TV's browser can blur what's behind a
|
|
1469
|
+
// panel (Tizen 6, 2021 TVs, and later), so not on older ones, where they'd slow it down.
|
|
1470
|
+
function canBlur() {
|
|
1471
|
+
try { return !!(window.CSS && CSS.supports && (CSS.supports('backdrop-filter', 'blur(2px)') || CSS.supports('-webkit-backdrop-filter', 'blur(2px)'))); } catch (e) { return false; }
|
|
1472
|
+
}
|
|
1473
|
+
var _look = 'classic';
|
|
1474
|
+
function look() { return _look; }
|
|
1475
|
+
function setLook(lk, fx, light) { // (light: Light Gray or White, bg-light: css/modern.css's fills for them)
|
|
1476
|
+
_look = lk === 'modern' ? 'modern' : 'classic';
|
|
1477
|
+
var b = document.body;
|
|
1478
|
+
if (!b || !b.classList) { return; }
|
|
1479
|
+
var full = _look === 'modern' && (fx === 'full' || (fx !== 'light' && canBlur()));
|
|
1480
|
+
b.classList[_look === 'modern' ? 'add' : 'remove']('look-modern');
|
|
1481
|
+
b.classList[full ? 'add' : 'remove']('fx-full');
|
|
1482
|
+
b.classList[light ? 'add' : 'remove']('bg-light');
|
|
1433
1483
|
}
|
|
1434
1484
|
|
|
1435
1485
|
// bg: 'dark' (the stylesheet's own), 'black', 'gray' or 'white' (the last two with dark text)
|
|
@@ -1444,7 +1494,10 @@ var U = (function () {
|
|
|
1444
1494
|
if (light) {
|
|
1445
1495
|
pairs.push([THEME_BASE.bg, light.page, 'bg'], [[22, 27, 38], light.panel, 'bg'], [[26, 31, 43], light.card, 'bg'],
|
|
1446
1496
|
[[42, 51, 70], light.raised, 'bg'], [[38, 48, 74], light.raised, 'bg'], [[23, 32, 58], light.deep, 'bg'],
|
|
1447
|
-
[[58, 33, 48], [243, 214, 220], 'bg'], [[255, 255, 255], [17, 17, 17], 'color']
|
|
1497
|
+
[[58, 33, 48], [243, 214, 220], 'bg'], [[255, 255, 255], [17, 17, 17], 'color'],
|
|
1498
|
+
// the Guide: its channel column, the strip behind the programs (the lines
|
|
1499
|
+
// between them), the program on now
|
|
1500
|
+
[[18, 23, 34], light.deep, 'bg'], [[14, 18, 25], light.page, 'bg'], [[34, 43, 61], light.raised, 'bg']);
|
|
1448
1501
|
LIGHT_TEXT.forEach(function (t) { pairs.push([t[0], t[1], 'text']); });
|
|
1449
1502
|
}
|
|
1450
1503
|
var el = byId('theme-override');
|
|
@@ -1625,10 +1678,10 @@ var U = (function () {
|
|
|
1625
1678
|
|
|
1626
1679
|
return {
|
|
1627
1680
|
byId: byId, el: el, clear: clear, moveIn: moveIn, getJSON: getJSON, getText: getText,
|
|
1628
|
-
postJSON: postJSON, redactUrl: redactUrl, problem: problem, problemDetail: problemDetail, listOf: listOf, lru: lru, cachedJSON: cachedJSON,
|
|
1681
|
+
postJSON: postJSON, redactUrl: redactUrl, problem: problem, problemDetail: problemDetail, listOf: listOf, lru: lru, randomHex: randomHex, cachedJSON: cachedJSON,
|
|
1629
1682
|
parseUrl: parseUrl, urlProblem: urlProblem, isPlaylistUrl: isPlaylistUrl, isManifestUrl: isManifestUrl,
|
|
1630
1683
|
isPrivateHost: isPrivateHost, urlIsPrivate: urlIsPrivate, setLocalPolicy: setLocalPolicy, sanitizeHeaders: sanitizeHeaders, drawable: drawable,
|
|
1631
|
-
log: log, logEntries: logEntries, clearLog: clearLog, bigStore: bigStore, diskInfo: diskInfo,
|
|
1684
|
+
look: look, setLook: setLook, canBlur: canBlur, heroImages: heroImages, log: log, logEntries: logEntries, clearLog: clearLog, bigStore: bigStore, diskInfo: diskInfo,
|
|
1632
1685
|
store: store, toast: toast, spinner: spinner,
|
|
1633
1686
|
deferImage: deferImage, deferBg: deferBg, cardImage: cardImage, prioritizeImages: prioritizeImages, requeueImages: requeueImages,
|
|
1634
1687
|
fmtTime: fmtTime, dayLabel: dayLabel, settleAll: settleAll, cancelToken: cancelToken, isHidden: isHidden, whenVisible: whenVisible, crumb: crumb, sessionStart: sessionStart, sessionState: sessionState, mark: mark, startupMarks: startupMarks, loadScript: loadScript, qrModules: qrModules, qrCanvas: qrCanvas, qrScale: qrScale,
|
package/js/view-core.js
CHANGED
|
@@ -656,7 +656,9 @@ var ViewParts = {};
|
|
|
656
656
|
}
|
|
657
657
|
function isLive() {
|
|
658
658
|
var t = titleType(meta.type || fallbackType);
|
|
659
|
-
|
|
659
|
+
// (an "anime" or "other" item: a title whatever its id; a debrid library's download, an
|
|
660
|
+
// addon's own "cnc:…" show: its page, so its episodes or files, not a channel's sources)
|
|
661
|
+
var isTitle = t === 'movie' || t === 'series' || TITLE_ID.test(meta.id || '') || /^(anime|other)$/i.test(t || '');
|
|
660
662
|
return !!fallbackType && fallbackType !== 'movie' && fallbackType !== 'series' && !isTitle && !/^(youtube|channel)$/i.test(fallbackType) && !/^(ytk|yt_id):/.test(meta.id || '');
|
|
661
663
|
}
|
|
662
664
|
c.__onselect = function () {
|
|
@@ -670,11 +672,13 @@ var ViewParts = {};
|
|
|
670
672
|
if (isLive()) {
|
|
671
673
|
App.openLive(t, meta.id, meta, rowChannels(c));
|
|
672
674
|
} else {
|
|
673
|
-
App.openDetail(t, meta.id, meta);
|
|
675
|
+
App.openDetail(t, meta.id, meta, t === 'series' && meta._openEp ? meta._openEp : null); // (Jellyfin's Next up: at that episode)
|
|
674
676
|
}
|
|
675
677
|
};
|
|
676
678
|
// the remote's Play key: a movie's or channel's top source; a series has no one episode, so its page
|
|
679
|
+
// (one with an episode of its own, Jellyfin's Next up: that episode's top source)
|
|
677
680
|
if (titleType(kind) === 'movie') { c.__onplay = function () { App.openDetail('movie', meta.id, meta, null, { playBest: true }); }; }
|
|
681
|
+
else if (titleType(kind) === 'series' && meta._openEp) { c.__onplay = function () { App.openDetail('series', meta.id, meta, meta._openEp, { playBest: true }); }; }
|
|
678
682
|
else if (titleType(kind) === 'series') { c.__onplay = function () { c.__onselect(); }; }
|
|
679
683
|
else if (fallbackType !== 'local' && isLive()) { c.__onplay = function () { App.openLive(titleType(kind), meta.id, meta, rowChannels(c), { playBest: true }); }; } // (a channel)
|
|
680
684
|
return c;
|
package/js/view-detail.js
CHANGED
|
@@ -257,7 +257,14 @@
|
|
|
257
257
|
var listed = _d.mode === 'streams' || (_d.mode === 'info' && _d.type === 'series'); // (a source list, an episode list)
|
|
258
258
|
var hero = U.el('div', 'detail-hero' + (listed ? ' hero-full' : '')); // (a list: over the whole backdrop)
|
|
259
259
|
var bg = meta.background || meta.poster;
|
|
260
|
-
|
|
260
|
+
// (sized for the page, first in the queue; one that doesn't load: the next of its
|
|
261
|
+
// pictures, a YouTube video's 1280x720 ones first: U.heroImages)
|
|
262
|
+
var heroes = bg ? U.heroImages(bg) : [];
|
|
263
|
+
(function heroTry(i) {
|
|
264
|
+
if (i >= heroes.length) { return; }
|
|
265
|
+
hero.__bgFail = function () { heroTry(i + 1); };
|
|
266
|
+
U.deferBg(hero, heroes[i], true);
|
|
267
|
+
})(0);
|
|
261
268
|
hero.appendChild(U.el('div', 'shade'));
|
|
262
269
|
s.appendChild(hero);
|
|
263
270
|
s.appendChild(buildTopMenu('detail')); // the main menu, above the title
|
|
@@ -1276,6 +1283,13 @@
|
|
|
1276
1283
|
var hide = spoilerFor(v); // (Hide spoilers: an episode not watched yet)
|
|
1277
1284
|
var thumb = U.el('div', 'ep-thumb' + (hide ? ' spoiler' : ''));
|
|
1278
1285
|
// through the poster queue: a season's thumbnails don't all download at once
|
|
1286
|
+
var ref = { num: v.episode, thumb: thumb, hasThumb: !!v.thumbnail, hideOv: hide === 'all', still: null };
|
|
1287
|
+
// (the addon's picture doesn't load, now or earlier: TMDB's, with a key, once known; see below)
|
|
1288
|
+
thumb.__bgFail = function () {
|
|
1289
|
+
thumb.__bgFail = null; // (once: TMDB's failing too is the end of it)
|
|
1290
|
+
ref.hasThumb = false;
|
|
1291
|
+
if (ref.still) { ref.hasThumb = true; U.deferBg(thumb, U.cardImage(ref.still, 'still')); }
|
|
1292
|
+
};
|
|
1279
1293
|
if (v.thumbnail) { U.deferBg(thumb, U.cardImage(v.thumbnail, 'still')); }
|
|
1280
1294
|
var pr = !watched && Player.progressFor(_d.collection ? 'movie' : 'series', v.id);
|
|
1281
1295
|
if (pr && pr.duration && pr.position > 0) { // partly watched: progress stripe
|
|
@@ -1309,7 +1323,8 @@
|
|
|
1309
1323
|
e.__onlongpress = function () { if (_d.collection) { collectionMenu(meta, v); } else { episodeMenu(meta, v); } };
|
|
1310
1324
|
if (_d.target && v.id === _d.target) { _d._epFocus = e; }
|
|
1311
1325
|
listScroll.appendChild(e);
|
|
1312
|
-
|
|
1326
|
+
ref.rating = rating; ref.ov = ov;
|
|
1327
|
+
epRefs.push(ref);
|
|
1313
1328
|
});
|
|
1314
1329
|
panel.appendChild(listScroll);
|
|
1315
1330
|
|
|
@@ -1336,6 +1351,7 @@
|
|
|
1336
1351
|
epRefs.forEach(function (r) {
|
|
1337
1352
|
var ep = map[r.num];
|
|
1338
1353
|
if (!ep) { return; }
|
|
1354
|
+
if (ep.still) { r.still = ep.still; } // (kept: for the addon's picture, should it fail)
|
|
1339
1355
|
if (ep.still && !r.hasThumb) { r.hasThumb = true; U.deferBg(r.thumb, U.cardImage(ep.still, 'still')); }
|
|
1340
1356
|
// Fill the rating only if OMDb didn't provide one for this episode
|
|
1341
1357
|
// (OMDb's dataset is missing IMDb ratings for some episodes).
|
|
@@ -1417,8 +1433,8 @@
|
|
|
1417
1433
|
// then ones with a format marked "not working" on this TV (Settings > Formats), then
|
|
1418
1434
|
// links that don't play here.
|
|
1419
1435
|
var TIERS = ['2160', '1440', '1080', '720', 'sd', 'other'];
|
|
1420
|
-
var GROUPS = ['local', 'played'].concat(TIERS, ['ranked', 'unsuitable', 'worded', 'sized', 'bad', 'where']);
|
|
1421
|
-
var GROUP_TITLES = { local: 'On your USB drive', played: 'Played before', '2160': '4K', '1440': '1440p', '1080': '1080p', '720': '720p',
|
|
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',
|
|
1422
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' };
|
|
1423
1439
|
var KIND_SCORE = { remux: 4, bluray: 3, web: 2, hdtv: 1, '': 1.5, cam: -5 };
|
|
1424
1440
|
function tierOf(info) {
|
|
@@ -1454,7 +1470,7 @@
|
|
|
1454
1470
|
var bad = usable ? Stremio.badFormats(st, info) : [];
|
|
1455
1471
|
var blocked = usable ? Stremio.blockedRes(st, info) : ''; // a resolution you don't allow
|
|
1456
1472
|
var pr = (usable && !unsuitable && !worded && !sized && !bad.length && !blocked) ? playedIndex(hist, st, info) : -1;
|
|
1457
|
-
var group = !usable ? 'where' : unsuitable ? 'unsuitable' : worded ? 'worded' : sized ? 'sized' : (bad.length || blocked) ? 'bad' : st._localFile ? 'local' : pr >= 0 ? 'played' : byRes ? tierOf(info) : 'ranked';
|
|
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';
|
|
1458
1474
|
var app = group === 'where' ? whereApp(st) : null; // links that open an app here come first
|
|
1459
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 };
|
|
1460
1476
|
});
|
|
@@ -1605,19 +1621,30 @@
|
|
|
1605
1621
|
}
|
|
1606
1622
|
U.store.set(UNSUIT_KEY, all);
|
|
1607
1623
|
}
|
|
1608
|
-
// Hold OK on a source: Play from the start (a place to resume),
|
|
1624
|
+
// Hold OK on a source: Play from the start (a place to resume), Play through StremioK's service
|
|
1625
|
+
// (an HLS one), Not suitable (or back), and
|
|
1609
1626
|
// with a USB drive plugged in, Download to it (js/downloads.js). With only Not suitable to
|
|
1610
1627
|
// offer, it's asked at once.
|
|
1628
|
+
// An HLS source (not YouTube, DRM or a USB file): Play through StremioK's service, this once
|
|
1629
|
+
// (Settings › Playback › Seeking & buffering › HLS through StremioK's service, for all of them).
|
|
1630
|
+
function serviceHlsOk(stream) {
|
|
1631
|
+
if (!stream || stream._yt || stream._localFile || stream._drm || typeof YTPlay === 'undefined' || YTPlay.installMode() === 'browser') { return false; }
|
|
1632
|
+
var url = '' + (stream.url || '');
|
|
1633
|
+
return /^https?:\/\//i.test(url) && (/\.m3u8?(?:[?#]|$)/i.test(url) || Stremio.streamInfo(stream).container === 'hls');
|
|
1634
|
+
}
|
|
1611
1635
|
function sourceMenu(stream) {
|
|
1612
1636
|
var canStart = !howHere() && savedPlace(_d.streamId);
|
|
1613
1637
|
var canDownload = typeof Downloads !== 'undefined' && Downloads.available() && (Downloads.isFileLink ? Downloads.isFileLink(stream) : /^https?:\/\//i.test(stream.url || '')) && !stream._localFile && !stream._yt;
|
|
1614
|
-
|
|
1638
|
+
var canService = serviceHlsOk(stream);
|
|
1639
|
+
if (!canStart && !canDownload && !canService) { toggleUnsuitable(stream); return; }
|
|
1615
1640
|
var unsuit = isUnsuitable(_d.id, stream), opts = [];
|
|
1616
1641
|
if (canStart) { opts.push(['start', 'Play from the start']); }
|
|
1642
|
+
if (canService) { opts.push(['service', 'Play through StremioK’s service']); }
|
|
1617
1643
|
if (canDownload) { opts.push(['download', '⬇ Download to USB drive']); }
|
|
1618
1644
|
opts.push(['suit', unsuit ? 'Put back among the sources' : 'Not suitable']);
|
|
1619
1645
|
pickList(Stremio.streamName(stream), opts, null, function (k) {
|
|
1620
1646
|
if (k === 'start') { startPlayback(stream, _d.streamId, _d.streamLabel || _d.meta.name, { fromStart: true }); }
|
|
1647
|
+
else if (k === 'service') { startPlayback(stream, _d.streamId, _d.streamLabel || _d.meta.name, { viaService: true, fromStart: !!howHere() }); }
|
|
1621
1648
|
else if (k === 'download') { downloadSource(stream); }
|
|
1622
1649
|
else { toggleUnsuitable(stream); }
|
|
1623
1650
|
});
|
|
@@ -2140,7 +2167,7 @@
|
|
|
2140
2167
|
var ctx = { url: stream.url, type: _d.type, addonType: _d.addonType, id: videoId, name: label, parent: _d.id,
|
|
2141
2168
|
poster: _d.meta.poster, background: _d.meta.background, streams: playableSources(), _headers: U.sanitizeHeaders(stream._headers) || undefined, zap: zap, zapTo: zap ? zapToChannel : null,
|
|
2142
2169
|
localSubs: stream._localSubs, localFile: stream._localFile,
|
|
2143
|
-
subExtra: fileHintsOf(stream), sourceSubs: sourceSubsOf(stream), formatInfo: Stremio.streamInfo(stream), fromStart: !!(how && how.fromStart) || undefined,
|
|
2170
|
+
subExtra: fileHintsOf(stream), sourceSubs: sourceSubsOf(stream), formatInfo: Stremio.streamInfo(stream), fromStart: !!(how && how.fromStart) || undefined, viaService: !!(how && how.viaService) || undefined,
|
|
2144
2171
|
titleIds: titleIdsOf(_d.meta, videoId), stream: stream, nextSource: nextSourceFor, downloadAs: typeof Downloads !== 'undefined' ? downloadTitle(videoId) : undefined,
|
|
2145
2172
|
onStarted: learn.onStarted, onFailed: learn.onFailed, learnFor: learnFor };
|
|
2146
2173
|
if (_d.type === 'series' && _d.meta.videos) {
|
package/js/view-discover.js
CHANGED
|
@@ -227,13 +227,13 @@
|
|
|
227
227
|
});
|
|
228
228
|
});
|
|
229
229
|
var ofType = _dv.cats.filter(function (c) { return c.type === _dv.type; });
|
|
230
|
-
pill('Catalog: ' + catLabel(_dv.cat) + ' ▾', function () {
|
|
230
|
+
pill('Catalog: ' + catLabel(_dv.cat) + ' ▾', function () { // (.discover-cat: the one cut short when the bar is full)
|
|
231
231
|
pickList('Catalog', ofType.map(function (c) { return [Stremio.catalogKey(c), catLabel(c)]; }), Stremio.catalogKey(_dv.cat), function (k) {
|
|
232
232
|
var c = ofType.filter(function (x) { return Stremio.catalogKey(x) === k; })[0];
|
|
233
233
|
if (!c || c === _dv.cat) { return; }
|
|
234
234
|
choose(_dv.type, c); reload();
|
|
235
235
|
});
|
|
236
|
-
});
|
|
236
|
+
}).className += ' discover-cat';
|
|
237
237
|
var f = genreFilter(_dv.cat);
|
|
238
238
|
if (f) {
|
|
239
239
|
pill(f.label + ': ' + (_dv.value ? genreLabel(_dv.value) : 'All') + ' ▾', function () { genrePicker(f, false); });
|
|
@@ -323,18 +323,23 @@
|
|
|
323
323
|
// measures nothing.
|
|
324
324
|
var WINDOW = 600;
|
|
325
325
|
function gridEl() { return scr('discover').querySelector('.discover-grid'); }
|
|
326
|
+
// A card's top in the grid's own pixels: where it's laid out (offsetTop), not where it's
|
|
327
|
+
// drawn: the focused card is drawn larger (its scale), its top a few pixels higher, and a
|
|
328
|
+
// single row (three titles) measured with it counted one card per row: LEFT / RIGHT went
|
|
329
|
+
// nowhere and UP / DOWN went along the row.
|
|
330
|
+
function cardTop(el) { return typeof el.offsetTop === 'number' ? el.offsetTop : el.getBoundingClientRect().top / U.zoom(); }
|
|
326
331
|
function cols() {
|
|
327
332
|
var els = _dv.cardEls || [];
|
|
328
333
|
if (_dv.cols && els.length > _dv.cols) { return _dv.cols; }
|
|
329
334
|
if (els.length < 2) { return 1; }
|
|
330
|
-
var top = els[0]
|
|
331
|
-
while (n < els.length && Math.abs(els[n]
|
|
335
|
+
var top = cardTop(els[0]), n = 1; // (the cards of the first row share its top)
|
|
336
|
+
while (n < els.length && Math.abs(cardTop(els[n]) - top) < 2) { n++; }
|
|
332
337
|
if (n < els.length) { _dv.cols = n; } // (known once a second row exists)
|
|
333
338
|
return Math.max(1, n);
|
|
334
339
|
}
|
|
335
340
|
function rowHeight() {
|
|
336
341
|
var els = _dv.cardEls, c = cols();
|
|
337
|
-
return (els.length > c) ? (els[c]
|
|
342
|
+
return (els.length > c) ? cardTop(els[c]) - cardTop(els[0]) : 0; // (in the grid's own pixels)
|
|
338
343
|
}
|
|
339
344
|
function drawGrid() {
|
|
340
345
|
var grid = gridEl();
|
package/js/view-home.js
CHANGED
|
@@ -650,7 +650,7 @@
|
|
|
650
650
|
};
|
|
651
651
|
c.__onlongpress = function () { continueActions(e, base, preview, target, c); };
|
|
652
652
|
c.__cwKey = showKey(e);
|
|
653
|
-
c.__meta = { name: e.name, description: e.position
|
|
653
|
+
c.__meta = { _id: base, _bg: a.background || e.background || '', _ep: e.type === 'series' && target ? codeOfId(target) : '', name: e.name, description: e.position
|
|
654
654
|
? 'Resume at ' + U.fmtTime(e.position) + (e.duration ? ' of ' + U.fmtTime(e.duration) : '')
|
|
655
655
|
: e.upNext !== undefined ? 'Next episode' + (e.upNext ? ': “' + e.upNext + '”' : '') + ' · from Trakt'
|
|
656
656
|
: 'Added, not started yet' };
|
|
@@ -786,7 +786,7 @@
|
|
|
786
786
|
var c = posterCard({ id: u.show, type: 'series', name: u.name, poster: u.poster || calPoster(u.show) }, 'series');
|
|
787
787
|
var code = epCodeOf(u.ep);
|
|
788
788
|
c.appendChild(U.el('div', 'card-new card-code', code));
|
|
789
|
-
c.__meta = { name: u.name, description: code + (u.ep.t ? ' “' + u.ep.t + '”' : '') + ' · ' + (u.ep.r > now ? 'out ' : 'came out ') + U.dayLabel(u.ep.r) };
|
|
789
|
+
c.__meta = { _id: u.show, name: u.name, description: code + (u.ep.t ? ' “' + u.ep.t + '”' : '') + ' · ' + (u.ep.r > now ? 'out ' : 'came out ') + U.dayLabel(u.ep.r) };
|
|
790
790
|
c.__onselect = function () { App.openDetail('series', u.show, { name: u.name, poster: u.poster, type: 'series' }, u.ep.id); };
|
|
791
791
|
c.__onplay = function () { App.openDetail('series', u.show, { name: u.name, poster: u.poster, type: 'series' }, u.ep.id, { playBest: true }); };
|
|
792
792
|
return c;
|
|
@@ -1240,9 +1240,12 @@
|
|
|
1240
1240
|
if (launch && asked === 'guide' && (Stremio.getPrefs().hiddenTabs || []).indexOf('guide') === -1) { _wantGuide = _homeTab; } // (see EPG.onChange below)
|
|
1241
1241
|
}
|
|
1242
1242
|
|
|
1243
|
+
var hero = U.look() === 'modern' && !NO_HERO[_homeTab]; // (Modern: the focused title's backdrop, behind it all)
|
|
1244
|
+
if (hero) { s.appendChild(homeBackdrop(_homeTab)); }
|
|
1243
1245
|
s.appendChild(buildTopMenu(_homeTab));
|
|
1244
|
-
// The focused title's details, between the top menu and the rows (#home-info)
|
|
1245
|
-
|
|
1246
|
+
// The focused title's details, between the top menu and the rows (#home-info); Modern's
|
|
1247
|
+
// title tabs: large, over the backdrop (hero).
|
|
1248
|
+
var info = U.el('div', 'home-info' + (hero ? ' hero' : ''));
|
|
1246
1249
|
info.appendChild(U.el('div', 'home-info-title'));
|
|
1247
1250
|
info.appendChild(U.el('div', 'home-info-meta'));
|
|
1248
1251
|
info.appendChild(U.el('div', 'home-info-desc'));
|
|
@@ -1315,7 +1318,61 @@
|
|
|
1315
1318
|
// Details strip: updated when focus settles on a Home card (debounced, so holding a
|
|
1316
1319
|
// direction doesn't redo it for every card passed).
|
|
1317
1320
|
var _homeInfoTimer = null;
|
|
1318
|
-
function fillHomeInfo(m) { fillInfoBox(scr('home').querySelector('.home-info'), m); }
|
|
1321
|
+
function fillHomeInfo(m) { fillInfoBox(scr('home').querySelector('.home-info'), m); fillBackdrop(scr('home').querySelector('.home-bg'), m); }
|
|
1322
|
+
// Modern look: the focused title's backdrop behind Home, two layers taking turns, so the
|
|
1323
|
+
// new one fades in over the last (Effects: Full) once it has loaded; a picture that doesn't
|
|
1324
|
+
// load gives way to the next of its choices (U.heroImages). A title without one: black; the
|
|
1325
|
+
// menu (no title): the last kept. Not on the live tabs and Local (their pictures are
|
|
1326
|
+
// logos and program stills: the details strip shows those).
|
|
1327
|
+
var NO_HERO = { tv: 1, guide: 1, radio: 1, sport: 1, local: 1 };
|
|
1328
|
+
var _homeBg = { tab: '', src: '' }; // (the last one, for when Home draws that tab again)
|
|
1329
|
+
function homeBackdrop(tab) {
|
|
1330
|
+
var bg = U.el('div', 'home-bg');
|
|
1331
|
+
bg.appendChild(U.el('div', 'hb'));
|
|
1332
|
+
bg.appendChild(U.el('div', 'hb'));
|
|
1333
|
+
bg.appendChild(U.el('div', 'hb-shade'));
|
|
1334
|
+
if (_homeBg.src && _homeBg.tab === tab) { bg.children[0].style.backgroundImage = 'url("' + _homeBg.src + '")'; bg.children[0].className = 'hb on'; bg.__src = _homeBg.src; }
|
|
1335
|
+
bg.__tab = tab;
|
|
1336
|
+
return bg;
|
|
1337
|
+
}
|
|
1338
|
+
// Continue Watching and the Calendar keep only a little of a title: for an IMDb one, its logo
|
|
1339
|
+
// is Cinemeta's for that id (one that doesn't load: its name, as for any logo).
|
|
1340
|
+
function ttLogo(m) {
|
|
1341
|
+
var tt = m && m._id && /^(tt\d{5,10})(?::|$)/.exec(m._id);
|
|
1342
|
+
return tt ? 'https://images.metahub.space/logo/medium/' + tt[1] + '/img' : '';
|
|
1343
|
+
}
|
|
1344
|
+
// A title's backdrop: its own; else, for an IMDb title (Continue Watching, the Calendar keep
|
|
1345
|
+
// only a little of it), Cinemeta's picture for that id.
|
|
1346
|
+
function backdropOf(m) {
|
|
1347
|
+
if (!m) { return null; }
|
|
1348
|
+
var b = m.background || m._bg || '', tt = !b && /^(tt\d{5,10})(?::|$)/.exec(m.id || m._id || '');
|
|
1349
|
+
if (tt) { b = 'https://images.metahub.space/background/medium/' + tt[1] + '/img'; }
|
|
1350
|
+
return U.heroImages(b);
|
|
1351
|
+
}
|
|
1352
|
+
function fillBackdrop(bg, m) {
|
|
1353
|
+
if (!bg || !m || !(m.name || m.title)) { return; } // (the menu: the last one stays)
|
|
1354
|
+
var list = backdropOf(m) || [], key = list.join(' ');
|
|
1355
|
+
if (bg.__src === key) { return; }
|
|
1356
|
+
bg.__src = key;
|
|
1357
|
+
function show(src) {
|
|
1358
|
+
var on = bg.querySelector('.hb.on'), next = on === bg.children[0] ? bg.children[1] : bg.children[0];
|
|
1359
|
+
if (src) { next.style.backgroundImage = 'url("' + src + '")'; next.className = 'hb on'; }
|
|
1360
|
+
if (on) { on.className = 'hb'; }
|
|
1361
|
+
_homeBg = { tab: bg.__tab, src: src || '' };
|
|
1362
|
+
}
|
|
1363
|
+
if (!list.length) { show(''); return; }
|
|
1364
|
+
(function next(i) {
|
|
1365
|
+
if (i >= list.length) { if (bg.__src === key) { show(''); } return; }
|
|
1366
|
+
var img = new Image();
|
|
1367
|
+
img.onload = function () {
|
|
1368
|
+
if (bg.__src !== key) { return; } // (focus moved on before it came)
|
|
1369
|
+
if (img.naturalWidth && img.naturalWidth < 200) { next(i + 1); return; } // (a stand-in, not the picture)
|
|
1370
|
+
show(list[i]);
|
|
1371
|
+
};
|
|
1372
|
+
img.onerror = function () { if (bg.__src === key) { next(i + 1); } };
|
|
1373
|
+
img.src = list[i];
|
|
1374
|
+
})(0);
|
|
1375
|
+
}
|
|
1319
1376
|
// Fill a details strip (Home, Discover) with a title's logo / name, facts and synopsis.
|
|
1320
1377
|
function fillInfoBox(box, m) {
|
|
1321
1378
|
if (!box) { return; }
|
|
@@ -1329,10 +1386,17 @@
|
|
|
1329
1386
|
if (m.name || m.title) { box.classList.add('on'); } else { box.classList.remove('on'); } // shaded only while describing a title
|
|
1330
1387
|
var t = box.children[0], name = m.name || m.title || '';
|
|
1331
1388
|
U.clear(t);
|
|
1332
|
-
var logoSrc = U.cardImage(m.logo, 'logo');
|
|
1389
|
+
var logoSrc = U.cardImage(m.logo || ttLogo(m), 'logo');
|
|
1390
|
+
// an episode in Continue Watching: its name says which (Breaking Bad S1E1), its logo
|
|
1391
|
+
// doesn't, so the facts begin with it then
|
|
1392
|
+
var ep = logoSrc && m._ep ? m._ep : '';
|
|
1333
1393
|
if (logoSrc) { // the title's logo when it has one; its name if that fails to load
|
|
1334
1394
|
var img = U.el('img', 'home-info-logo');
|
|
1335
|
-
img.onerror = function () {
|
|
1395
|
+
img.onerror = function () {
|
|
1396
|
+
if (img.parentNode !== t) { return; }
|
|
1397
|
+
U.clear(t); t.textContent = name;
|
|
1398
|
+
if (ep && box.children[1].textContent.indexOf(ep) === 0) { box.children[1].textContent = box.children[1].textContent.slice(ep.length).replace(/^\s*·\s*/, ''); }
|
|
1399
|
+
};
|
|
1336
1400
|
t.appendChild(img);
|
|
1337
1401
|
U.deferImage(img, logoSrc, true); // (through the queue, ahead of the rest)
|
|
1338
1402
|
} else {
|
|
@@ -1344,6 +1408,7 @@
|
|
|
1344
1408
|
bits = ['Now ' + EPG.hhmm(g.now.start) + '–' + EPG.hhmm(g.now.stop) + ' ' + g.now.title];
|
|
1345
1409
|
desc = (g.now.desc ? g.now.desc + ' ' : '') + (g.next ? 'Next ' + EPG.hhmm(g.next.start) + ' ' + g.next.title : '');
|
|
1346
1410
|
}
|
|
1411
|
+
if (ep) { bits.unshift(ep); }
|
|
1347
1412
|
box.children[1].textContent = bits.join(' · ');
|
|
1348
1413
|
box.children[2].textContent = desc;
|
|
1349
1414
|
// a program's picture from the TV guide (the Guide tab's focused one, a channel's now)
|
|
@@ -1441,6 +1506,8 @@
|
|
|
1441
1506
|
if (typeof Stremio !== 'undefined' && Stremio.onIptvReady) { Stremio.onIptvReady(function () { refreshAddonRows('local:iptv'); }); }
|
|
1442
1507
|
if (typeof XtVod !== 'undefined' && XtVod.onChange) { XtVod.onChange(function () { refreshAddonRows('local:xtvod'); }); } // (an Xtream account's films and series, once its categories came)
|
|
1443
1508
|
if (typeof StVod !== 'undefined' && StVod.onChange) { StVod.onChange(function () { refreshAddonRows('local:stvod'); }); } // (a Stalker portal's, the same)
|
|
1509
|
+
if (typeof Jellyfin !== 'undefined' && Jellyfin.onChange) { Jellyfin.onChange(function () { refreshAddonRows('local:jellyfin'); refreshAddonRows('local:emby'); }); } // (a Jellyfin or Emby server's libraries)
|
|
1510
|
+
if (typeof Plex !== 'undefined' && Plex.onChange) { Plex.onChange(function () { refreshAddonRows('local:plex'); }); } // (a Plex server's)
|
|
1444
1511
|
var PARTIAL_DELAY = 150; // coalesces catalogs that arrive together into one redraw
|
|
1445
1512
|
function loadHomeCatalogs() {
|
|
1446
1513
|
if (_homeLoading) { return; }
|