stremiok 2.2.3 → 2.2.5
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 +15 -0
- package/README.md +5 -4
- package/config.xml +1 -1
- package/index.html +34 -34
- package/js/app.js +9 -2
- package/js/epg.js +1 -1
- package/js/iptv.js +34 -5
- package/js/stremio.js +1 -1
- package/js/view-core.js +38 -5
- package/js/view-detail.js +37 -10
- package/js/view-guide.js +16 -14
- package/js/view-home.js +10 -5
- package/js/view-settings.js +21 -5
- package/js/views.js +1 -1
- package/js/ytplay.js +6 -2
- package/package.json +1 -1
- package/service/index.js +55 -17
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,21 @@
|
|
|
3
3
|
What changed in each version of StremioK, newest first. How everything works is in the
|
|
4
4
|
[user guide](docs/USER-GUIDE.md).
|
|
5
5
|
|
|
6
|
+
## 2.2.5 — 2026-11-01
|
|
7
|
+
- **A Stalker portal's Channel groups** (OK on it, in Settings › Content › IPTV): tick the genres you
|
|
8
|
+
want and only those are read, however big the portal is.
|
|
9
|
+
- **Whole portal** waits longer when a portal stops answering, slows down after that, and keeps what
|
|
10
|
+
it read instead of losing it all at the time limit.
|
|
11
|
+
|
|
12
|
+
## 2.2.4 — 2026-10-31
|
|
13
|
+
- **The remote's ▶ Play key:** on a movie, an episode or a channel (its card, its row, its sources,
|
|
14
|
+
its row in the Guide), plays the top source at once, whatever *Skip the source list* says.
|
|
15
|
+
- **Titles in a Home row** has *Unlimited*, for catalogs and IPTV groups.
|
|
16
|
+
- **Stalker channels** (Settings › Content › IPTV): *Whole portal* reads past the first 100 pages
|
|
17
|
+
(about 1,400 channels), with a warning; a portal read that stopped short says so.
|
|
18
|
+
- **TV guide:** a guide read again (*Reload*, *Auto-refresh*) reaches the Guide tab at once; its grid
|
|
19
|
+
could keep the old titles for up to 2 hours.
|
|
20
|
+
|
|
6
21
|
## 2.2.3 — 2026-10-30
|
|
7
22
|
- **Xtream films and series:** an account's films and series in the Movies and Series tabs (a show
|
|
8
23
|
is one tile, its episodes on its page), Discover by its categories, and Search. The IPTV tab
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
StremioK is a from-scratch Stremio-addon streaming client for Samsung Tizen TVs.
|
|
4
4
|
It was originally built for a 2017 UN50MU6100 running Tizen 3.0
|
|
5
|
-
(~Chromium 47) and is also tested on a 2021 QN55Q80AAG running Tizen 6.0.
|
|
5
|
+
(~Chromium 47) and is also tested on a 2021 QN55Q80AAG running Tizen 6.0. A user reports it working on Tizen 4 too.
|
|
6
6
|
|
|
7
7
|
Old Samsung Tizen TVs run web applications rather than Android APKs. StremioK is
|
|
8
8
|
therefore written in old-Chromium-compatible HTML, JavaScript (ES5) and CSS, and plays
|
|
@@ -37,7 +37,8 @@ video through Samsung's AVPlay API.
|
|
|
37
37
|
with SponsorBlock, DeArrow, chapters and captions.
|
|
38
38
|
- **Local:** the videos on a USB drive, matched to their titles.
|
|
39
39
|
- **Torrents**, through Stremio's streaming server or a TorrServer you run on your network.
|
|
40
|
-
- **Made for the remote:** D-pad navigation throughout;
|
|
40
|
+
- **Made for the remote:** D-pad navigation throughout; ▶ Play on a movie, episode or channel plays
|
|
41
|
+
its top source at once; hold OK where an item has more to
|
|
41
42
|
offer (*Hold OK for more* says so); zoom up to 140% for reading from further away.
|
|
42
43
|
|
|
43
44
|
## Install
|
|
@@ -89,8 +90,8 @@ your progress, settings and copies that let it start faster (see
|
|
|
89
90
|
|
|
90
91
|
- AVPlay behavior varies by TV generation, codec and HLS provider.
|
|
91
92
|
- Torrents play only through a streaming server you run on your network.
|
|
92
|
-
- Home rows show
|
|
93
|
-
yours); Discover pages through the rest.
|
|
93
|
+
- Home rows show 30 titles of a catalog unless you change it, up to *Unlimited* (★ Favorites shows
|
|
94
|
+
all yours); Discover pages through the rest.
|
|
94
95
|
- No StremioK account and no profiles: settings, addons and progress stay on the TV. The
|
|
95
96
|
only sync is optional: Trakt (watched marks, Continue Watching, ratings).
|
|
96
97
|
- Subtitles use an HTML overlay; gzipped (`.gz`) subtitle files aren't decoded.
|
package/config.xml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets"
|
|
3
|
-
id="http://stremiok.tizen/StremioKTizen" version="2.2.
|
|
3
|
+
id="http://stremiok.tizen/StremioKTizen" version="2.2.5" viewmodes="maximized">
|
|
4
4
|
<tizen:application id="StremioK01.StremioK" package="StremioK01" required_version="3.0"/>
|
|
5
5
|
<content src="index.html"/>
|
|
6
6
|
<feature name="http://tizen.org/feature/screen.size.all"/>
|
package/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<meta name="viewport" content="width=1920, height=1080, user-scalable=no">
|
|
6
6
|
<title>StremioK</title>
|
|
7
|
-
<link rel="stylesheet" href="css/style.css?v=2.2.
|
|
7
|
+
<link rel="stylesheet" href="css/style.css?v=2.2.5">
|
|
8
8
|
</head>
|
|
9
9
|
<body>
|
|
10
10
|
<!-- CSS-applied sentinel (kept off-screen); app.js waits for its width before rendering -->
|
|
@@ -53,38 +53,38 @@
|
|
|
53
53
|
|
|
54
54
|
<!-- Load order matters: polyfills -> util -> iptv -> data -> input -> tvapps -> player parts -> player -> ytplay -> view parts -> views -> app -->
|
|
55
55
|
<!-- ?v= busts the TV webview cache on every release (keep in sync with package.json) -->
|
|
56
|
-
<script src="js/polyfills.js?v=2.2.
|
|
57
|
-
<script src="js/util.js?v=2.2.
|
|
58
|
-
<script src="js/iptv.js?v=2.2.
|
|
59
|
-
<script src="js/xtvod.js?v=2.2.
|
|
60
|
-
<script src="js/epg.js?v=2.2.
|
|
61
|
-
<script src="js/youtube.js?v=2.2.
|
|
62
|
-
<script src="js/stremio.js?v=2.2.
|
|
63
|
-
<script src="js/trakt.js?v=2.2.
|
|
64
|
-
<script src="js/keys.js?v=2.2.
|
|
65
|
-
<script src="js/focus.js?v=2.2.
|
|
66
|
-
<script src="js/tvapps.js?v=2.2.
|
|
67
|
-
<script src="js/player-core.js?v=2.2.
|
|
68
|
-
<script src="js/player-store.js?v=2.2.
|
|
69
|
-
<script src="js/player-lang.js?v=2.2.
|
|
70
|
-
<script src="js/player-quality.js?v=2.2.
|
|
71
|
-
<script src="js/player-subs.js?v=2.2.
|
|
72
|
-
<script src="js/player-audio.js?v=2.2.
|
|
73
|
-
<script src="js/player-controls.js?v=2.2.
|
|
74
|
-
<script src="js/player.js?v=2.2.
|
|
75
|
-
<script src="js/ytplay.js?v=2.2.
|
|
76
|
-
<script src="js/local.js?v=2.2.
|
|
77
|
-
<script src="js/downloads.js?v=2.2.
|
|
78
|
-
<script src="js/stremio-account.js?v=2.2.
|
|
79
|
-
<script src="js/view-core.js?v=2.2.
|
|
80
|
-
<script src="js/view-home.js?v=2.2.
|
|
81
|
-
<script src="js/view-guide.js?v=2.2.
|
|
82
|
-
<script src="js/view-detail.js?v=2.2.
|
|
83
|
-
<script src="js/view-search.js?v=2.2.
|
|
84
|
-
<script src="js/view-settings.js?v=2.2.
|
|
85
|
-
<script src="js/view-discover.js?v=2.2.
|
|
86
|
-
<script src="js/views.js?v=2.2.
|
|
87
|
-
<script src="js/app.js?v=2.2.
|
|
88
|
-
<script src="js/hubpreview.js?v=2.2.
|
|
56
|
+
<script src="js/polyfills.js?v=2.2.5"></script>
|
|
57
|
+
<script src="js/util.js?v=2.2.5"></script>
|
|
58
|
+
<script src="js/iptv.js?v=2.2.5"></script>
|
|
59
|
+
<script src="js/xtvod.js?v=2.2.5"></script>
|
|
60
|
+
<script src="js/epg.js?v=2.2.5"></script>
|
|
61
|
+
<script src="js/youtube.js?v=2.2.5"></script>
|
|
62
|
+
<script src="js/stremio.js?v=2.2.5"></script>
|
|
63
|
+
<script src="js/trakt.js?v=2.2.5"></script>
|
|
64
|
+
<script src="js/keys.js?v=2.2.5"></script>
|
|
65
|
+
<script src="js/focus.js?v=2.2.5"></script>
|
|
66
|
+
<script src="js/tvapps.js?v=2.2.5"></script>
|
|
67
|
+
<script src="js/player-core.js?v=2.2.5"></script>
|
|
68
|
+
<script src="js/player-store.js?v=2.2.5"></script>
|
|
69
|
+
<script src="js/player-lang.js?v=2.2.5"></script>
|
|
70
|
+
<script src="js/player-quality.js?v=2.2.5"></script>
|
|
71
|
+
<script src="js/player-subs.js?v=2.2.5"></script>
|
|
72
|
+
<script src="js/player-audio.js?v=2.2.5"></script>
|
|
73
|
+
<script src="js/player-controls.js?v=2.2.5"></script>
|
|
74
|
+
<script src="js/player.js?v=2.2.5"></script>
|
|
75
|
+
<script src="js/ytplay.js?v=2.2.5"></script>
|
|
76
|
+
<script src="js/local.js?v=2.2.5"></script>
|
|
77
|
+
<script src="js/downloads.js?v=2.2.5"></script>
|
|
78
|
+
<script src="js/stremio-account.js?v=2.2.5"></script>
|
|
79
|
+
<script src="js/view-core.js?v=2.2.5"></script>
|
|
80
|
+
<script src="js/view-home.js?v=2.2.5"></script>
|
|
81
|
+
<script src="js/view-guide.js?v=2.2.5"></script>
|
|
82
|
+
<script src="js/view-detail.js?v=2.2.5"></script>
|
|
83
|
+
<script src="js/view-search.js?v=2.2.5"></script>
|
|
84
|
+
<script src="js/view-settings.js?v=2.2.5"></script>
|
|
85
|
+
<script src="js/view-discover.js?v=2.2.5"></script>
|
|
86
|
+
<script src="js/views.js?v=2.2.5"></script>
|
|
87
|
+
<script src="js/app.js?v=2.2.5"></script>
|
|
88
|
+
<script src="js/hubpreview.js?v=2.2.5"></script>
|
|
89
89
|
</body>
|
|
90
90
|
</html>
|
package/js/app.js
CHANGED
|
@@ -55,11 +55,11 @@ var App = (function () {
|
|
|
55
55
|
|
|
56
56
|
// Live TV: skip the info page — load sources and (if a single one) play immediately.
|
|
57
57
|
// channels: { list: [{ meta, card }], idx } — the row it was picked from, for CH+/CH−
|
|
58
|
-
function openLive(type, id, preview, channels) {
|
|
58
|
+
function openLive(type, id, preview, channels, opts) {
|
|
59
59
|
if (!id) { return; }
|
|
60
60
|
pushFrame();
|
|
61
61
|
showScreen('detail');
|
|
62
|
-
Views.renderLive(type, id, preview, channels);
|
|
62
|
+
Views.renderLive(type, id, preview, channels, opts);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
// A person's page (from a title's cast row).
|
|
@@ -210,6 +210,13 @@ var App = (function () {
|
|
|
210
210
|
return true;
|
|
211
211
|
}
|
|
212
212
|
case 'BACK': back(); return true;
|
|
213
|
+
case 'PLAY':
|
|
214
|
+
case 'PLAYPAUSE': { // (a movie, an episode or a channel: its top source, as with Skip the source list on)
|
|
215
|
+
var cp = Focus.current();
|
|
216
|
+
if (cp && cp.__onplay) { cp.__onplay(cp); }
|
|
217
|
+
else if (_current === 'detail' && !Views.isModalOpen()) { Views.playKey(); }
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
213
220
|
default:
|
|
214
221
|
if (/^NUM\d$/.test(action)) { numberKey(+action.slice(3)); }
|
|
215
222
|
return true;
|
package/js/epg.js
CHANGED
|
@@ -122,7 +122,7 @@ var EPG = (function () {
|
|
|
122
122
|
['state', 'at', 'channels', 'programmes', 'partial', 'error'].forEach(function (f) { g[f] = r && r[f]; });
|
|
123
123
|
if (g.state === 'loading' && n < POLLS) { g.timer = setTimeout(function () { g.timer = null; ask(n + 1); }, n < POLL_MS.length ? POLL_MS[n] : POLL_MS_LATER); }
|
|
124
124
|
if (g.state + '|' + g.at !== was) {
|
|
125
|
-
if (g.state === 'ready') { forget(url); } // (read again: what's on, asked again)
|
|
125
|
+
if (g.state === 'ready') { _gen++; forget(url); } // (read again: what's on, and the Guide tab's grid, asked again)
|
|
126
126
|
changed();
|
|
127
127
|
}
|
|
128
128
|
}, function () {
|
package/js/iptv.js
CHANGED
|
@@ -31,6 +31,7 @@ var IPTV = (function () {
|
|
|
31
31
|
if (p.off === true) { o.off = true; }
|
|
32
32
|
if (typeof p.guide === 'string' && U.parseUrl(p.guide)) { o.guide = p.guide; } // (its TV guide, yours: see EPG.guideUrl)
|
|
33
33
|
if (macOf(p.mac)) { o.mac = macOf(p.mac); } // (a Stalker portal: see addStalker)
|
|
34
|
+
if (o.mac && Array.isArray(p.genres) && p.genres.length) { o.genres = p.genres; } // (only those read: see setStalkerGroups)
|
|
34
35
|
return o;
|
|
35
36
|
});
|
|
36
37
|
}
|
|
@@ -203,12 +204,34 @@ var IPTV = (function () {
|
|
|
203
204
|
return checkedUrl(s);
|
|
204
205
|
}
|
|
205
206
|
function isStalker(p) { return !!(p && p.mac); }
|
|
207
|
+
// Settings › Content › IPTV › Stalker channels: a portal read past its first 100 pages, up to
|
|
208
|
+
// 30,000 channels (adding one is still checked by those pages: stalkerCheck).
|
|
209
|
+
var STALKER_ALL_KEY = 'stremiok.iptv.stalkerall';
|
|
210
|
+
function stalkerAll() { return U.store.get(STALKER_ALL_KEY, false) === true; }
|
|
211
|
+
function setStalkerAll(on) { U.store.set(STALKER_ALL_KEY, !!on); }
|
|
212
|
+
// A portal's Channel groups: its genres (the service's { genres: [{ id, title }] } or { why }),
|
|
213
|
+
// and the ones to read (none: as Stalker channels says). Read again by whoever sets them.
|
|
214
|
+
function stalkerGroups(id) {
|
|
215
|
+
var list = getPlaylists(), i = find(list, id);
|
|
216
|
+
if (i < 0 || typeof YTPlay === 'undefined' || !YTPlay.stalkerGenres) { return Promise.reject(new Error('Stalker portals are read by StremioK’s service (not in a desktop browser)')); }
|
|
217
|
+
return YTPlay.stalkerGenres(list[i].url, list[i].mac).then(function (r) {
|
|
218
|
+
if (!r || !Array.isArray(r.genres)) { throw new Error('Couldn’t read the portal: ' + ((r && r.why) || 'no answer')); }
|
|
219
|
+
return r.genres;
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
function setStalkerGroups(id, ids) {
|
|
223
|
+
var list = getPlaylists(), i = find(list, id);
|
|
224
|
+
if (i < 0) { return false; }
|
|
225
|
+
if (ids && ids.length) { list[i].genres = ids; } else { delete list[i].genres; }
|
|
226
|
+
savePlaylists(list);
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
206
229
|
// Checked through the service (its channels read): { ok, count }, { refused, why },
|
|
207
230
|
// { unreachable, why } or { noService } (a desktop browser).
|
|
208
231
|
function stalkerCheck(portal, mac) {
|
|
209
232
|
if (typeof YTPlay === 'undefined' || !YTPlay.stalkerList) { return Promise.resolve({ noService: true }); }
|
|
210
233
|
return YTPlay.stalkerList(portal, mac).then(function (r) {
|
|
211
|
-
if (r && typeof r.m3u === 'string') { return { ok: true, count: r.count || 0 }; }
|
|
234
|
+
if (r && typeof r.m3u === 'string') { return { ok: true, count: r.count || 0, cut: r.cut || null }; }
|
|
212
235
|
return r && r.refused ? { refused: true, why: '' + (r.why || '') } : { unreachable: true, why: '' + ((r && r.why) || '') };
|
|
213
236
|
}, function (e) { return /no service/.test((e && e.message) || '') ? { noService: true } : { unreachable: true, why: U.problem(e) }; });
|
|
214
237
|
}
|
|
@@ -474,7 +497,7 @@ var IPTV = (function () {
|
|
|
474
497
|
if (/^http:/i.test(playlist.url)) { // (Settings › Diagnostics › Logs)
|
|
475
498
|
U.log('iptv', 'Playlist “' + label(playlist) + '” is downloaded over unencrypted http:// — anyone on the network path can see or change it (and ' + (isStalker(playlist) ? 'its MAC address' : 'any username / password in its link') + ')');
|
|
476
499
|
}
|
|
477
|
-
var src = playlist.url + (playlist.mac ? '#mac=' + playlist.mac : ''); // (its saved copy: this portal and
|
|
500
|
+
var src = playlist.url + (playlist.mac ? '#mac=' + playlist.mac : '') + (playlist.genres ? '#genres=' + playlist.genres.join(',') : ''); // (its saved copy: this portal, MAC and groups')
|
|
478
501
|
|
|
479
502
|
function finish(text, at) {
|
|
480
503
|
st.fetchedAt = at || 0;
|
|
@@ -511,8 +534,14 @@ var IPTV = (function () {
|
|
|
511
534
|
// A Stalker portal's channels, from the service (see stalkerCheck): its M3U text.
|
|
512
535
|
function stalkerText() {
|
|
513
536
|
if (typeof YTPlay === 'undefined' || !YTPlay.stalkerList) { return Promise.reject(new Error('Stalker portals are read by StremioK’s service (not in a desktop browser)')); }
|
|
514
|
-
return YTPlay.stalkerList(playlist.url, playlist.mac).then(function (r) {
|
|
515
|
-
if (r && typeof r.m3u === 'string') {
|
|
537
|
+
return YTPlay.stalkerList(playlist.url, playlist.mac, stalkerAll(), playlist.genres).then(function (r) {
|
|
538
|
+
if (r && typeof r.m3u === 'string') {
|
|
539
|
+
if (r.cut) { // (stopped short: said, with what's there)
|
|
540
|
+
st.cut = r.cut.total || true;
|
|
541
|
+
U.log('iptv', 'Stalker portal “' + label(playlist) + '”: read ' + (r.count || 0) + ' channels' + (r.cut.total ? ' of ' + r.cut.total : '') + ', and stopped' + (r.cut.why ? ' (' + r.cut.why + ')' : ''));
|
|
542
|
+
}
|
|
543
|
+
return r.m3u;
|
|
544
|
+
}
|
|
516
545
|
throw new Error((r && r.refused ? 'The portal refused it: ' : 'Couldn’t read the portal: ') + ((r && r.why) || 'no answer'));
|
|
517
546
|
}, function (e) {
|
|
518
547
|
throw new Error(/no service/.test((e && e.message) || '') ? 'Stalker portals are read by StremioK’s service (not in a desktop browser)' : 'Couldn’t reach StremioK’s service: ' + U.problem(e));
|
|
@@ -745,7 +774,7 @@ var IPTV = (function () {
|
|
|
745
774
|
getPlaylists: getPlaylists, addPlaylist: addPlaylist, updatePlaylist: updatePlaylist,
|
|
746
775
|
removePlaylist: removePlaylist, renamePlaylist: renamePlaylist, setPlaylistOff: setPlaylistOff,
|
|
747
776
|
movePlaylist: movePlaylist, setPlaylistGuide: setPlaylistGuide, label: labelOf,
|
|
748
|
-
macOf: macOf, stalkerPortal: stalkerPortal, stalkerCheck: stalkerCheck, addStalker: addStalker, isStalker: isStalker,
|
|
777
|
+
macOf: macOf, stalkerPortal: stalkerPortal, stalkerCheck: stalkerCheck, addStalker: addStalker, isStalker: isStalker, stalkerAll: stalkerAll, setStalkerAll: setStalkerAll, stalkerGroups: stalkerGroups, setStalkerGroups: setStalkerGroups,
|
|
749
778
|
xtreamParts: xtreamParts, xtreamUrl: xtreamUrl, xtreamCheck: xtreamCheck, addXtream: addXtream, xtreamFormat: xtreamFormat, setXtreamFormat: setXtreamFormat,
|
|
750
779
|
isFavorite: isFavorite, setFavorite: setFavorite, refreshEvery: refreshEvery, setRefreshEvery: setRefreshEvery, readAt: readAt,
|
|
751
780
|
channels: function () { return _cache ? _cache.channels : []; }, channel: function (id) { return _cache ? _cache.byId[id] || null : null; }, isEnabled: isEnabled, reset: reset, status: status,
|
package/js/stremio.js
CHANGED
|
@@ -163,7 +163,7 @@ var Stremio = (function () {
|
|
|
163
163
|
var p = U.store.get(PREFS_KEY, {}) || {};
|
|
164
164
|
return { posterShape: p.posterShape || 'portrait', accent: p.accent || 'indigo', bg: p.bg || 'dark',
|
|
165
165
|
zoom: [110, 120, 130, 140].indexOf(p.zoom) !== -1 ? p.zoom : 100, // Settings > Appearance: everything bigger (percent)
|
|
166
|
-
rowCards: [50, 100, 200].indexOf(p.rowCards) !== -1 ? p.rowCards : 30, // Settings > Appearance: titles in a Home row
|
|
166
|
+
rowCards: p.rowCards === 'all' || [50, 100, 200].indexOf(p.rowCards) !== -1 ? p.rowCards : 30, // Settings > Appearance: titles in a Home row ('all': Unlimited)
|
|
167
167
|
formatsAuto: p.formatsAuto !== false, // Settings > Formats: mark "Not working" on its own
|
|
168
168
|
allowLocal: p.allowLocal === true, // Settings > Addons: home-network links from internet addons
|
|
169
169
|
addonWait: ADDON_WAITS.indexOf(p.addonWait) !== -1 ? p.addonWait : 0, // Settings > Addons: seconds to wait for an addon (0: Normal)
|
package/js/view-core.js
CHANGED
|
@@ -283,6 +283,29 @@ var ViewParts = {};
|
|
|
283
283
|
U.toast('Its channels now play as ' + (fmt === 'hls' ? 'MPEG-TS' : 'HLS') + ' (reading the account again…)', 4000);
|
|
284
284
|
renderSettings();
|
|
285
285
|
};
|
|
286
|
+
var groups = U.el('div', 'pill focusable modal-btn', 'Channel groups'); // (a Stalker portal: the genres to read)
|
|
287
|
+
groups.__onselect = function () {
|
|
288
|
+
closeModal();
|
|
289
|
+
U.toast('Asking the portal for its groups…', 4000);
|
|
290
|
+
IPTV.stalkerGroups(playlist.id).then(function (list) {
|
|
291
|
+
if (!list.length) { U.toast('The portal lists no groups', 4000); return; }
|
|
292
|
+
pickMany('Groups to read from “' + label + '”', list.map(function (g) { return { key: g.id, label: g.title }; }), {
|
|
293
|
+
on: playlist.genres, none: true,
|
|
294
|
+
button: function (n) { return n ? 'Read ' + n + ' group' + (n === 1 ? '' : 's') : 'Read as Stalker channels says'; }
|
|
295
|
+
}, function (keys) {
|
|
296
|
+
IPTV.setStalkerGroups(playlist.id, keys);
|
|
297
|
+
refreshAddonRows('local:iptv');
|
|
298
|
+
U.toast('Reading the portal…', 4000);
|
|
299
|
+
renderSettings();
|
|
300
|
+
Stremio.iptvReload(playlist.id).then(function () {
|
|
301
|
+
refreshAddonRows('local:iptv');
|
|
302
|
+
var st = Stremio.iptvStatus(playlist.id);
|
|
303
|
+
U.toast(st.error ? ('Reload failed: ' + st.error) : ('Loaded ' + st.count + ' channels'), 4000);
|
|
304
|
+
renderSettings();
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
}, function (e) { U.toast(U.problem(e), 5000); });
|
|
308
|
+
};
|
|
286
309
|
var reload = U.el('div', 'pill focusable modal-btn', 'Reload');
|
|
287
310
|
var remove = U.el('div', 'pill focusable modal-btn danger', 'Remove');
|
|
288
311
|
|
|
@@ -363,6 +386,7 @@ var ViewParts = {};
|
|
|
363
386
|
row.appendChild(edit);
|
|
364
387
|
if (!playlist.off && typeof EPG !== 'undefined' && EPG.available && EPG.available()) { row.appendChild(guide); }
|
|
365
388
|
if (!playlist.off && fmt) { row.appendChild(format); }
|
|
389
|
+
if (!playlist.off && IPTV.isStalker(playlist)) { row.appendChild(groups); }
|
|
366
390
|
if (!playlist.off) { row.appendChild(reload); }
|
|
367
391
|
row.appendChild(remove);
|
|
368
392
|
box.appendChild(row);
|
|
@@ -405,8 +429,8 @@ var ViewParts = {};
|
|
|
405
429
|
// Ticks in a popup (what to import): nothing ticked at first; OK on one ticks or unticks it,
|
|
406
430
|
// Select all ticks every one that can be (again: none); the button counts what's ticked.
|
|
407
431
|
// items: [{ key, label, have (already yours: shown as such, can't be ticked), note }];
|
|
408
|
-
// opts: { button(n) -> its label, haveText
|
|
409
|
-
// ticked (Cancel / BACK: nothing).
|
|
432
|
+
// opts: { button(n) -> its label, haveText, on (keys ticked at first), none (the button works
|
|
433
|
+
// with nothing ticked) }; onDone(keys) on the button with something ticked (Cancel / BACK: nothing).
|
|
410
434
|
function pickMany(title, items, opts, onDone) {
|
|
411
435
|
var existing = document.querySelector('.modal-overlay');
|
|
412
436
|
if (existing) { existing.parentNode.removeChild(existing); }
|
|
@@ -414,6 +438,7 @@ var ViewParts = {};
|
|
|
414
438
|
var box = U.el('div', 'modal-box pick-box');
|
|
415
439
|
box.appendChild(U.el('div', 'modal-msg', title));
|
|
416
440
|
var listEl = U.el('div', 'pick-list'), on = {}, nodes = [];
|
|
441
|
+
(opts.on || []).forEach(function (k) { on[k] = true; });
|
|
417
442
|
var can = items.filter(function (it) { return !it.have; });
|
|
418
443
|
var go = U.el('div', 'pill focusable modal-btn');
|
|
419
444
|
function ticked() { return items.filter(function (it) { return on[it.key]; }).map(function (it) { return it.key; }); }
|
|
@@ -446,7 +471,7 @@ var ViewParts = {};
|
|
|
446
471
|
var row = U.el('div', 'modal-row');
|
|
447
472
|
go.__onselect = function () {
|
|
448
473
|
var keys = ticked();
|
|
449
|
-
if (!keys.length) { U.toast('Nothing ticked: OK on one ticks it', 2500); return; }
|
|
474
|
+
if (!keys.length && !opts.none) { U.toast('Nothing ticked: OK on one ticks it', 2500); return; }
|
|
450
475
|
closeModal();
|
|
451
476
|
onDone(keys);
|
|
452
477
|
};
|
|
@@ -587,6 +612,11 @@ var ViewParts = {};
|
|
|
587
612
|
guideOnCard(c, meta.id);
|
|
588
613
|
c.__onlongpress = function () { liveSchedule(meta, c); };
|
|
589
614
|
}
|
|
615
|
+
function isLive() {
|
|
616
|
+
var t = titleType(meta.type || fallbackType);
|
|
617
|
+
var isTitle = t === 'movie' || t === 'series' || TITLE_ID.test(meta.id || '');
|
|
618
|
+
return !!fallbackType && fallbackType !== 'movie' && fallbackType !== 'series' && !isTitle && !/^(youtube|channel)$/i.test(fallbackType) && !/^(ytk|yt_id):/.test(meta.id || '');
|
|
619
|
+
}
|
|
590
620
|
c.__onselect = function () {
|
|
591
621
|
var t = titleType(meta.type || fallbackType);
|
|
592
622
|
// Live TV catalogs (anything that isn't movies/series) skip the info page and
|
|
@@ -595,13 +625,16 @@ var ViewParts = {};
|
|
|
595
625
|
// (a video plays from it at once, a channel lists its videos). So is anything that
|
|
596
626
|
// is a movie or series itself, or has a title's id, whatever its catalog's type
|
|
597
627
|
// (AIOMetadata's "anime" catalogs list movies and series: "mal:28851", a movie).
|
|
598
|
-
|
|
599
|
-
if (fallbackType && fallbackType !== 'movie' && fallbackType !== 'series' && !isTitle && !/^(youtube|channel)$/i.test(fallbackType) && !/^(ytk|yt_id):/.test(meta.id || '')) {
|
|
628
|
+
if (isLive()) {
|
|
600
629
|
App.openLive(t, meta.id, meta, rowChannels(c));
|
|
601
630
|
} else {
|
|
602
631
|
App.openDetail(t, meta.id, meta);
|
|
603
632
|
}
|
|
604
633
|
};
|
|
634
|
+
// the remote's Play key: a movie's or channel's top source; a series has no one episode, so its page
|
|
635
|
+
if (titleType(kind) === 'movie') { c.__onplay = function () { App.openDetail('movie', meta.id, meta, null, { playBest: true }); }; }
|
|
636
|
+
else if (titleType(kind) === 'series') { c.__onplay = function () { c.__onselect(); }; }
|
|
637
|
+
else if (fallbackType !== 'local' && isLive()) { c.__onplay = function () { App.openLive(titleType(kind), meta.id, meta, rowChannels(c), { playBest: true }); }; } // (a channel)
|
|
605
638
|
return c;
|
|
606
639
|
}
|
|
607
640
|
|
package/js/view-detail.js
CHANGED
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
return function still() { return _d === page && !(tok && tok.cancelled); };
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
function renderLive(type, id, preview, channels) {
|
|
48
|
+
function renderLive(type, id, preview, channels, opts) {
|
|
49
49
|
newPage();
|
|
50
50
|
_d = { type: type, id: id, meta: preview || { id: id, type: type }, mode: 'streams',
|
|
51
51
|
season: null, preview: preview || null, target: null,
|
|
@@ -70,6 +70,9 @@
|
|
|
70
70
|
}
|
|
71
71
|
if (playable.length === 1) {
|
|
72
72
|
startPlayback(playable[0], id, _d.streamLabel || _d.meta.name || 'Live');
|
|
73
|
+
} else if ((opts && opts.playBest) || _d.autoBest) { // (the remote's Play key)
|
|
74
|
+
var top = bestRow(rankRowsFor(list));
|
|
75
|
+
startPlayback(top ? top.st : playable[0], id, _d.streamLabel || _d.meta.name || 'Live');
|
|
73
76
|
} else {
|
|
74
77
|
drawDetail(); // multiple sources → straight to the source list
|
|
75
78
|
}
|
|
@@ -80,7 +83,7 @@
|
|
|
80
83
|
function renderDetail(type, id, preview, target, opts) {
|
|
81
84
|
newPage();
|
|
82
85
|
_d = { type: type, id: id, meta: null, mode: 'info', season: null, preview: preview || null, target: target || null };
|
|
83
|
-
var resume = (opts && opts.resume) || null;
|
|
86
|
+
var resume = (opts && opts.resume) || null, playBest = !!(opts && opts.playBest); // (playBest: the remote's Play key)
|
|
84
87
|
var s = scr('detail');
|
|
85
88
|
U.clear(s);
|
|
86
89
|
s.appendChild(U.el('div', 'detail-hero'));
|
|
@@ -114,8 +117,10 @@
|
|
|
114
117
|
function afterMeta() {
|
|
115
118
|
asEpisodeList();
|
|
116
119
|
var files = embeddedFiles(_d.meta);
|
|
117
|
-
|
|
120
|
+
var ep = playBest && target ? (_d.meta.videos || []).filter(function (v) { return v.id === target; })[0] : null;
|
|
121
|
+
if (_d.type === 'movie') { openStreams(_d.id, _d.meta.name || _d.meta.title, false, playBest ? PLAY_KEY : null); }
|
|
118
122
|
else if (files.length === 1) { openEmbedded(files[0]); }
|
|
123
|
+
else if (ep) { _d.season = (ep.season === undefined ? 1 : ep.season); openStreams(ep.id, epName(ep), false, PLAY_KEY); }
|
|
119
124
|
else { drawDetail(); }
|
|
120
125
|
if (resume) { startResume(resume); }
|
|
121
126
|
else if (files.length === 1 && (_d.meta.videos || []).length === 1) { playYouTubeNow(files[0]); }
|
|
@@ -142,7 +147,7 @@
|
|
|
142
147
|
_d.yearSeasons = false;
|
|
143
148
|
return true;
|
|
144
149
|
}
|
|
145
|
-
function openTitle(v) { App.openDetail('movie', v.id, { id: v.id, type: 'movie', name: v.title || v.name || '', poster: v.thumbnail }); }
|
|
150
|
+
function openTitle(v, opts) { App.openDetail('movie', v.id, { id: v.id, type: 'movie', name: v.title || v.name || '', poster: v.thumbnail }, null, opts); }
|
|
146
151
|
|
|
147
152
|
function asEpisodeList() {
|
|
148
153
|
if (asCollection()) { return; }
|
|
@@ -525,6 +530,7 @@
|
|
|
525
530
|
var c = posterCard({ id: 'tmdb:' + item.kind + ':' + item.tmdbId, type: item.type,
|
|
526
531
|
name: item.name + (item.year ? ' (' + item.year + ')' : ''), poster: item.poster, background: item.background }, item.type);
|
|
527
532
|
c.__onselect = function () { openTmdbTitle(item); };
|
|
533
|
+
c.__onplay = function () { openTmdbTitle(item, item.type === 'movie' ? { playBest: true } : null); };
|
|
528
534
|
// hold OK: the menu any poster has (Details, Continue Watching, watched), on the title
|
|
529
535
|
// by its IMDb id (what the addons, Continue Watching and watched marks know it by)
|
|
530
536
|
c.__onlongpress = function () {
|
|
@@ -532,8 +538,8 @@
|
|
|
532
538
|
};
|
|
533
539
|
return c;
|
|
534
540
|
}
|
|
535
|
-
function openTmdbTitle(item) {
|
|
536
|
-
withImdb(item, function (imdb) { App.openDetail(item.type, imdb, { name: item.name, poster: item.poster, type: item.type }); });
|
|
541
|
+
function openTmdbTitle(item, opts) {
|
|
542
|
+
withImdb(item, function (imdb) { App.openDetail(item.type, imdb, { name: item.name, poster: item.poster, type: item.type }, null, opts); });
|
|
537
543
|
}
|
|
538
544
|
function withImdb(item, then) {
|
|
539
545
|
U.spinner(true);
|
|
@@ -848,6 +854,10 @@
|
|
|
848
854
|
if (up.resume && up.resume.url) { startResume(up.resume); }
|
|
849
855
|
else { openStreams(up.v.id, epName(up.v), false, AUTO); }
|
|
850
856
|
};
|
|
857
|
+
btn.__onplay = function () {
|
|
858
|
+
if (up.resume && up.resume.url) { startResume(up.resume); }
|
|
859
|
+
else { openStreams(up.v.id, epName(up.v), false, PLAY_KEY); }
|
|
860
|
+
};
|
|
851
861
|
// hold OK: where you were, or the episode from the start (its saved source; with none
|
|
852
862
|
// saved, its page, where everything then plays from the start)
|
|
853
863
|
if (up.resume && up.resume.position > 0) {
|
|
@@ -1046,6 +1056,7 @@
|
|
|
1046
1056
|
var row = U.el('div', 'btn-row');
|
|
1047
1057
|
var play = U.el('div', 'pill focusable', '▶ Play');
|
|
1048
1058
|
play.__onselect = function () { openStreams(_d.id, _d.meta.name, false, AUTO); };
|
|
1059
|
+
play.__onplay = function () { openStreams(_d.id, _d.meta.name, false, PLAY_KEY); };
|
|
1049
1060
|
row.appendChild(play);
|
|
1050
1061
|
return row;
|
|
1051
1062
|
}
|
|
@@ -1275,6 +1286,10 @@
|
|
|
1275
1286
|
if (_d.collection) { openTitle(v); return; }
|
|
1276
1287
|
openStreams(v.id, epName(v), false, AUTO);
|
|
1277
1288
|
};
|
|
1289
|
+
e.__onplay = function () {
|
|
1290
|
+
if (_d.collection) { openTitle(v, { playBest: true }); return; }
|
|
1291
|
+
openStreams(v.id, epName(v), false, PLAY_KEY);
|
|
1292
|
+
};
|
|
1278
1293
|
e.__onlongpress = function () { if (_d.collection) { collectionMenu(meta, v); } else { episodeMenu(meta, v); } };
|
|
1279
1294
|
if (_d.target && v.id === _d.target) { _d._epFocus = e; }
|
|
1280
1295
|
listScroll.appendChild(e);
|
|
@@ -1645,11 +1660,13 @@
|
|
|
1645
1660
|
|
|
1646
1661
|
// how (optional): { fromStart } — everything played from the page plays from the start;
|
|
1647
1662
|
// { auto } — Skip the source list (Settings › Source ranking): the top source plays once the
|
|
1648
|
-
// addons have answered (with nothing playable, the list shows as usual)
|
|
1649
|
-
|
|
1663
|
+
// addons have answered (with nothing playable, the list shows as usual); { always }: whatever
|
|
1664
|
+
// that setting says (the remote's Play key).
|
|
1665
|
+
var AUTO = { auto: true }, PLAY_KEY = { auto: true, always: true };
|
|
1650
1666
|
function openStreams(videoId, label, force, how) {
|
|
1651
1667
|
if (!force) { _d.fromStart = !!(how && how.fromStart); } // (a re-scan keeps it)
|
|
1652
|
-
var auto = !force && !!(how && how.auto) && Stremio.getPrefs().skipSourceList && !_d.live;
|
|
1668
|
+
var auto = !force && !!(how && how.auto) && (how.always || Stremio.getPrefs().skipSourceList) && !_d.live;
|
|
1669
|
+
_d.autoBest = null;
|
|
1653
1670
|
_d.mode = 'streams';
|
|
1654
1671
|
_d.streamId = videoId;
|
|
1655
1672
|
_d.streamLabel = label;
|
|
@@ -1686,7 +1703,7 @@
|
|
|
1686
1703
|
}, force).then(function (list) {
|
|
1687
1704
|
if (!here() && !Player.isActive()) { U.spinner(false); }
|
|
1688
1705
|
show(list, 0);
|
|
1689
|
-
if (
|
|
1706
|
+
if (here() && (auto || _d.autoBest === videoId) && !Player.isActive()) { // (Skip the source list, the Play key: the top one plays)
|
|
1690
1707
|
var top = (_d.streams && _d.streams.length) ? bestRow(rankRowsFor(_d.streams)) : null;
|
|
1691
1708
|
if (top) { startPlayback(top.st, videoId, label, howHere()); return; }
|
|
1692
1709
|
}
|
|
@@ -1787,6 +1804,15 @@
|
|
|
1787
1804
|
};
|
|
1788
1805
|
return p;
|
|
1789
1806
|
}
|
|
1807
|
+
// The remote's Play key on a title's or channel's sources, wherever focus is on them: ▶ Play best. With
|
|
1808
|
+
// nothing to pick yet, once the addons have answered.
|
|
1809
|
+
function playKey() {
|
|
1810
|
+
if (!_d || _d.mode !== 'streams' || !_d.streamId) { return; }
|
|
1811
|
+
var best = (_d.streams && _d.streams.length) ? bestRow(filterRows(rankRowsFor(_d.streams))) : null;
|
|
1812
|
+
if (best) { startPlayback(best.st, _d.streamId, _d.streamLabel || _d.meta.name, howHere()); }
|
|
1813
|
+
else if (!_d.streams || _d.streamsPending > 0) { _d.autoBest = _d.streamId; }
|
|
1814
|
+
else { U.toast('Nothing here plays on this TV'); }
|
|
1815
|
+
}
|
|
1790
1816
|
function streamActionsBar() {
|
|
1791
1817
|
var row = U.el('div', 'btn-row streams-actions');
|
|
1792
1818
|
var allRows = (_d.streams && _d.streams.length) ? rankRowsFor(_d.streams) : [];
|
|
@@ -2330,6 +2356,7 @@
|
|
|
2330
2356
|
V.episodeWatched = episodeWatched;
|
|
2331
2357
|
V.nextUp = nextUp;
|
|
2332
2358
|
V.renderDetail = renderDetail;
|
|
2359
|
+
V.playKey = playKey;
|
|
2333
2360
|
V.leaveDetail = leaveDetail;
|
|
2334
2361
|
V.renderLive = renderLive;
|
|
2335
2362
|
V.renderPerson = renderPerson;
|
package/js/view-guide.js
CHANGED
|
@@ -169,6 +169,7 @@
|
|
|
169
169
|
wait.__meta = { name: c.name, releaseInfo: 'Reading its TV guide…' };
|
|
170
170
|
hooks(wait, -1);
|
|
171
171
|
wait.__onlongpress = function () { hold(g, r, null); };
|
|
172
|
+
if (!c.guideOnly) { wait.__onplay = function () { playChannel(g, r, true); }; }
|
|
172
173
|
track.appendChild(wait);
|
|
173
174
|
nodes.push(wait);
|
|
174
175
|
if (want && want.id === c.id) { found = wait; }
|
|
@@ -182,6 +183,7 @@
|
|
|
182
183
|
n.__p = p; n.__i = i;
|
|
183
184
|
n.__onselect = function () { pick(g, r, p); };
|
|
184
185
|
n.__onlongpress = function () { hold(g, r, p); };
|
|
186
|
+
if (!c.guideOnly) { n.__onplay = function () { playChannel(g, r, true); }; } // (the remote's Play key: the channel, whichever program)
|
|
185
187
|
hooks(n, i);
|
|
186
188
|
track.appendChild(n);
|
|
187
189
|
nodes.push(n);
|
|
@@ -284,24 +286,24 @@
|
|
|
284
286
|
for (var i = 0; i < nodes.length; i++) { if (nodes[i].__p === p) { return nodes[i]; } }
|
|
285
287
|
return false;
|
|
286
288
|
}
|
|
287
|
-
// OK: what's on now plays the channel; another program says what it is.
|
|
288
289
|
// Played, CH+ / CH− go through the Guide's channels; each one's card (where BACK lands, on
|
|
289
|
-
// the channel you end on) is what's on now on it.
|
|
290
|
+
// the channel you end on) is what's on now on it. best: the remote's Play key.
|
|
291
|
+
function playChannel(g, r, best) {
|
|
292
|
+
var c = g.chans[r], now = Date.now() / 1000, list = [], idx = 0;
|
|
293
|
+
g.chans.forEach(function (ch, i) { // (every channel: a cell only for the rows drawn, where BACK lands)
|
|
294
|
+
if (ch.guideOnly) { return; } // (nothing to play)
|
|
295
|
+
var nodes = g.nodes[i] || [], card = nodes[0] || null;
|
|
296
|
+
for (var j = 0; j < nodes.length; j++) { if (nodes[j].__p.start <= now && now < nodes[j].__p.stop) { card = nodes[j]; break; } }
|
|
297
|
+
if (i === r) { idx = list.length; }
|
|
298
|
+
list.push({ meta: { id: ch.id, type: ch.type, name: ch.name, poster: ch.logo || '', logo: ch.logo || '', posterShape: 'landscape' }, card: card });
|
|
299
|
+
});
|
|
300
|
+
App.openLive(c.type, c.id, list[idx].meta, { list: list, idx: idx }, best ? { playBest: true } : null);
|
|
301
|
+
}
|
|
302
|
+
// OK: what's on now plays the channel; another program says what it is.
|
|
290
303
|
function pick(g, r, p) {
|
|
291
304
|
var c = g.chans[r], now = Date.now() / 1000;
|
|
292
305
|
if (c.guideOnly) { findInAddons(p); return; }
|
|
293
|
-
if (p.start <= now && now < p.stop) {
|
|
294
|
-
var list = [], idx = 0;
|
|
295
|
-
g.chans.forEach(function (ch, i) { // (every channel: a cell only for the rows drawn, where BACK lands)
|
|
296
|
-
if (ch.guideOnly) { return; } // (nothing to play)
|
|
297
|
-
var nodes = g.nodes[i] || [], card = nodes[0] || null;
|
|
298
|
-
for (var j = 0; j < nodes.length; j++) { if (nodes[j].__p.start <= now && now < nodes[j].__p.stop) { card = nodes[j]; break; } }
|
|
299
|
-
if (i === r) { idx = list.length; }
|
|
300
|
-
list.push({ meta: { id: ch.id, type: ch.type, name: ch.name, poster: ch.logo || '', logo: ch.logo || '', posterShape: 'landscape' }, card: card });
|
|
301
|
-
});
|
|
302
|
-
App.openLive(c.type, c.id, list[idx].meta, { list: list, idx: idx });
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
306
|
+
if (p.start <= now && now < p.stop) { playChannel(g, r); return; }
|
|
305
307
|
U.toast(EPG.dayTime(p.start) + '–' + EPG.hhmm(p.stop) + ' ' + c.name + ' · ' + p.title + (p.desc ? ': ' + p.desc : '') +
|
|
306
308
|
(p.stop <= now ? ' (already shown)' : ''), 8000);
|
|
307
309
|
}
|
package/js/view-home.js
CHANGED
|
@@ -644,6 +644,9 @@
|
|
|
644
644
|
c.__onselect = function () {
|
|
645
645
|
App.openDetail(e.type, base, preview, target, e.url ? { resume: e } : null);
|
|
646
646
|
};
|
|
647
|
+
c.__onplay = function () { // (a saved stream resumes, as OK; none: the top source)
|
|
648
|
+
App.openDetail(e.type, base, preview, target, e.url ? { resume: e } : { playBest: true });
|
|
649
|
+
};
|
|
647
650
|
c.__onlongpress = function () { continueActions(e, base, preview, target, c); };
|
|
648
651
|
c.__cwKey = showKey(e);
|
|
649
652
|
c.__meta = { name: e.name, description: e.position
|
|
@@ -784,6 +787,7 @@
|
|
|
784
787
|
c.appendChild(U.el('div', 'card-new card-code', code));
|
|
785
788
|
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) };
|
|
786
789
|
c.__onselect = function () { App.openDetail('series', u.show, { name: u.name, poster: u.poster, type: 'series' }, u.ep.id); };
|
|
790
|
+
c.__onplay = function () { App.openDetail('series', u.show, { name: u.name, poster: u.poster, type: 'series' }, u.ep.id, { playBest: true }); };
|
|
787
791
|
return c;
|
|
788
792
|
})));
|
|
789
793
|
});
|
|
@@ -1519,11 +1523,12 @@
|
|
|
1519
1523
|
// Everything is capped to the cards a Home row shows (Settings › Appearance › Titles in a Home
|
|
1520
1524
|
// row), but for IPTV's ★ Favorites (all: every one you picked, up to the 300 kept).
|
|
1521
1525
|
var ROW_CARDS = 30;
|
|
1522
|
-
function rowCards() {
|
|
1526
|
+
function rowCards() { var n = Stremio.getPrefs().rowCards; return n === 'all' ? Infinity : n || ROW_CARDS; }
|
|
1523
1527
|
// A row's titles, up to n: a catalog that pages (skip) is asked for its next pages (skip =
|
|
1524
1528
|
// titles so far, as Discover does) until there are n, a page brings nothing new or fails (what
|
|
1525
|
-
// came is kept), or HOME_PAGES pages
|
|
1526
|
-
|
|
1529
|
+
// came is kept), or HOME_PAGES pages (Unlimited: HOME_PAGES_ALL, for an addon that never runs
|
|
1530
|
+
// out). IPTV's and YouTube's own: as they come.
|
|
1531
|
+
var HOME_PAGES = 10, HOME_PAGES_ALL = 200;
|
|
1527
1532
|
function catalogPages(cat) {
|
|
1528
1533
|
var def = cat.def || {};
|
|
1529
1534
|
return (def.extra || []).some(function (e) { return e && e.name === 'skip'; }) || (def.extraSupported || []).indexOf('skip') !== -1;
|
|
@@ -1534,7 +1539,7 @@
|
|
|
1534
1539
|
var out = first.slice(), seen = {};
|
|
1535
1540
|
out.forEach(function (m) { seen[m.id] = 1; });
|
|
1536
1541
|
function next(page) {
|
|
1537
|
-
if (out.length >= n || page > HOME_PAGES) { return out; }
|
|
1542
|
+
if (out.length >= n || page > (n === Infinity ? HOME_PAGES_ALL : HOME_PAGES)) { return out; }
|
|
1538
1543
|
return Stremio.getCatalog(cat, { skip: out.length }).then(function (more) {
|
|
1539
1544
|
var added = 0;
|
|
1540
1545
|
more.forEach(function (m) { if (!seen[m.id]) { seen[m.id] = 1; out.push(m); added++; } });
|
|
@@ -1559,7 +1564,7 @@
|
|
|
1559
1564
|
return out;
|
|
1560
1565
|
}
|
|
1561
1566
|
|
|
1562
|
-
// A long row (
|
|
1567
|
+
// A long row (Titles in a Home row, ★ Favorites up to 300) builds ROW_FIRST cards, not all of them
|
|
1563
1568
|
// in one go with the remote waiting, then ROW_MORE at a time when focus is within ROW_NEAR of
|
|
1564
1569
|
// the end (Home's Focus.onFocus). row.__rest(): the titles not built yet (CH+ / CH− go through
|
|
1565
1570
|
// them); row.__cardOf(meta): its card, built if it wasn't.
|
package/js/view-settings.js
CHANGED
|
@@ -142,7 +142,7 @@
|
|
|
142
142
|
function render() { name.textContent = caption + ': ' + labelFor(list, store.get()[key]); }
|
|
143
143
|
render();
|
|
144
144
|
row.appendChild(name);
|
|
145
|
-
row.appendChild(U.el('div', 'a-url', 'Press OK to choose'));
|
|
145
|
+
row.appendChild(U.el('div', 'a-url', 'Press OK to choose' + (store.warning ? '. ' + store.warning : '')));
|
|
146
146
|
row.__onselect = function () {
|
|
147
147
|
pickList(caption, list, store.get()[key], function (v) {
|
|
148
148
|
var cfg = store.get(); cfg[key] = v; store.set(cfg);
|
|
@@ -215,9 +215,10 @@
|
|
|
215
215
|
get: function () { return { zoom: '' + zoomPct() }; },
|
|
216
216
|
set: function (cfg) { Stremio.setPref('zoom', +cfg.zoom); applyAppearance(); }
|
|
217
217
|
}));
|
|
218
|
-
wrap.appendChild(subPickRow('Titles in a Home row', [['30', '30'], ['50', '50'], ['100', '100'], ['200', '200']], 'rowCards', {
|
|
218
|
+
wrap.appendChild(subPickRow('Titles in a Home row', [['30', '30'], ['50', '50'], ['100', '100'], ['200', '200'], ['all', 'Unlimited']], 'rowCards', {
|
|
219
|
+
warning: 'Unlimited: Home can take much longer to load, an addon may refuse so many requests, and very long rows can slow an older TV',
|
|
219
220
|
get: function () { return { rowCards: '' + Stremio.getPrefs().rowCards }; },
|
|
220
|
-
set: function (cfg) { Stremio.setPref('rowCards', +cfg.rowCards); clearCatalogCache(); } // (the rows read again, with more pages or fewer)
|
|
221
|
+
set: function (cfg) { Stremio.setPref('rowCards', cfg.rowCards === 'all' ? 'all' : +cfg.rowCards); clearCatalogCache(); } // (the rows read again, with more pages or fewer)
|
|
221
222
|
}));
|
|
222
223
|
wrap.appendChild(subPickRow('Poster orientation', POSTER_SHAPES, 'posterShape', {
|
|
223
224
|
get: function () { return { posterShape: Stremio.getPrefs().posterShape }; },
|
|
@@ -926,6 +927,8 @@
|
|
|
926
927
|
parts.push(thousands(st.count || 0) + ' channel' + (st.count === 1 ? '' : 's') + (st.groups ? ' in ' + st.groups + ' group' + (st.groups === 1 ? '' : 's') : ''));
|
|
927
928
|
if (st.fetchedAt) { var d = new Date(st.fetchedAt); parts.push('downloaded ' + U.dayLabel(st.fetchedAt) + ' ' + two(d.getHours()) + ':' + two(d.getMinutes())); }
|
|
928
929
|
if (st.dropped) { parts.push(thousands(st.dropped) + ' more left out (a playlist keeps its first 30,000)'); }
|
|
930
|
+
if (p.genres) { parts.push(p.genres.length + ' group' + (p.genres.length === 1 ? '' : 's') + ' chosen'); }
|
|
931
|
+
if (st.cut) { parts.push('stopped short' + (st.cut > 0 ? ' of ' + thousands(st.cut) : '') + ': OK on it, then Channel groups, reads only what you want'); }
|
|
929
932
|
if (st.uncached) { parts.push('too large to save on the TV: downloaded each launch'); }
|
|
930
933
|
var g = guideInfo(p);
|
|
931
934
|
if (g) { parts.push(g); }
|
|
@@ -997,7 +1000,7 @@
|
|
|
997
1000
|
if (r.refused) { U.toast('The portal refused that MAC address' + (r.why ? ' (' + r.why + ')' : '') + ': nothing was saved', 6000); return; }
|
|
998
1001
|
Stremio.iptvAddStalker(portal, mac);
|
|
999
1002
|
refreshAddonRows('local:iptv');
|
|
1000
|
-
U.toast('Stalker portal added: ' + r.count + ' channels', 4000);
|
|
1003
|
+
U.toast('Stalker portal added: ' + r.count + ' channels' + (r.cut ? (r.cut.total ? ' of ' + r.cut.total : ' so far') + ': see Stalker channels' : ''), r.cut ? 6000 : 4000);
|
|
1001
1004
|
renderSettings();
|
|
1002
1005
|
});
|
|
1003
1006
|
}
|
|
@@ -1167,6 +1170,19 @@
|
|
|
1167
1170
|
wrap.appendChild(subPickRow('Auto-refresh', IPTV_EVERY, 'every',
|
|
1168
1171
|
{ get: function () { return { every: String(Stremio.iptvRefreshEvery()) }; }, set: function (c) { Stremio.iptvSetRefreshEvery(+c.every); } }));
|
|
1169
1172
|
}
|
|
1173
|
+
wrap.appendChild(subPickRow('Stalker channels', [['pages', 'First 100 pages (about 1,400 channels)'], ['all', 'Whole portal (up to 30,000 channels)']], 'stalker', {
|
|
1174
|
+
warning: 'Whole portal can take many minutes on every Reload and Auto-refresh, the IPTV rows wait for a first read, and a portal may slow down, cut off or block a MAC address that asks so much',
|
|
1175
|
+
get: function () { return { stalker: IPTV.stalkerAll() ? 'all' : 'pages' }; },
|
|
1176
|
+
set: function (c) {
|
|
1177
|
+
var on = c.stalker === 'all', was = IPTV.stalkerAll();
|
|
1178
|
+
IPTV.setStalkerAll(on);
|
|
1179
|
+
if (!on || was) { return; }
|
|
1180
|
+
var mine = playlists.filter(IPTV.isStalker); // (read again now: leave StremioK open meanwhile)
|
|
1181
|
+
if (!mine.length) { return; }
|
|
1182
|
+
U.toast('Reading the whole portal: this can take many minutes, leave StremioK open', 6000);
|
|
1183
|
+
mine.forEach(function (p) { Stremio.iptvReload(p.id).then(function () { refreshAddonRows('local:iptv'); }); });
|
|
1184
|
+
}
|
|
1185
|
+
}));
|
|
1170
1186
|
|
|
1171
1187
|
wrap.appendChild(U.el('div', 'hint',
|
|
1172
1188
|
'Channels are grouped into IPTV and Radio rows on Home. ▲ / ▼ set the playlists\' order: a channel in two playlists comes from the first.'));
|
|
@@ -2160,7 +2176,7 @@
|
|
|
2160
2176
|
sl.setAttribute('data-fk', 'skiplist'); sl.setAttribute('data-ctl', 'extra');
|
|
2161
2177
|
sl.appendChild(U.el('div', 'a-name', 'Skip the source list: ' + (skipList ? 'On' : 'Off')));
|
|
2162
2178
|
sl.appendChild(U.el('div', 'a-url', (skipList ? '▶ Play, OK on an episode and ▶ Play SxEx play the top source at once (hold OK on an episode › Details for the list)'
|
|
2163
|
-
: '▶ Play and OK on an episode show the sources to pick from') + ' · OK to turn ' + (skipList ? 'off' : 'on')));
|
|
2179
|
+
: '▶ Play and OK on an episode show the sources to pick from (the remote’s Play key plays the top one)') + ' · OK to turn ' + (skipList ? 'off' : 'on')));
|
|
2164
2180
|
sl.__onselect = function () { Stremio.setPref('skipSourceList', !skipList); refeed('ranking', 'skiplist', 'extra'); };
|
|
2165
2181
|
return sl;
|
|
2166
2182
|
}
|
package/js/views.js
CHANGED
|
@@ -14,7 +14,7 @@ var Views = (function (V) {
|
|
|
14
14
|
renderLive: V.renderLive,
|
|
15
15
|
renderSearch: V.renderSearch, searchFor: function (q) { V.searchFor(q); }, renderDiscover: V.renderDiscover, renderEntry: V.renderEntry, backInDetail: V.backInDetail,
|
|
16
16
|
homeDirty: V.homeDirty, refreshHomeIfStale: V.refreshHomeIfStale, alertNewEpisodes: V.alertNewEpisodes, previewTiles: V.previewTiles, withShowInfo: V.withShowInfo,
|
|
17
|
-
isModalOpen: V.isModalOpen, closeModal: V.closeModal, confirm: V.confirm, moveKey: V.moveKey, availableTabs: V.availableTabs,
|
|
17
|
+
isModalOpen: V.isModalOpen, closeModal: V.closeModal, confirm: V.confirm, moveKey: V.moveKey, playKey: V.playKey, availableTabs: V.availableTabs,
|
|
18
18
|
menuItems: V.menuItems, menuOrder: V.menuOrder, moveMenuItem: V.moveMenuItem
|
|
19
19
|
};
|
|
20
20
|
})(ViewParts);
|
package/js/ytplay.js
CHANGED
|
@@ -106,7 +106,11 @@ var YTPlay = (function () {
|
|
|
106
106
|
return U.getJSON(PROXY + path + '?portal=' + encodeURIComponent(portal) + '&mac=' + encodeURIComponent(mac) + more + a.q, ms, max, cancel || null, a.h);
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
|
-
function stalkerList(portal, mac) {
|
|
109
|
+
function stalkerList(portal, mac, whole, genres) { // (whole: the whole portal, see IPTV.stalkerAll; genres: only those, see IPTV.setStalkerGroups)
|
|
110
|
+
var some = genres && genres.length;
|
|
111
|
+
return stalkerAsk('/stalker/list', portal, mac, (whole || some ? '&all=1' : '') + (some ? '&genres=' + encodeURIComponent(genres.join(',')) : ''), whole || some ? 20 * 60000 : 90000, 48 * 1048576);
|
|
112
|
+
}
|
|
113
|
+
function stalkerGenres(portal, mac) { return stalkerAsk('/stalker/genres', portal, mac, '', 40000, 1048576); }
|
|
110
114
|
function stalkerLink(portal, mac, u, cancel) { return stalkerAsk('/stalker/link', portal, mac, '&u=' + encodeURIComponent(u), 25000, 65536, cancel); }
|
|
111
115
|
// An Xtream account's films or series, kept by the service (see service/index.js, xtvControl;
|
|
112
116
|
// user= and pass=: names Diagnostics masks):
|
|
@@ -253,6 +257,6 @@ var YTPlay = (function () {
|
|
|
253
257
|
return MODE === 'tizenbrew' ? 'TizenBrew module' : MODE === 'wgt' ? 'Sideloaded app (.wgt)' : 'Browser (development)';
|
|
254
258
|
}
|
|
255
259
|
|
|
256
|
-
return { ensureService: ensureService, resolverUrl: resolverUrl, infoUrl: infoUrl, canPlay: canPlay, liveOpen: liveOpen, hlsMaster: hlsMaster, aiomAddons: aiomAddons, stalkerList: stalkerList, stalkerLink: stalkerLink, xtvodAsk: xtvodAsk, epgLoad: epgLoad, epgGet: epgGet, epgFiles: epgFiles, epgClear: epgClear, entryOpen: entryOpen, entryPoll: entryPoll, entryClose: entryClose, subsUrl: subsUrl, audioLang: audioLang, setAudioLang: setAudioLang, installMode: function () { return MODE; },
|
|
260
|
+
return { ensureService: ensureService, resolverUrl: resolverUrl, infoUrl: infoUrl, canPlay: canPlay, liveOpen: liveOpen, hlsMaster: hlsMaster, aiomAddons: aiomAddons, stalkerList: stalkerList, stalkerGenres: stalkerGenres, stalkerLink: stalkerLink, xtvodAsk: xtvodAsk, epgLoad: epgLoad, epgGet: epgGet, epgFiles: epgFiles, epgClear: epgClear, entryOpen: entryOpen, entryPoll: entryPoll, entryClose: entryClose, subsUrl: subsUrl, audioLang: audioLang, setAudioLang: setAudioLang, installMode: function () { return MODE; },
|
|
257
261
|
installLabel: installLabel, unavailableMessage: unavailableMessage, isRunning: isRunning, port: PORT };
|
|
258
262
|
})();
|
package/package.json
CHANGED
package/service/index.js
CHANGED
|
@@ -1819,7 +1819,7 @@ function handle(req, res) {
|
|
|
1819
1819
|
if (/^\/epg\//.test(path)) { epgControl(req, res, path, parts[1]); return; } // (a playlist's TV guide: see epgControl)
|
|
1820
1820
|
if (path === '/aiom/addons') { aiomControl(req, res, parts[1], leaving); return; }
|
|
1821
1821
|
if (path === '/xtvod/list' || path === '/xtvod/find') { xtvControl(req, res, path, parts[1]); return; } // (an Xtream account's films and series: see xtvControl)
|
|
1822
|
-
if (path === '/stalker/list' || path === '/stalker/link') { stalkerControl(req, res, path, parts[1], leaving); return; } // (a Stalker portal: see stalkerControl) // (AIOManager's addons: see aiomControl) // (a live channel's sound repacked: see liveControl) // (the phone's one-time page: see below)
|
|
1822
|
+
if (path === '/stalker/list' || path === '/stalker/link' || path === '/stalker/genres') { stalkerControl(req, res, path, parts[1], leaving); return; } // (a Stalker portal: see stalkerControl) // (AIOManager's addons: see aiomControl) // (a live channel's sound repacked: see liveControl) // (the phone's one-time page: see below)
|
|
1823
1823
|
if (path === '/fsfile') { // a USB file over HTTP, with Range: the player reads a big one from here (see fsfile in the header)
|
|
1824
1824
|
var whyF = fsAllowed(req, parts[1]);
|
|
1825
1825
|
if (whyF) { send(res, 403, 'text/plain', 'not allowed (' + whyF + ')'); return; }
|
|
@@ -2975,13 +2975,17 @@ function xtvControl(req, res, path, query) {
|
|
|
2975
2975
|
// A Stalker (Ministra) portal, asked as a MAG box asks: its MAC address in a cookie, a MAG
|
|
2976
2976
|
// User-Agent, a session token from a handshake (none of which a web page can send). Its API at
|
|
2977
2977
|
// <address>/portal.php, else /server/load.php (the address's /c/ left out). list: its genres and
|
|
2978
|
-
// channels (get_all_channels, else get_ordered_list a page at a time, STALKER_PAGES at most
|
|
2978
|
+
// channels (get_all_channels, else get_ordered_list a page at a time, STALKER_PAGES at most; all=1:
|
|
2979
|
+
// the whole portal, up to STALKER_CHANNELS within STALKER_WHOLE_MS, a failed page tried again after
|
|
2980
|
+
// each of STALKER_WAITS, the rest then read STALKER_PACE_MS apart; genres=: only those genres, read
|
|
2981
|
+
// the same way; cut: it stopped short) as an
|
|
2979
2982
|
// M3U playlist, genres as groups, xmltv_id as tvg-id, each channel's link the one in its cmd (often
|
|
2980
2983
|
// a stand-in, http://localhost/ch/123_), kept STALKER_LIST_MS (adding a portal just checked reads it
|
|
2981
2984
|
// once). link: the link to play now (create_link, with the channel's own cmd). A session whose
|
|
2982
2985
|
// token the portal no longer takes is opened again, once. Redirects only on the same server.
|
|
2983
2986
|
var STALKER_UA = 'Mozilla/5.0 (QtEmbedded; U; Linux; C) AppleWebKit/533.3 (KHTML, like Gecko) MAG200 stbapp ver: 2 rev: 250 Safari/533.3';
|
|
2984
2987
|
var STALKER_MS = 20000, STALKER_MAX = 16 * 1048576, STALKER_PAGES = 100, STALKER_CHANNELS = 30000, STALKER_LIST_MS = 2 * 60000, STALKER_KEEP = 4;
|
|
2988
|
+
var STALKER_GENRES = 1000, STALKER_WAITS = [3000, 10000, 30000, 60000, 120000], STALKER_PACE_MS = 1000, STALKER_WHOLE_MS = 17 * 60000; // (the app waits 20 minutes: what was read gets there)
|
|
2985
2989
|
var _stalker = Object.create(null); // portal|mac -> { api, base, mac, token, cmds: { link: cmd }, list: { at, m3u, count }, used }
|
|
2986
2990
|
function stalkerKeep(key) {
|
|
2987
2991
|
var s = _stalker[key];
|
|
@@ -3097,7 +3101,12 @@ function stalkerWith(s, portal, mac, ctl, job, cb) {
|
|
|
3097
3101
|
function open(again) { stalkerOpen(s, portal, mac, ctl, function (err) { if (err) { cb(err); return; } run(again); }); }
|
|
3098
3102
|
if (s.token && s.api) { run(false); } else { open(false); }
|
|
3099
3103
|
}
|
|
3100
|
-
function
|
|
3104
|
+
function stalkerSlim(c) { // (a page's channel: what the playlist takes; thousands of them are held meanwhile)
|
|
3105
|
+
if (!c || typeof c !== 'object') { return null; }
|
|
3106
|
+
return { name: c.name, cmd: c.cmd, cmds: Array.isArray(c.cmds) ? c.cmds.slice(0, 1) : null, logo: c.logo, xmltv_id: c.xmltv_id, number: c.number, tv_genre_id: c.tv_genre_id };
|
|
3107
|
+
}
|
|
3108
|
+
// picks: the genres to read (their ids), or none: all of them.
|
|
3109
|
+
function stalkerChannels(s, ctl, whole, picks, cb) {
|
|
3101
3110
|
stalkerAsk(s, 'type=itv&action=get_genres', ctl, function (e0, genres) {
|
|
3102
3111
|
if (e0 && e0.auth) { cb(e0); return; }
|
|
3103
3112
|
var g = {};
|
|
@@ -3105,16 +3114,27 @@ function stalkerChannels(s, ctl, cb) {
|
|
|
3105
3114
|
stalkerAsk(s, 'type=itv&action=get_all_channels', ctl, function (e1, js) {
|
|
3106
3115
|
if (e1 && e1.auth) { cb(e1); return; }
|
|
3107
3116
|
var all = js && Array.isArray(js.data) ? js.data : Array.isArray(js) ? js : [];
|
|
3108
|
-
if (all.length) { cb(null, all.slice(0, STALKER_CHANNELS), g); return; }
|
|
3109
|
-
|
|
3117
|
+
if (all.length && picks.length) { all = all.filter(function (c) { return c && picks.indexOf(String(c.tv_genre_id)) !== -1; }); cb(null, all.slice(0, STALKER_CHANNELS), g, all.length > STALKER_CHANNELS ? { total: all.length } : null); return; }
|
|
3118
|
+
if (all.length) { cb(null, all.slice(0, STALKER_CHANNELS), g, all.length > STALKER_CHANNELS ? { total: all.length } : null); return; }
|
|
3119
|
+
var todo = picks.length ? picks : ['*'], at = 0, page = 1, tries = 0, pace = 0, from = 0, known = 0, began = Date.now();
|
|
3110
3120
|
(function more() {
|
|
3111
|
-
stalkerAsk(s, 'type=itv&action=get_ordered_list&genre
|
|
3112
|
-
if (e2 && !all.length) { cb(e2); return; }
|
|
3113
|
-
var
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3121
|
+
stalkerAsk(s, 'type=itv&action=get_ordered_list&genre=' + encodeURIComponent(todo[at]) + '&fav=0&sortby=number&hd=0&p=' + page, ctl, function (e2, o) {
|
|
3122
|
+
if (e2 && (!all.length || (whole && e2.auth))) { cb(e2); return; } // (whole: a session gone midway read again, once: stalkerWith)
|
|
3123
|
+
var late = whole && Date.now() - began > STALKER_WHOLE_MS;
|
|
3124
|
+
if (e2 && whole && !ctl.gone && !late && tries < STALKER_WAITS.length) { pace = STALKER_PACE_MS; setTimeout(more, STALKER_WAITS[tries++]); return; }
|
|
3125
|
+
tries = 0;
|
|
3126
|
+
var d = !e2 && o && Array.isArray(o.data) ? o.data : [], total = +(o && o.total_items) || 0, room = STALKER_CHANNELS - all.length;
|
|
3127
|
+
d.slice(0, room).forEach(function (c) { var x = stalkerSlim(c); if (x) { if (picks.length) { x.tv_genre_id = todo[at]; } all.push(x); } });
|
|
3128
|
+
if (total) { known = total; }
|
|
3129
|
+
var ended = !d.length || (total && all.length - from >= total), lastOne = at + 1 >= todo.length; // (this genre's all read; no other to read)
|
|
3130
|
+
var full = all.length >= STALKER_CHANNELS, last = !whole && page >= STALKER_PAGES;
|
|
3131
|
+
if (e2 || full || last || late || (ended && lastOne)) {
|
|
3132
|
+
var cut = e2 || ((!ended || !lastOne) && (full || last || late)) ? { total: picks.length ? 0 : known, why: e2 ? (e2.message || 'failed') : late ? 'it took too long' : '' } : null;
|
|
3133
|
+
cb(null, all, g, cut);
|
|
3134
|
+
return;
|
|
3135
|
+
}
|
|
3136
|
+
if (ended) { at++; page = 1; from = all.length; } else { page++; }
|
|
3137
|
+
if (pace) { setTimeout(more, pace); } else { more(); }
|
|
3118
3138
|
});
|
|
3119
3139
|
})();
|
|
3120
3140
|
});
|
|
@@ -3161,18 +3181,36 @@ function stalkerControl(req, res, path, query, leaving) {
|
|
|
3161
3181
|
}, function (err, link) { json(err ? { why: err.message || 'failed' } : { url: link }); });
|
|
3162
3182
|
return;
|
|
3163
3183
|
}
|
|
3164
|
-
if (
|
|
3184
|
+
if (path === '/stalker/genres') {
|
|
3185
|
+
stalkerWith(s, portal, mac, ctl, function (ss, done) { stalkerAsk(ss, 'type=itv&action=get_genres', ctl, done); }, function (err, js) {
|
|
3186
|
+
if (err) { json({ why: err.message || 'failed' }); return; }
|
|
3187
|
+
json({ genres: (Array.isArray(js) ? js : []).filter(function (x) { return x && x.id != null && x.id !== '*' && x.title; }).slice(0, STALKER_GENRES).map(function (x) { return { id: String(x.id).slice(0, 40), title: String(x.title).slice(0, 100) }; }) });
|
|
3188
|
+
});
|
|
3189
|
+
return;
|
|
3190
|
+
}
|
|
3191
|
+
var picks = String(q.genres || '').split(',').filter(function (x) { return /^[\w.-]{1,40}$/.test(x); }).slice(0, STALKER_GENRES), wanted = picks.join(',');
|
|
3192
|
+
var whole = q.all === '1', sock = req.socket;
|
|
3193
|
+
if (whole && sock && sock.setTimeout) { // (a read of many minutes: Node's two idle minutes would end it)
|
|
3194
|
+
sock.setTimeout(0);
|
|
3195
|
+
if (res.on) { res.on('finish', function () { sock.setTimeout(120000); }); }
|
|
3196
|
+
}
|
|
3197
|
+
function listed(l) { var o = { m3u: l.m3u, count: l.count }; if (l.cut) { o.cut = l.cut; } return o; }
|
|
3198
|
+
if (s.list && Date.now() - s.list.at < STALKER_LIST_MS && s.list.genres === wanted && (s.list.whole || !whole)) { json(listed(s.list)); return; }
|
|
3165
3199
|
stalkerWith(s, portal, mac, ctl, function (ss, done) {
|
|
3166
|
-
stalkerChannels(ss, ctl,
|
|
3200
|
+
stalkerChannels(ss, ctl, whole, picks, function (err, list, genres, cut) {
|
|
3201
|
+
var m = err ? null : stalkerM3u(ss, list, genres);
|
|
3202
|
+
if (m && cut) { m.cut = cut; }
|
|
3203
|
+
done(err, m);
|
|
3204
|
+
});
|
|
3167
3205
|
}, function (err, r) {
|
|
3168
3206
|
if (err) {
|
|
3169
3207
|
var refused = err.auth || err.status === 401 || /^not a Stalker answer/.test(err.message || '') && !!s.token;
|
|
3170
3208
|
json(refused ? { refused: true, why: s.block || 'the portal refused that MAC address' } : { unreachable: true, why: err.message || 'failed' });
|
|
3171
3209
|
return;
|
|
3172
3210
|
}
|
|
3173
|
-
if (!r.count) { json({ refused: true, why: s.block || 'the portal listed no channels for that MAC address' }); return; }
|
|
3174
|
-
s.list = { at: Date.now(), m3u: r.m3u, count: r.count };
|
|
3175
|
-
json(
|
|
3211
|
+
if (!r.count) { json({ refused: true, why: s.block || (picks.length ? 'the portal listed no channels in the groups you chose' : 'the portal listed no channels for that MAC address') }); return; }
|
|
3212
|
+
s.list = { at: Date.now(), m3u: r.m3u, count: r.count, cut: r.cut || null, whole: whole, genres: wanted };
|
|
3213
|
+
json(listed(s.list));
|
|
3176
3214
|
});
|
|
3177
3215
|
}
|
|
3178
3216
|
|