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/view-settings.js
CHANGED
|
@@ -197,9 +197,15 @@
|
|
|
197
197
|
// Zoom: everything bigger (see U.setZoom), in percent.
|
|
198
198
|
var ZOOMS = [['100', '100%'], ['110', '110%'], ['120', '120%'], ['130', '130%'], ['140', '140%']];
|
|
199
199
|
function zoomPct() { return Stremio.getPrefs().zoom; }
|
|
200
|
+
// Look: Classic (the stylesheet as it is) or Modern (css/modern.css, its rules only under
|
|
201
|
+
// body.look-modern). Effects, Modern's blur and motion: Auto turns them on where the TV's
|
|
202
|
+
// browser can blur behind a panel (Tizen 6 and later), Light keeps them off, Full on.
|
|
203
|
+
var LOOKS = [['classic', 'Classic'], ['modern', 'Modern']];
|
|
204
|
+
var EFFECTS = [['auto', 'Auto (by the TV)'], ['light', 'Light'], ['full', 'Full']];
|
|
200
205
|
function applyAppearance() {
|
|
201
|
-
var a = appearance();
|
|
206
|
+
var a = appearance(), p = Stremio.getPrefs();
|
|
202
207
|
U.applyTheme(a.accent, a.bg);
|
|
208
|
+
U.setLook(p.look, p.effects, a.bg === 'gray' || a.bg === 'white');
|
|
203
209
|
U.setZoom(zoomPct() / 100);
|
|
204
210
|
}
|
|
205
211
|
function settingsAppearance(wrap) {
|
|
@@ -210,6 +216,10 @@
|
|
|
210
216
|
} };
|
|
211
217
|
var accents = U.ACCENT_KEYS.map(function (k) { return [k, ACCENT_NAMES[k] || k, null, U.accentColor(k)]; });
|
|
212
218
|
wrap.appendChild(U.el('h2', null, 'Appearance'));
|
|
219
|
+
var looks = { get: function () { var p = Stremio.getPrefs(); return { look: p.look, effects: p.effects }; },
|
|
220
|
+
set: function (cfg) { Stremio.setPref('look', cfg.look); Stremio.setPref('effects', cfg.effects); applyAppearance(); markHomeDirty(); } };
|
|
221
|
+
wrap.appendChild(subPickRow('Look', LOOKS, 'look', looks));
|
|
222
|
+
wrap.appendChild(subPickRow('Effects', EFFECTS, 'effects', looks));
|
|
213
223
|
wrap.appendChild(subPickRow('Background', BACKGROUNDS, 'bg', store));
|
|
214
224
|
wrap.appendChild(subPickRow('Accent color', accents, 'accent', store));
|
|
215
225
|
wrap.appendChild(subPickRow('Zoom', ZOOMS, 'zoom', {
|
|
@@ -368,6 +378,7 @@
|
|
|
368
378
|
['YouTube', 'Your YouTube channels, playlists and searches; YouTube in Search', 'youtube'],
|
|
369
379
|
['Streaming apps', 'Your apps (Prime Video, Netflix, …) that open a title\'s "where to watch" sources', 'appshortcuts'],
|
|
370
380
|
['USB drive', 'The Local tab: what\'s on your drive, matched to titles; hidden files', 'usb'],
|
|
381
|
+
['Media servers', 'Your Jellyfin or Emby server: its libraries on Home, its files as sources', 'mediaservers'],
|
|
371
382
|
['Import configuration file', 'Import addons, API keys & IPTV playlists', 'import'],
|
|
372
383
|
['Export configuration', 'Your addons, playlists, API keys and settings, to your phone', 'export']] },
|
|
373
384
|
playback: { title: 'Playback', rows: [
|
|
@@ -429,6 +440,7 @@
|
|
|
429
440
|
else if (_settingsSection === 'storage') { settingsStorage(wrap); }
|
|
430
441
|
else if (_settingsSection === 'tvapps') { settingsTvApps(wrap); }
|
|
431
442
|
else if (_settingsSection === 'usb') { settingsUsb(wrap); }
|
|
443
|
+
else if (_settingsSection === 'mediaservers') { settingsMediaServers(wrap); }
|
|
432
444
|
else if (_settingsSection === 'private') { settingsPrivate(wrap); }
|
|
433
445
|
else if (_settingsSection === 'appshortcuts') { settingsAppShortcuts(wrap); }
|
|
434
446
|
else if (_settingsSection === 'import') { settingsImport(wrap); }
|
|
@@ -476,9 +488,9 @@
|
|
|
476
488
|
var TIZENBREW_NOTE = '⚠ Installed with TizenBrew: other TizenBrew modules can read what StremioK saves, including API keys and addon links with their tokens. Only install modules you trust; the sideloaded app keeps its data to itself.';
|
|
477
489
|
function settingsMenu(wrap) {
|
|
478
490
|
wrap.appendChild(U.el('h2', null, 'Settings'));
|
|
479
|
-
wrap.appendChild(sectionRow('Content', 'Addons, API keys, IPTV playlists, streaming apps, importing a configuration file', 'content'));
|
|
491
|
+
wrap.appendChild(sectionRow('Content', 'Addons, API keys, IPTV playlists, media servers, streaming apps, importing a configuration file', 'content'));
|
|
480
492
|
wrap.appendChild(sectionRow('Playback', 'Audio and subtitles, source ranking, feed sources, formats', 'playback'));
|
|
481
|
-
wrap.appendChild(sectionRow('Appearance', '
|
|
493
|
+
wrap.appendChild(sectionRow('Appearance', 'Look, background, accent color, zoom, posters, spoilers', 'appearance'));
|
|
482
494
|
wrap.appendChild(sectionRow('Home', 'The tab it opens on, the top menu, Home feeds, Search results', 'home'));
|
|
483
495
|
wrap.appendChild(sectionRow('Diagnostics', 'Logs, storage, installed apps; how StremioK was installed', 'diagnostics'));
|
|
484
496
|
if (typeof YTPlay !== 'undefined' && YTPlay.installMode && YTPlay.installMode() === 'tizenbrew') { wrap.appendChild(U.el('div', 'hint', TIZENBREW_NOTE)); }
|
|
@@ -1229,6 +1241,13 @@
|
|
|
1229
1241
|
}
|
|
1230
1242
|
}));
|
|
1231
1243
|
|
|
1244
|
+
if (typeof StVod !== 'undefined' && StVod.keepMinutes) { // (what the service keeps of a portal's films and series)
|
|
1245
|
+
wrap.appendChild(subPickRow('Stalker films and series', [['10', 'Kept 10 minutes'], ['5', 'Kept 5 minutes'], ['0', 'Off (asked each time)']], 'keep', {
|
|
1246
|
+
get: function () { return { keep: String(StVod.keepMinutes()) }; },
|
|
1247
|
+
set: function (c) { StVod.setKeepMinutes(+c.keep); }
|
|
1248
|
+
}));
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1232
1251
|
wrap.appendChild(U.el('div', 'hint',
|
|
1233
1252
|
'Channels are grouped into IPTV and Radio rows on Home. ▲ / ▼ set the playlists\' order: a channel in two playlists comes from the first.'));
|
|
1234
1253
|
var s = scr('settings'), want = null;
|
|
@@ -1591,6 +1610,175 @@
|
|
|
1591
1610
|
onModalClose(cancelFlow); // canceling the overlay stops polling
|
|
1592
1611
|
}
|
|
1593
1612
|
|
|
1613
|
+
// ---- Media servers: your Jellyfin servers ----
|
|
1614
|
+
function settingsMediaServers(wrap) {
|
|
1615
|
+
wrap.appendChild(U.el('h2', null, 'Media servers'));
|
|
1616
|
+
var have = typeof Jellyfin !== 'undefined';
|
|
1617
|
+
var add = U.el('div', 'addon-item focusable cfg-row');
|
|
1618
|
+
add.appendChild(U.el('div', 'a-name', '+ Add a Jellyfin or Emby server'));
|
|
1619
|
+
add.appendChild(U.el('div', 'a-url', 'Its address on your network, then a user name and password, or Jellyfin’s Quick Connect'));
|
|
1620
|
+
add.__onselect = function () { askJellyfinAddress(''); };
|
|
1621
|
+
if (have) { wrap.appendChild(add); }
|
|
1622
|
+
var hasPlex = typeof Plex !== 'undefined';
|
|
1623
|
+
if (hasPlex) {
|
|
1624
|
+
var addPx = U.el('div', 'addon-item focusable cfg-row');
|
|
1625
|
+
addPx.appendChild(U.el('div', 'a-name', '+ Add a Plex server'));
|
|
1626
|
+
addPx.appendChild(U.el('div', 'a-url', 'A code to enter at plex.tv/link, then which of your servers'));
|
|
1627
|
+
addPx.__onselect = function () { plexLink(); };
|
|
1628
|
+
wrap.appendChild(addPx);
|
|
1629
|
+
}
|
|
1630
|
+
var focus = null;
|
|
1631
|
+
// (each server with the module it's from: Jellyfin's for Jellyfin and Emby, Plex's)
|
|
1632
|
+
var all = (have ? Jellyfin.servers().map(function (s) { return { srv: s, mod: Jellyfin, kind: Jellyfin.kindName(s) }; }) : [])
|
|
1633
|
+
.concat(hasPlex ? Plex.servers().map(function (s) { return { srv: s, mod: Plex, kind: 'Plex' }; }) : []);
|
|
1634
|
+
all.forEach(function (x) {
|
|
1635
|
+
var srv = x.srv, mod = x.mod;
|
|
1636
|
+
var r = U.el('div', 'addon-item focusable cfg-row'), libs = mod.libraries(srv);
|
|
1637
|
+
r.appendChild(U.el('div', 'a-name', srv.name + ' · ' + x.kind + ' ' + srv.version));
|
|
1638
|
+
r.appendChild(U.el('div', 'a-url', srv.url + (srv.user ? ' · signed in as ' + srv.user : '') + (libs.length ? ' · ' + libs.map(function (l) { return l.name; }).join(', ') : '')));
|
|
1639
|
+
r.__onselect = function () {
|
|
1640
|
+
pickList(srv.name, [['reload', 'Reload'], ['remove', 'Sign out and remove']], null, function (v) {
|
|
1641
|
+
if (v === 'reload') {
|
|
1642
|
+
mod.reload(srv.id);
|
|
1643
|
+
markHomeDirty();
|
|
1644
|
+
U.toast('Reading “' + srv.name + '” again…');
|
|
1645
|
+
setTimeout(function () { if (_settingsSection === 'mediaservers') { renderSettings(); } }, 1500);
|
|
1646
|
+
} else if (v === 'remove') {
|
|
1647
|
+
confirm('Sign out of “' + srv.name + '” and remove it?', 'Remove', function () { mod.remove(srv.id); markHomeDirty(); renderSettings(); });
|
|
1648
|
+
}
|
|
1649
|
+
});
|
|
1650
|
+
};
|
|
1651
|
+
if (_focusChild === 'jf:' + srv.id) { focus = r; }
|
|
1652
|
+
wrap.appendChild(r);
|
|
1653
|
+
});
|
|
1654
|
+
wrap.appendChild(U.el('div', 'hint', 'Jellyfin 10.9 or newer, Emby 4.7 or newer, Plex. Their files play as they are (nothing converted), so the TV must play their format.'));
|
|
1655
|
+
if (focus) { _focusChild = null; Focus.setScope(scr('settings'), focus); } else { focusSettings(); }
|
|
1656
|
+
}
|
|
1657
|
+
function askJellyfinAddress(value) {
|
|
1658
|
+
App.openEntry({
|
|
1659
|
+
title: 'Jellyfin or Emby server: address',
|
|
1660
|
+
hint: 'Its address on your network, like http://192.168.0.50:8096. RETURN cancels.',
|
|
1661
|
+
value: value || 'http://', placeholder: 'http://192.168.0.50:8096', phone: 'jellyfin',
|
|
1662
|
+
validate: function (v) { return Jellyfin.addressProblem(v); },
|
|
1663
|
+
onConfirm: function (v) {
|
|
1664
|
+
App.back();
|
|
1665
|
+
U.spinner(true, 'Asking the server…');
|
|
1666
|
+
Jellyfin.probe(v).then(function (info) { U.spinner(false); if (info.kind === 'emby') { jellyfinPassword(info, ''); } else { jellyfinSignIn(info); } }, function (e) {
|
|
1667
|
+
U.spinner(false);
|
|
1668
|
+
U.toast(e.message, 6000);
|
|
1669
|
+
if (_settingsSection === 'mediaservers') { renderSettings(); }
|
|
1670
|
+
});
|
|
1671
|
+
}
|
|
1672
|
+
});
|
|
1673
|
+
}
|
|
1674
|
+
function jellyfinDone(srv) {
|
|
1675
|
+
markHomeDirty();
|
|
1676
|
+
_settingsSection = 'mediaservers';
|
|
1677
|
+
_focusChild = 'jf:' + srv.id;
|
|
1678
|
+
renderSettings();
|
|
1679
|
+
U.toast('✓ Signed in to “' + srv.name + '”' + (srv.user ? ' as ' + srv.user : ''));
|
|
1680
|
+
}
|
|
1681
|
+
// Plex: its code to enter at plex.tv/link (a QR of the page too), then which server.
|
|
1682
|
+
function plexLink() {
|
|
1683
|
+
var existing = document.querySelector('.modal-overlay');
|
|
1684
|
+
if (existing) { existing.parentNode.removeChild(existing); }
|
|
1685
|
+
var overlay = U.el('div', 'modal-overlay'), box = U.el('div', 'modal-box');
|
|
1686
|
+
box.appendChild(U.el('div', 'modal-msg', 'Add a Plex server'));
|
|
1687
|
+
var body = U.el('div', 'trakt-connect');
|
|
1688
|
+
body.appendChild(U.el('div', 'tc-line', 'Asking Plex for a code…'));
|
|
1689
|
+
box.appendChild(body);
|
|
1690
|
+
var row = U.el('div', 'modal-row'), cancel = U.el('div', 'pill focusable modal-btn', 'Cancel');
|
|
1691
|
+
cancel.__onselect = function () { closeModal(); };
|
|
1692
|
+
row.appendChild(cancel);
|
|
1693
|
+
box.appendChild(row);
|
|
1694
|
+
overlay.appendChild(box);
|
|
1695
|
+
document.body.appendChild(overlay);
|
|
1696
|
+
showModal(overlay, cancel);
|
|
1697
|
+
function addIt(res) {
|
|
1698
|
+
U.spinner(true, 'Finding “' + res.name + '”…');
|
|
1699
|
+
Plex.add(res).then(function (srv) { U.spinner(false); jellyfinDone(srv); }, function (e) { U.spinner(false); U.toast(e.message, 8000); });
|
|
1700
|
+
}
|
|
1701
|
+
var stop = Plex.link({
|
|
1702
|
+
onCode: function (code, url) {
|
|
1703
|
+
U.clear(body);
|
|
1704
|
+
var qrSpot = U.el('div', 'tc-qr-spot');
|
|
1705
|
+
body.appendChild(qrSpot);
|
|
1706
|
+
var goTo = body.appendChild(U.el('div', 'tc-line', 'On your phone or computer, go to:'));
|
|
1707
|
+
(typeof qrcode !== 'undefined' ? Promise.resolve() : U.loadScript('js/qrcode.js')).then(function () {
|
|
1708
|
+
var qr = U.qrCanvas(url, 8);
|
|
1709
|
+
if (!qr || !qrSpot.parentNode) { return; }
|
|
1710
|
+
qr.className = 'tc-qr';
|
|
1711
|
+
qrSpot.appendChild(U.el('div', 'tc-line', 'Scan with your phone:'));
|
|
1712
|
+
qrSpot.appendChild(qr);
|
|
1713
|
+
goTo.textContent = 'or go to';
|
|
1714
|
+
}, function () {});
|
|
1715
|
+
body.appendChild(U.el('div', 'tc-url', url.replace(/^https:\/\//, '')));
|
|
1716
|
+
body.appendChild(U.el('div', 'tc-line', 'sign in, and enter this code:'));
|
|
1717
|
+
body.appendChild(U.el('div', 'tc-code', code));
|
|
1718
|
+
body.appendChild(U.el('div', 'tc-line small', 'Waiting for you to enter it…'));
|
|
1719
|
+
},
|
|
1720
|
+
onServers: function (list) {
|
|
1721
|
+
if (isModalOpen()) { onModalClose(null); closeModal(); }
|
|
1722
|
+
if (list.length === 1) { addIt(list[0]); return; }
|
|
1723
|
+
pickList('Which Plex server?', list.map(function (x, i) { return ['' + i, x.name + (x.owned ? '' : ' (shared with you)')]; }), null, function (v) { addIt(list[+v]); });
|
|
1724
|
+
},
|
|
1725
|
+
onError: function (msg) { U.clear(body); body.appendChild(U.el('div', 'tc-line', msg)); }
|
|
1726
|
+
});
|
|
1727
|
+
onModalClose(stop);
|
|
1728
|
+
}
|
|
1729
|
+
// Signing in: Quick Connect's code, or a user name and password instead.
|
|
1730
|
+
function jellyfinSignIn(info) {
|
|
1731
|
+
var existing = document.querySelector('.modal-overlay');
|
|
1732
|
+
if (existing) { existing.parentNode.removeChild(existing); }
|
|
1733
|
+
var overlay = U.el('div', 'modal-overlay'), box = U.el('div', 'modal-box');
|
|
1734
|
+
box.appendChild(U.el('div', 'modal-msg', 'Sign in to “' + info.name + '”'));
|
|
1735
|
+
var body = U.el('div', 'trakt-connect');
|
|
1736
|
+
body.appendChild(U.el('div', 'tc-line', 'Starting Quick Connect…'));
|
|
1737
|
+
box.appendChild(body);
|
|
1738
|
+
var row = U.el('div', 'modal-row');
|
|
1739
|
+
var pw = U.el('div', 'pill focusable modal-btn', 'User name and password');
|
|
1740
|
+
var cancel = U.el('div', 'pill focusable modal-btn', 'Cancel');
|
|
1741
|
+
row.appendChild(pw); row.appendChild(cancel);
|
|
1742
|
+
box.appendChild(row);
|
|
1743
|
+
overlay.appendChild(box);
|
|
1744
|
+
document.body.appendChild(overlay);
|
|
1745
|
+
showModal(overlay, cancel);
|
|
1746
|
+
var stop = Jellyfin.quickConnect(info, {
|
|
1747
|
+
onCode: function (code) {
|
|
1748
|
+
U.clear(body);
|
|
1749
|
+
body.appendChild(U.el('div', 'tc-line', 'In Jellyfin on your phone or computer, open your profile › Quick Connect, and enter:'));
|
|
1750
|
+
body.appendChild(U.el('div', 'tc-code', code));
|
|
1751
|
+
body.appendChild(U.el('div', 'tc-line small', 'Waiting for you to enter it…'));
|
|
1752
|
+
},
|
|
1753
|
+
onSuccess: function (srv) { if (isModalOpen()) { onModalClose(null); closeModal(); } jellyfinDone(srv); },
|
|
1754
|
+
onError: function (msg) { U.clear(body); body.appendChild(U.el('div', 'tc-line', msg)); }
|
|
1755
|
+
});
|
|
1756
|
+
onModalClose(stop); // (closed: no more asking)
|
|
1757
|
+
pw.__onselect = function () { onModalClose(null); stop(); closeModal(); jellyfinPassword(info, ''); };
|
|
1758
|
+
cancel.__onselect = function () { closeModal(); };
|
|
1759
|
+
}
|
|
1760
|
+
function jellyfinPassword(info, user) {
|
|
1761
|
+
App.openEntry({
|
|
1762
|
+
title: Jellyfin.kindName(info) + ' “' + info.name + '”: user name', hint: 'Your ' + Jellyfin.kindName(info) + ' user name. RETURN cancels.', value: user || '', placeholder: 'user name',
|
|
1763
|
+
validate: function (v) { return ('' + v).trim() ? null : 'Your user name'; },
|
|
1764
|
+
onConfirm: function (u) {
|
|
1765
|
+
App.back();
|
|
1766
|
+
App.openEntry({
|
|
1767
|
+
title: Jellyfin.kindName(info) + ' “' + info.name + '”: password', hint: 'Its password (not kept: only the sign-in the server gives back). RETURN cancels.', value: '', placeholder: 'password', secret: true,
|
|
1768
|
+
validate: function () { return null; },
|
|
1769
|
+
onConfirm: function (p) {
|
|
1770
|
+
App.back();
|
|
1771
|
+
U.spinner(true, 'Signing in…');
|
|
1772
|
+
Jellyfin.signIn(info, ('' + u).trim(), p).then(function (srv) { U.spinner(false); jellyfinDone(srv); }, function (e) {
|
|
1773
|
+
U.spinner(false);
|
|
1774
|
+
U.toast(e.message, 6000);
|
|
1775
|
+
});
|
|
1776
|
+
}
|
|
1777
|
+
});
|
|
1778
|
+
}
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1594
1782
|
function settingsSubtitles(wrap) {
|
|
1595
1783
|
wrap.appendChild(U.el('h2', null, 'Subtitles'));
|
|
1596
1784
|
wrap.appendChild(subPickRow('Default language', SUB_LANGS, 'lang'));
|
|
@@ -1636,14 +1824,17 @@
|
|
|
1636
1824
|
// Seeking & buffering: how far LEFT / RIGHT jump; a bigger buffer for slow connections; how
|
|
1637
1825
|
// often a live channel that drops is opened again.
|
|
1638
1826
|
var RECONNECTS = [['off', 'Off'], ['few', 'A few times (3 in 5 minutes)'], ['always', 'Keep trying']];
|
|
1827
|
+
// (an HLS source through the service, with its own headers on every piece: see player-core's viaService)
|
|
1828
|
+
var HLS_ROUTES = [['off', 'Off'], ['headers', 'Sources that need headers'], ['all', 'All HLS sources']];
|
|
1639
1829
|
function settingsSeeking(wrap) {
|
|
1640
1830
|
wrap.appendChild(U.el('h2', null, 'Seeking & buffering'));
|
|
1641
|
-
var store = { get: function () { var c = Player.playerCfg(); return { seek: '' + c.seek, buffer: c.buffer, reconnect: c.reconnect }; },
|
|
1642
|
-
set: function (cfg) { Player.setPlayerCfg({ seek: +cfg.seek || 10, buffer: cfg.buffer, reconnect: cfg.reconnect }); } };
|
|
1831
|
+
var store = { get: function () { var c = Player.playerCfg(); return { seek: '' + c.seek, buffer: c.buffer, reconnect: c.reconnect, hls: c.hls }; },
|
|
1832
|
+
set: function (cfg) { Player.setPlayerCfg({ seek: +cfg.seek || 10, buffer: cfg.buffer, reconnect: cfg.reconnect, hls: cfg.hls }); } };
|
|
1643
1833
|
wrap.appendChild(subPickRow('Seek step', [['5', '5 s'], ['10', '10 s'], ['15', '15 s'], ['30', '30 s']], 'seek', store));
|
|
1644
1834
|
wrap.appendChild(subPickRow('Buffer', [['normal', 'Normal (the TV’s own)'], ['more', 'More'], ['most', 'Most']], 'buffer', store));
|
|
1645
1835
|
wrap.appendChild(subPickRow('Reconnect live channels', RECONNECTS, 'reconnect', store));
|
|
1646
|
-
wrap.appendChild(
|
|
1836
|
+
wrap.appendChild(subPickRow('HLS through StremioK’s service', HLS_ROUTES, 'hls', store));
|
|
1837
|
+
wrap.appendChild(U.el('div', 'hint', 'Seek step: FF / REW jump three. Buffer: More or Most starts slower but stops less on a slow connection. Reconnect: a live channel that drops opens again (BACK stops it). HLS through StremioK’s service: for a host that wants headers the TV’s player can’t send; a step more before it starts.'));
|
|
1647
1838
|
focusSettings();
|
|
1648
1839
|
}
|
|
1649
1840
|
function settingsSkipping(wrap) {
|
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) : '');
|
|
90
|
+
(force && opts && opts.fix === false ? '&fix=0' : '') + (force && cc ? '&cc=' + encodeURIComponent(cc) : '') + (force && opts && opts.film ? '&film=1' : '');
|
|
91
91
|
return U.getJSON(PROXY + q + a.q, force ? 5000 : 30000, 65536, cancel || null, a.h);
|
|
92
92
|
});
|
|
93
93
|
}
|
package/package.json
CHANGED
package/service/index.js
CHANGED
|
@@ -2003,6 +2003,7 @@ function liveGet(u, who, max, cb, part) {
|
|
|
2003
2003
|
var h = { 'User-Agent': who.ua || TV_UA };
|
|
2004
2004
|
if (who.ref) { h.Referer = who.ref; }
|
|
2005
2005
|
if (who.cookie) { h.Cookie = who.cookie; }
|
|
2006
|
+
if (who.range) { h.Range = who.range; } // (a film's piece that's part of a file: EXT-X-BYTERANGE)
|
|
2006
2007
|
var opts = { hostname: pu.hostname, port: pu.port, path: pu.path, headers: h };
|
|
2007
2008
|
if (pu.protocol === 'https:' && caList().length) { opts.ca = caList(); }
|
|
2008
2009
|
var chunks = [], size = 0, done = false;
|
|
@@ -2021,7 +2022,8 @@ function liveGet(u, who, max, cb, part) {
|
|
|
2021
2022
|
if (!gone) { get(urllib.resolve(url, resp.headers.location)); }
|
|
2022
2023
|
return;
|
|
2023
2024
|
}
|
|
2024
|
-
if (sc
|
|
2025
|
+
if (who.range && sc === 200) { resp.resume(); end(upError('the server sent the whole file, not the part asked for', 502)); return; }
|
|
2026
|
+
if (sc !== 200 && !(sc === 206 && who.range)) { resp.resume(); end(upError('HTTP ' + sc, sc >= 400 && sc < 600 ? sc : 502)); return; }
|
|
2025
2027
|
resp.on('data', function (c) {
|
|
2026
2028
|
if (done) { return; }
|
|
2027
2029
|
chunks.push(c); size += c.length; held += c.length; _liveHeld += c.length;
|
|
@@ -2489,31 +2491,57 @@ function ccList(s, text, base, k) {
|
|
|
2489
2491
|
// A playlist with its links through the relay: a master's variants and renditions (m), a media
|
|
2490
2492
|
// playlist's segments (s, numbered from its media sequence); encrypted or fMP4 segments, keys:
|
|
2491
2493
|
// fetched directly (their absolute links).
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
+
// A film's relay (&film=1: HLS through StremioK's service) keeps every link (up to
|
|
2495
|
+
// LIVE_FILM_LINKS: seeking goes back to any of them), a live channel's its last LIVE_LINKS.
|
|
2496
|
+
// raw: a key, an init section or an encrypted / fMP4 piece, passed on as it is; range: a byte
|
|
2497
|
+
// range of its link ('bytes=a-b').
|
|
2498
|
+
var LIVE_FILM_LINKS = 30000, LIVE_FILM_IDLE_MS = 3 * 3600 * 1000;
|
|
2499
|
+
function liveLink(s, url, kind, seq, ch, raw, range) {
|
|
2500
|
+
var key = kind + (ch !== undefined ? ch : '') + (range ? '@' + range : '') + ' ' + url;
|
|
2494
2501
|
if (s.at[key] !== undefined) { return s.at[key]; }
|
|
2495
|
-
var n = s.next
|
|
2496
|
-
s.links[n] = { url: url, kind: kind, seq: seq, ch: ch, key: key };
|
|
2502
|
+
var n = s.next++, keep = s.film ? LIVE_FILM_LINKS : LIVE_LINKS;
|
|
2503
|
+
s.links[n] = { url: url, kind: kind, seq: seq, ch: ch, key: key, raw: !!raw, range: range || '' };
|
|
2497
2504
|
s.at[key] = n;
|
|
2498
|
-
var old = s.links[n -
|
|
2499
|
-
if (old) { delete s.at[old.key]; delete s.links[n -
|
|
2505
|
+
var old = s.links[n - keep];
|
|
2506
|
+
if (old) { delete s.at[old.key]; delete s.links[n - keep]; }
|
|
2500
2507
|
return n;
|
|
2501
2508
|
}
|
|
2509
|
+
// EXT-X-BYTERANGE's "<length>[@<offset>]" as a Range header, after the one before it (a piece
|
|
2510
|
+
// without an offset follows the last of the same link): { range, end } or null.
|
|
2511
|
+
function liveRange(v, last, url) {
|
|
2512
|
+
var m = /^\s*(\d+)(?:@(\d+))?\s*$/.exec(v || '');
|
|
2513
|
+
if (!m) { return null; }
|
|
2514
|
+
var len = +m[1], off = m[2] !== undefined ? +m[2] : (last && last.url === url ? last.end : 0);
|
|
2515
|
+
if (!(len > 0)) { return null; }
|
|
2516
|
+
return { range: 'bytes=' + off + '-' + (off + len - 1), end: off + len, url: url };
|
|
2517
|
+
}
|
|
2502
2518
|
function liveBase(s) { return 'http://localhost:' + PORT + '/live/' + s.id + '/'; }
|
|
2503
2519
|
function liveRewrite(s, text, base) {
|
|
2504
2520
|
var master = /#EXT-X-STREAM-INF/.test(text), direct = !master && /#EXT-X-KEY:METHOD=(?!NONE)|#EXT-X-MAP/.test(text);
|
|
2505
2521
|
var sq = /#EXT-X-MEDIA-SEQUENCE:\s*(\d+)/.exec(text), seq = sq ? +sq[1] : 0, pre = liveBase(s);
|
|
2522
|
+
var span = null, last = null; // (a film's: the byte range of the next piece, and of the one before)
|
|
2506
2523
|
return String(text).split(/\r?\n/).map(function (ln) {
|
|
2507
2524
|
var t = ln.trim();
|
|
2508
2525
|
if (!t) { return ln; }
|
|
2509
2526
|
if (t.charAt(0) === '#') {
|
|
2527
|
+
if (s.film && /^#EXT-X-BYTERANGE:/.test(t)) { span = t.slice(17); return ln; }
|
|
2510
2528
|
return t.replace(/URI="([^"]*)"/, function (all, v) {
|
|
2511
2529
|
var abs = urllib.resolve(base, v);
|
|
2512
|
-
|
|
2530
|
+
if (/^#EXT-X-MEDIA:/.test(t)) { return 'URI="' + pre + 'm?n=' + liveLink(s, abs, 'm') + '"'; }
|
|
2531
|
+
if (s.film && /^#EXT-X-(KEY|MAP|SESSION-KEY):/.test(t)) { // (a film's key or init section: with its headers too)
|
|
2532
|
+
var br = /^#EXT-X-MAP:/.test(t) && /BYTERANGE="([^"]*)"/.exec(t), r = br ? liveRange(br[1], null, abs) : null;
|
|
2533
|
+
return 'URI="' + pre + 's?n=' + liveLink(s, abs, 's', -1, undefined, true, r ? r.range : '') + '"';
|
|
2534
|
+
}
|
|
2535
|
+
return 'URI="' + abs + '"';
|
|
2513
2536
|
});
|
|
2514
2537
|
}
|
|
2515
2538
|
var abs = urllib.resolve(base, t);
|
|
2516
2539
|
if (master) { return pre + 'm?n=' + liveLink(s, abs, 'm'); }
|
|
2540
|
+
if (s.film) {
|
|
2541
|
+
var rg = span !== null ? liveRange(span, last, abs) : null;
|
|
2542
|
+
span = null; last = rg;
|
|
2543
|
+
return pre + 's?n=' + liveLink(s, abs, 's', seq++, undefined, direct, rg ? rg.range : '');
|
|
2544
|
+
}
|
|
2517
2545
|
if (direct) { seq++; return abs; }
|
|
2518
2546
|
return pre + 's?n=' + liveLink(s, abs, 's', seq++);
|
|
2519
2547
|
}).join('\n');
|
|
@@ -2526,14 +2554,14 @@ function liveSession(u, who, opts) {
|
|
|
2526
2554
|
delete _live[ids[0]];
|
|
2527
2555
|
}
|
|
2528
2556
|
var s = { id: crypto.randomBytes(16).toString('hex'), ua: who.ua, ref: who.ref, cookie: who.cookie || '', links: {}, at: {}, next: 0, last: Date.now(), a: liveAudio(),
|
|
2529
|
-
fix: opts.fix !== false, cc: opts.cc && opts.cc.length ? opts.cc : null, c: ccState(), got: Object.create(null) };
|
|
2557
|
+
fix: opts.fix !== false && !opts.film, cc: opts.cc && opts.cc.length && !opts.film ? opts.cc : null, film: !!opts.film, c: ccState(), got: Object.create(null) };
|
|
2530
2558
|
_live[s.id] = s;
|
|
2531
2559
|
s.top = liveLink(s, u, 'm');
|
|
2532
2560
|
return s;
|
|
2533
2561
|
}
|
|
2534
2562
|
function livePurge() {
|
|
2535
2563
|
var now = Date.now();
|
|
2536
|
-
Object.keys(_live).forEach(function (id) { if (now - _live[id].last > LIVE_IDLE_MS) { delete _live[id]; } });
|
|
2564
|
+
Object.keys(_live).forEach(function (id) { if (now - _live[id].last > (_live[id].film ? LIVE_FILM_IDLE_MS : LIVE_IDLE_MS)) { delete _live[id]; } }); // (a film may be paused a while)
|
|
2537
2565
|
}
|
|
2538
2566
|
// The look: the playlist (a master's first variant), then the start of the segment a player
|
|
2539
2567
|
// starts with (the third from the end); with captions in that start, the whole segment (up to
|
|
@@ -2594,7 +2622,7 @@ function liveControl(req, res, path, query, leaving) {
|
|
|
2594
2622
|
if (!/^https?:\/\/[^\s]+$/i.test(u) || u.length > 2000) { send(res, 400, 'text/plain', 'bad link'); return; }
|
|
2595
2623
|
var cc = ccAsked(q.cc);
|
|
2596
2624
|
if (q.force === '1') {
|
|
2597
|
-
var sf = liveSession(u, who, { fix: q.fix !== '0', cc: cc });
|
|
2625
|
+
var sf = liveSession(u, who, { fix: q.fix !== '0', cc: cc, film: q.film === '1' });
|
|
2598
2626
|
send(res, 200, 'application/json', JSON.stringify({ fix: true, sure: true, why: 'asked for', url: liveBase(sf) + 'm?n=' + sf.top }));
|
|
2599
2627
|
return;
|
|
2600
2628
|
}
|
|
@@ -2615,11 +2643,13 @@ function liveControl(req, res, path, query, leaving) {
|
|
|
2615
2643
|
try { return ccSegment(s.c, body, link.seq); } catch (e) { log('live captions: ' + (e && e.message)); s.c = ccState(); return null; }
|
|
2616
2644
|
}
|
|
2617
2645
|
if (kind === 'v' && s.c.segs[link.seq]) { send(res, 200, 'text/vtt; charset=utf-8', ccVtt(s.c.segs[link.seq], link.ch)); return; }
|
|
2618
|
-
|
|
2646
|
+
var who = link.range ? { ua: s.ua, ref: s.ref, cookie: s.cookie, range: link.range } : s; // (a byte range: asked as one)
|
|
2647
|
+
leaving.push((seg && s.cc ? liveShared : liveGet)(link.url, who, seg ? LIVE_SEG_MAX : LIVE_LIST_MAX, function (err, body, at) {
|
|
2619
2648
|
if (err) { send(res, err.status || 502, 'text/plain', 'failed: ' + (err.message || 'unknown')); return; }
|
|
2620
2649
|
if (kind === 'v') { var cs = captions(body); send(res, 200, 'text/vtt; charset=utf-8', cs ? ccVtt(cs, link.ch) : 'WEBVTT\n'); return; }
|
|
2621
2650
|
if (kind === 'c') { send(res, 200, 'application/vnd.apple.mpegurl', ccList(s, body.toString('utf8'), at, link.ch)); return; }
|
|
2622
2651
|
if (kind !== 's') { send(res, 200, 'application/vnd.apple.mpegurl', s.cc && kind === 'm' && +q.n === s.top ? ccMaster(s, body.toString('utf8'), at) : liveRewrite(s, body.toString('utf8'), at)); return; }
|
|
2652
|
+
if (link.raw) { send(res, 200, 'application/octet-stream', body); return; } // (a film's key, init section or encrypted piece: as it came)
|
|
2623
2653
|
var out = body;
|
|
2624
2654
|
if (s.cc) { captions(body); }
|
|
2625
2655
|
if (s.fix) { try { out = liveFix(s, body, link.seq); } catch (e) { log('live: ' + (e && e.message)); s.a = liveAudio(); } }
|
|
@@ -3199,8 +3229,10 @@ var STALKER_VOD_TAKE = 42, STALKER_VOD_PAGES = 4, STALKER_VOD_CATS_MS = 10 * 600
|
|
|
3199
3229
|
// What a portal answered (a list from a position, a search, a series' seasons): kept
|
|
3200
3230
|
// STALKER_VOD_KEEP_MS, the last STALKER_VOD_KEEP a portal, so a row or category shown again isn't
|
|
3201
3231
|
// asked again (a portal may stop answering many quick asks); fresh=1 (Reload) lets it all go.
|
|
3232
|
+
// &keep=: the app's Stalker films and series setting, in minutes (0: not kept; up to 10).
|
|
3202
3233
|
var STALKER_VOD_KEEP_MS = 10 * 60000, STALKER_VOD_KEEP = 40;
|
|
3203
|
-
function
|
|
3234
|
+
function stalkerKeepMs(q) { var m = /^\d{1,2}$/.test(q.keep || '') ? +q.keep : 10; return Math.min(m, 10) * 60000; }
|
|
3235
|
+
function stalkerKept(s, key, ms) { var k = s.vodKept && s.vodKept[key]; return k && Date.now() - k.at < Math.min(ms, STALKER_VOD_KEEP_MS) ? k.v : null; }
|
|
3204
3236
|
function stalkerKeepVod(s, key, v) {
|
|
3205
3237
|
if (!s.vodKept) { s.vodKept = Object.create(null); s.vodOrder = []; }
|
|
3206
3238
|
if (!s.vodKept[key]) { s.vodOrder.push(key); while (s.vodOrder.length > STALKER_VOD_KEEP) { delete s.vodKept[s.vodOrder.shift()]; } }
|
|
@@ -3364,7 +3396,9 @@ function stalkerControl(req, res, path, query, leaving) {
|
|
|
3364
3396
|
var type = q.type === 'series' ? 'series' : 'movie', what = String(q.do || '');
|
|
3365
3397
|
if (q.fresh === '1') { s.vodCats = null; s.vodKept = null; s.vodOrder = null; } // (Reload: all of it read again)
|
|
3366
3398
|
var vkey = what === 'list' || what === 'seasons' ? [what, type, q.cat || '*', String(q.q || '').trim().slice(0, 120), parseInt(q.skip, 10) || 0, q.id || '', q.via || ''].join('|') : '';
|
|
3367
|
-
var
|
|
3399
|
+
var keepMs = stalkerKeepMs(q);
|
|
3400
|
+
if (!keepMs) { vkey = ''; } // (not kept: asked each time)
|
|
3401
|
+
var kept = vkey && stalkerKept(s, vkey, keepMs);
|
|
3368
3402
|
if (kept) { json(kept); return; }
|
|
3369
3403
|
stalkerWith(s, portal, mac, ctl, function (ss, done) {
|
|
3370
3404
|
if (what === 'cats') { stalkerVodCats(ss, type, ctl, function (err, list) { done(err, { cats: list }); }); return; }
|