stremiok 2.2.3 → 2.2.4

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 CHANGED
@@ -3,6 +3,15 @@
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.4 — 2026-10-31
7
+ - **The remote's ▶ Play key:** on a movie, an episode or a channel (its card, its row, its sources,
8
+ its row in the Guide), plays the top source at once, whatever *Skip the source list* says.
9
+ - **Titles in a Home row** has *Unlimited*, for catalogs and IPTV groups.
10
+ - **Stalker channels** (Settings › Content › IPTV): *Whole portal* reads past the first 100 pages
11
+ (about 1,400 channels), with a warning; a portal read that stopped short says so.
12
+ - **TV guide:** a guide read again (*Reload*, *Auto-refresh*) reaches the Guide tab at once; its grid
13
+ could keep the old titles for up to 2 hours.
14
+
6
15
  ## 2.2.3 — 2026-10-30
7
16
  - **Xtream films and series:** an account's films and series in the Movies and Series tabs (a show
8
17
  is one tile, its episodes on its page), Discover by its categories, and Search. The IPTV tab
package/README.md CHANGED
@@ -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; hold OK where an item has more to
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 up to 200 titles of a catalog (30 unless you change it; ★ Favorites shows all
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" viewmodes="maximized">
3
+ id="http://stremiok.tizen/StremioKTizen" version="2.2.4" 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.3">
7
+ <link rel="stylesheet" href="css/style.css?v=2.2.4">
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.3"></script>
57
- <script src="js/util.js?v=2.2.3"></script>
58
- <script src="js/iptv.js?v=2.2.3"></script>
59
- <script src="js/xtvod.js?v=2.2.3"></script>
60
- <script src="js/epg.js?v=2.2.3"></script>
61
- <script src="js/youtube.js?v=2.2.3"></script>
62
- <script src="js/stremio.js?v=2.2.3"></script>
63
- <script src="js/trakt.js?v=2.2.3"></script>
64
- <script src="js/keys.js?v=2.2.3"></script>
65
- <script src="js/focus.js?v=2.2.3"></script>
66
- <script src="js/tvapps.js?v=2.2.3"></script>
67
- <script src="js/player-core.js?v=2.2.3"></script>
68
- <script src="js/player-store.js?v=2.2.3"></script>
69
- <script src="js/player-lang.js?v=2.2.3"></script>
70
- <script src="js/player-quality.js?v=2.2.3"></script>
71
- <script src="js/player-subs.js?v=2.2.3"></script>
72
- <script src="js/player-audio.js?v=2.2.3"></script>
73
- <script src="js/player-controls.js?v=2.2.3"></script>
74
- <script src="js/player.js?v=2.2.3"></script>
75
- <script src="js/ytplay.js?v=2.2.3"></script>
76
- <script src="js/local.js?v=2.2.3"></script>
77
- <script src="js/downloads.js?v=2.2.3"></script>
78
- <script src="js/stremio-account.js?v=2.2.3"></script>
79
- <script src="js/view-core.js?v=2.2.3"></script>
80
- <script src="js/view-home.js?v=2.2.3"></script>
81
- <script src="js/view-guide.js?v=2.2.3"></script>
82
- <script src="js/view-detail.js?v=2.2.3"></script>
83
- <script src="js/view-search.js?v=2.2.3"></script>
84
- <script src="js/view-settings.js?v=2.2.3"></script>
85
- <script src="js/view-discover.js?v=2.2.3"></script>
86
- <script src="js/views.js?v=2.2.3"></script>
87
- <script src="js/app.js?v=2.2.3"></script>
88
- <script src="js/hubpreview.js?v=2.2.3"></script>
56
+ <script src="js/polyfills.js?v=2.2.4"></script>
57
+ <script src="js/util.js?v=2.2.4"></script>
58
+ <script src="js/iptv.js?v=2.2.4"></script>
59
+ <script src="js/xtvod.js?v=2.2.4"></script>
60
+ <script src="js/epg.js?v=2.2.4"></script>
61
+ <script src="js/youtube.js?v=2.2.4"></script>
62
+ <script src="js/stremio.js?v=2.2.4"></script>
63
+ <script src="js/trakt.js?v=2.2.4"></script>
64
+ <script src="js/keys.js?v=2.2.4"></script>
65
+ <script src="js/focus.js?v=2.2.4"></script>
66
+ <script src="js/tvapps.js?v=2.2.4"></script>
67
+ <script src="js/player-core.js?v=2.2.4"></script>
68
+ <script src="js/player-store.js?v=2.2.4"></script>
69
+ <script src="js/player-lang.js?v=2.2.4"></script>
70
+ <script src="js/player-quality.js?v=2.2.4"></script>
71
+ <script src="js/player-subs.js?v=2.2.4"></script>
72
+ <script src="js/player-audio.js?v=2.2.4"></script>
73
+ <script src="js/player-controls.js?v=2.2.4"></script>
74
+ <script src="js/player.js?v=2.2.4"></script>
75
+ <script src="js/ytplay.js?v=2.2.4"></script>
76
+ <script src="js/local.js?v=2.2.4"></script>
77
+ <script src="js/downloads.js?v=2.2.4"></script>
78
+ <script src="js/stremio-account.js?v=2.2.4"></script>
79
+ <script src="js/view-core.js?v=2.2.4"></script>
80
+ <script src="js/view-home.js?v=2.2.4"></script>
81
+ <script src="js/view-guide.js?v=2.2.4"></script>
82
+ <script src="js/view-detail.js?v=2.2.4"></script>
83
+ <script src="js/view-search.js?v=2.2.4"></script>
84
+ <script src="js/view-settings.js?v=2.2.4"></script>
85
+ <script src="js/view-discover.js?v=2.2.4"></script>
86
+ <script src="js/views.js?v=2.2.4"></script>
87
+ <script src="js/app.js?v=2.2.4"></script>
88
+ <script src="js/hubpreview.js?v=2.2.4"></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
@@ -203,12 +203,17 @@ var IPTV = (function () {
203
203
  return checkedUrl(s);
204
204
  }
205
205
  function isStalker(p) { return !!(p && p.mac); }
206
+ // Settings › Content › IPTV › Stalker channels: a portal read past its first 100 pages, up to
207
+ // 30,000 channels (adding one is still checked by those pages: stalkerCheck).
208
+ var STALKER_ALL_KEY = 'stremiok.iptv.stalkerall';
209
+ function stalkerAll() { return U.store.get(STALKER_ALL_KEY, false) === true; }
210
+ function setStalkerAll(on) { U.store.set(STALKER_ALL_KEY, !!on); }
206
211
  // Checked through the service (its channels read): { ok, count }, { refused, why },
207
212
  // { unreachable, why } or { noService } (a desktop browser).
208
213
  function stalkerCheck(portal, mac) {
209
214
  if (typeof YTPlay === 'undefined' || !YTPlay.stalkerList) { return Promise.resolve({ noService: true }); }
210
215
  return YTPlay.stalkerList(portal, mac).then(function (r) {
211
- if (r && typeof r.m3u === 'string') { return { ok: true, count: r.count || 0 }; }
216
+ if (r && typeof r.m3u === 'string') { return { ok: true, count: r.count || 0, cut: r.cut || null }; }
212
217
  return r && r.refused ? { refused: true, why: '' + (r.why || '') } : { unreachable: true, why: '' + ((r && r.why) || '') };
213
218
  }, function (e) { return /no service/.test((e && e.message) || '') ? { noService: true } : { unreachable: true, why: U.problem(e) }; });
214
219
  }
@@ -511,8 +516,14 @@ var IPTV = (function () {
511
516
  // A Stalker portal's channels, from the service (see stalkerCheck): its M3U text.
512
517
  function stalkerText() {
513
518
  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') { return r.m3u; }
519
+ return YTPlay.stalkerList(playlist.url, playlist.mac, stalkerAll()).then(function (r) {
520
+ if (r && typeof r.m3u === 'string') {
521
+ if (r.cut) { // (stopped short: said, with what's there)
522
+ st.cut = r.cut.total || true;
523
+ 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 + ')' : ''));
524
+ }
525
+ return r.m3u;
526
+ }
516
527
  throw new Error((r && r.refused ? 'The portal refused it: ' : 'Couldn’t read the portal: ') + ((r && r.why) || 'no answer'));
517
528
  }, function (e) {
518
529
  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 +756,7 @@ var IPTV = (function () {
745
756
  getPlaylists: getPlaylists, addPlaylist: addPlaylist, updatePlaylist: updatePlaylist,
746
757
  removePlaylist: removePlaylist, renamePlaylist: renamePlaylist, setPlaylistOff: setPlaylistOff,
747
758
  movePlaylist: movePlaylist, setPlaylistGuide: setPlaylistGuide, label: labelOf,
748
- macOf: macOf, stalkerPortal: stalkerPortal, stalkerCheck: stalkerCheck, addStalker: addStalker, isStalker: isStalker,
759
+ macOf: macOf, stalkerPortal: stalkerPortal, stalkerCheck: stalkerCheck, addStalker: addStalker, isStalker: isStalker, stalkerAll: stalkerAll, setStalkerAll: setStalkerAll,
749
760
  xtreamParts: xtreamParts, xtreamUrl: xtreamUrl, xtreamCheck: xtreamCheck, addXtream: addXtream, xtreamFormat: xtreamFormat, setXtreamFormat: setXtreamFormat,
750
761
  isFavorite: isFavorite, setFavorite: setFavorite, refreshEvery: refreshEvery, setRefreshEvery: setRefreshEvery, readAt: readAt,
751
762
  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
@@ -587,6 +587,11 @@ var ViewParts = {};
587
587
  guideOnCard(c, meta.id);
588
588
  c.__onlongpress = function () { liveSchedule(meta, c); };
589
589
  }
590
+ function isLive() {
591
+ var t = titleType(meta.type || fallbackType);
592
+ var isTitle = t === 'movie' || t === 'series' || TITLE_ID.test(meta.id || '');
593
+ return !!fallbackType && fallbackType !== 'movie' && fallbackType !== 'series' && !isTitle && !/^(youtube|channel)$/i.test(fallbackType) && !/^(ytk|yt_id):/.test(meta.id || '');
594
+ }
590
595
  c.__onselect = function () {
591
596
  var t = titleType(meta.type || fallbackType);
592
597
  // Live TV catalogs (anything that isn't movies/series) skip the info page and
@@ -595,13 +600,16 @@ var ViewParts = {};
595
600
  // (a video plays from it at once, a channel lists its videos). So is anything that
596
601
  // is a movie or series itself, or has a title's id, whatever its catalog's type
597
602
  // (AIOMetadata's "anime" catalogs list movies and series: "mal:28851", a movie).
598
- var isTitle = t === 'movie' || t === 'series' || TITLE_ID.test(meta.id || '');
599
- if (fallbackType && fallbackType !== 'movie' && fallbackType !== 'series' && !isTitle && !/^(youtube|channel)$/i.test(fallbackType) && !/^(ytk|yt_id):/.test(meta.id || '')) {
603
+ if (isLive()) {
600
604
  App.openLive(t, meta.id, meta, rowChannels(c));
601
605
  } else {
602
606
  App.openDetail(t, meta.id, meta);
603
607
  }
604
608
  };
609
+ // the remote's Play key: a movie's or channel's top source; a series has no one episode, so its page
610
+ if (titleType(kind) === 'movie') { c.__onplay = function () { App.openDetail('movie', meta.id, meta, null, { playBest: true }); }; }
611
+ else if (titleType(kind) === 'series') { c.__onplay = function () { c.__onselect(); }; }
612
+ else if (fallbackType !== 'local' && isLive()) { c.__onplay = function () { App.openLive(titleType(kind), meta.id, meta, rowChannels(c), { playBest: true }); }; } // (a channel)
605
613
  return c;
606
614
  }
607
615
 
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
- if (_d.type === 'movie') { openStreams(_d.id, _d.meta.name || _d.meta.title); }
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
- var AUTO = { auto: true };
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 (auto && here() && !Player.isActive()) { // (Skip the source list: the top one plays)
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() { return Stremio.getPrefs().rowCards || ROW_CARDS; }
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. IPTV's and YouTube's own: as they come.
1526
- var HOME_PAGES = 10;
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 (up to 200 titles, ★ Favorites up to 300) builds ROW_FIRST cards, not all of them
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.
@@ -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,7 @@
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 (st.cut) { parts.push('stopped short' + (st.cut > 0 ? ' of ' + thousands(st.cut) : '') + ': see Stalker channels'); }
929
931
  if (st.uncached) { parts.push('too large to save on the TV: downloaded each launch'); }
930
932
  var g = guideInfo(p);
931
933
  if (g) { parts.push(g); }
@@ -997,7 +999,7 @@
997
999
  if (r.refused) { U.toast('The portal refused that MAC address' + (r.why ? ' (' + r.why + ')' : '') + ': nothing was saved', 6000); return; }
998
1000
  Stremio.iptvAddStalker(portal, mac);
999
1001
  refreshAddonRows('local:iptv');
1000
- U.toast('Stalker portal added: ' + r.count + ' channels', 4000);
1002
+ 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
1003
  renderSettings();
1002
1004
  });
1003
1005
  }
@@ -1167,6 +1169,19 @@
1167
1169
  wrap.appendChild(subPickRow('Auto-refresh', IPTV_EVERY, 'every',
1168
1170
  { get: function () { return { every: String(Stremio.iptvRefreshEvery()) }; }, set: function (c) { Stremio.iptvSetRefreshEvery(+c.every); } }));
1169
1171
  }
1172
+ wrap.appendChild(subPickRow('Stalker channels', [['pages', 'First 100 pages (about 1,400 channels)'], ['all', 'Whole portal (up to 30,000 channels)']], 'stalker', {
1173
+ 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',
1174
+ get: function () { return { stalker: IPTV.stalkerAll() ? 'all' : 'pages' }; },
1175
+ set: function (c) {
1176
+ var on = c.stalker === 'all', was = IPTV.stalkerAll();
1177
+ IPTV.setStalkerAll(on);
1178
+ if (!on || was) { return; }
1179
+ var mine = playlists.filter(IPTV.isStalker); // (read again now: leave StremioK open meanwhile)
1180
+ if (!mine.length) { return; }
1181
+ U.toast('Reading the whole portal: this can take many minutes, leave StremioK open', 6000);
1182
+ mine.forEach(function (p) { Stremio.iptvReload(p.id).then(function () { refreshAddonRows('local:iptv'); }); });
1183
+ }
1184
+ }));
1170
1185
 
1171
1186
  wrap.appendChild(U.el('div', 'hint',
1172
1187
  '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 +2175,7 @@
2160
2175
  sl.setAttribute('data-fk', 'skiplist'); sl.setAttribute('data-ctl', 'extra');
2161
2176
  sl.appendChild(U.el('div', 'a-name', 'Skip the source list: ' + (skipList ? 'On' : 'Off')));
2162
2177
  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')));
2178
+ : '▶ 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
2179
  sl.__onselect = function () { Stremio.setPref('skipSourceList', !skipList); refeed('ranking', 'skiplist', 'extra'); };
2165
2180
  return sl;
2166
2181
  }
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,7 @@ 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) { return stalkerAsk('/stalker/list', portal, mac, '', 90000, 48 * 1048576); }
109
+ function stalkerList(portal, mac, whole) { return stalkerAsk('/stalker/list', portal, mac, whole ? '&all=1' : '', whole ? 20 * 60000 : 90000, 48 * 1048576); } // (whole: the whole portal, see IPTV.stalkerAll)
110
110
  function stalkerLink(portal, mac, u, cancel) { return stalkerAsk('/stalker/link', portal, mac, '&u=' + encodeURIComponent(u), 25000, 65536, cancel); }
111
111
  // An Xtream account's films or series, kept by the service (see service/index.js, xtvControl;
112
112
  // user= and pass=: names Diagnostics masks):
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stremiok",
3
- "version": "2.2.3",
3
+ "version": "2.2.4",
4
4
  "description": "StremioK streaming client for Tizen 3.0+ Samsung TVs (TizenBrew app module).",
5
5
  "packageType": "app",
6
6
  "appName": "StremioK",
package/service/index.js CHANGED
@@ -2975,13 +2975,14 @@ 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) as an
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, a failed page tried again; cut: it stopped short) as an
2979
2980
  // M3U playlist, genres as groups, xmltv_id as tvg-id, each channel's link the one in its cmd (often
2980
2981
  // a stand-in, http://localhost/ch/123_), kept STALKER_LIST_MS (adding a portal just checked reads it
2981
2982
  // once). link: the link to play now (create_link, with the channel's own cmd). A session whose
2982
2983
  // token the portal no longer takes is opened again, once. Redirects only on the same server.
2983
2984
  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
- var STALKER_MS = 20000, STALKER_MAX = 16 * 1048576, STALKER_PAGES = 100, STALKER_CHANNELS = 30000, STALKER_LIST_MS = 2 * 60000, STALKER_KEEP = 4;
2985
+ var STALKER_MS = 20000, STALKER_MAX = 16 * 1048576, STALKER_PAGES = 100, STALKER_CHANNELS = 30000, STALKER_LIST_MS = 2 * 60000, STALKER_KEEP = 4, STALKER_RETRIES = 2, STALKER_RETRY_MS = 3000;
2985
2986
  var _stalker = Object.create(null); // portal|mac -> { api, base, mac, token, cmds: { link: cmd }, list: { at, m3u, count }, used }
2986
2987
  function stalkerKeep(key) {
2987
2988
  var s = _stalker[key];
@@ -3097,7 +3098,11 @@ function stalkerWith(s, portal, mac, ctl, job, cb) {
3097
3098
  function open(again) { stalkerOpen(s, portal, mac, ctl, function (err) { if (err) { cb(err); return; } run(again); }); }
3098
3099
  if (s.token && s.api) { run(false); } else { open(false); }
3099
3100
  }
3100
- function stalkerChannels(s, ctl, cb) {
3101
+ function stalkerSlim(c) { // (a page's channel: what the playlist takes; thousands of them are held meanwhile)
3102
+ if (!c || typeof c !== 'object') { return null; }
3103
+ 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 };
3104
+ }
3105
+ function stalkerChannels(s, ctl, whole, cb) {
3101
3106
  stalkerAsk(s, 'type=itv&action=get_genres', ctl, function (e0, genres) {
3102
3107
  if (e0 && e0.auth) { cb(e0); return; }
3103
3108
  var g = {};
@@ -3105,14 +3110,21 @@ function stalkerChannels(s, ctl, cb) {
3105
3110
  stalkerAsk(s, 'type=itv&action=get_all_channels', ctl, function (e1, js) {
3106
3111
  if (e1 && e1.auth) { cb(e1); return; }
3107
3112
  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
- var page = 1;
3113
+ if (all.length) { cb(null, all.slice(0, STALKER_CHANNELS), g, all.length > STALKER_CHANNELS ? { total: all.length } : null); return; }
3114
+ var page = 1, tries = 0;
3110
3115
  (function more() {
3111
3116
  stalkerAsk(s, 'type=itv&action=get_ordered_list&genre=*&fav=0&sortby=number&hd=0&p=' + page, ctl, function (e2, o) {
3112
- if (e2 && !all.length) { cb(e2); return; }
3113
- var d = !e2 && o && Array.isArray(o.data) ? o.data : [], total = +(o && o.total_items) || 0;
3114
- all = all.concat(d);
3115
- if (!d.length || page >= STALKER_PAGES || (total && all.length >= total) || all.length >= STALKER_CHANNELS) { cb(null, all.slice(0, STALKER_CHANNELS), g); return; }
3117
+ if (e2 && (!all.length || (whole && e2.auth))) { cb(e2); return; } // (whole: a session gone midway read again, once: stalkerWith)
3118
+ if (e2 && whole && !ctl.gone && tries < STALKER_RETRIES) { tries++; setTimeout(more, STALKER_RETRY_MS); return; }
3119
+ tries = 0;
3120
+ var d = !e2 && o && Array.isArray(o.data) ? o.data : [], total = +(o && o.total_items) || 0, room = STALKER_CHANNELS - all.length;
3121
+ d.slice(0, room).forEach(function (c) { var x = stalkerSlim(c); if (x) { all.push(x); } });
3122
+ var got = total && all.length >= total, full = all.length >= STALKER_CHANNELS, last = !whole && page >= STALKER_PAGES;
3123
+ if (!d.length || got || full || last) {
3124
+ var cut = e2 || (!got && d.length && (full || last)) ? { total: total, why: e2 ? (e2.message || 'failed') : '' } : null;
3125
+ cb(null, all, g, cut);
3126
+ return;
3127
+ }
3116
3128
  page++;
3117
3129
  more();
3118
3130
  });
@@ -3161,9 +3173,19 @@ function stalkerControl(req, res, path, query, leaving) {
3161
3173
  }, function (err, link) { json(err ? { why: err.message || 'failed' } : { url: link }); });
3162
3174
  return;
3163
3175
  }
3164
- if (s.list && Date.now() - s.list.at < STALKER_LIST_MS) { json({ m3u: s.list.m3u, count: s.list.count }); return; }
3176
+ var whole = q.all === '1', sock = req.socket;
3177
+ if (whole && sock && sock.setTimeout) { // (a read of many minutes: Node's two idle minutes would end it)
3178
+ sock.setTimeout(0);
3179
+ if (res.on) { res.on('finish', function () { sock.setTimeout(120000); }); }
3180
+ }
3181
+ function listed(l) { var o = { m3u: l.m3u, count: l.count }; if (l.cut) { o.cut = l.cut; } return o; }
3182
+ if (s.list && Date.now() - s.list.at < STALKER_LIST_MS && (s.list.whole || !whole)) { json(listed(s.list)); return; }
3165
3183
  stalkerWith(s, portal, mac, ctl, function (ss, done) {
3166
- stalkerChannels(ss, ctl, function (err, list, genres) { done(err, err ? null : stalkerM3u(ss, list, genres)); });
3184
+ stalkerChannels(ss, ctl, whole, function (err, list, genres, cut) {
3185
+ var m = err ? null : stalkerM3u(ss, list, genres);
3186
+ if (m && cut) { m.cut = cut; }
3187
+ done(err, m);
3188
+ });
3167
3189
  }, function (err, r) {
3168
3190
  if (err) {
3169
3191
  var refused = err.auth || err.status === 401 || /^not a Stalker answer/.test(err.message || '') && !!s.token;
@@ -3171,8 +3193,8 @@ function stalkerControl(req, res, path, query, leaving) {
3171
3193
  return;
3172
3194
  }
3173
3195
  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({ m3u: r.m3u, count: r.count });
3196
+ s.list = { at: Date.now(), m3u: r.m3u, count: r.count, cut: r.cut || null, whole: whole };
3197
+ json(listed(s.list));
3176
3198
  });
3177
3199
  }
3178
3200