stremiok 2.2.2 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
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.3 — 2026-10-30
7
+ - **Xtream films and series:** an account's films and series in the Movies and Series tabs (a show
8
+ is one tile, its episodes on its page), Discover by its categories, and Search. The IPTV tab
9
+ keeps its live channels. Home says *Loading…* while a long list is read; *Reload* on the account
10
+ reads them again.
11
+ - **Its copies on your titles:** a film or episode from your addons lists the account's copy among
12
+ its sources (*Xtream*), matched by TMDB id, or by name and year.
13
+ - **Stalker portals, experimental** (Settings › Content › IPTV › *Add Stalker portal*): its address and MAC
14
+ address; its channels are a playlist, a row per genre.
15
+ - **★ Favorites** shows all your favorites, not the last 30 picked.
16
+ - **Titles in a Home row** (Settings › Appearance): 30, 50, 100 or 200; a catalog that comes a page
17
+ at a time is asked for more pages to fill the row.
18
+ - **Films in a playlist** (a link to a file) play as films you can scrub through, not as live TV.
19
+ - **Subtitles** within a language come in your addon order, each addon's best match first (they
20
+ were shuffled on older TVs).
21
+ - **Smoother on older TVs:** D-pad moves reach the screen a quarter or more sooner on the 2017 TV;
22
+ long rows build as you reach them, and pictures off screen load while you aren't pressing keys.
23
+ - **Progress** is saved once a minute while playing, and at once when you stop or leave.
24
+
6
25
  ## 2.2.2 — 2026-10-28
7
26
  - **Torrents through a streaming server** (Settings › Content › Streaming server): with Stremio's
8
27
  streaming server or a TorrServer running on your network (a computer or a NAS), torrent-only
package/README.md CHANGED
@@ -31,7 +31,8 @@ video through Samsung's AVPlay API.
31
31
  - **The player:** resume where you stopped, skip intros, recaps and credits, next episode,
32
32
  subtitles (addons', the file's own, and your own files on a USB drive) with your choice of look, audio
33
33
  tracks remembered, switching source mid-playback, private viewing.
34
- - **IPTV and radio** from your M3U playlists and Xtream accounts, with CH+ / CH−.
34
+ - **IPTV and radio** from your M3U playlists, Xtream accounts (with their films and series) and
35
+ Stalker portals, with CH+ / CH−.
35
36
  - **YouTube:** live channels, trailers, and your own YouTube channels, playlists and searches,
36
37
  with SponsorBlock, DeArrow, chapters and captions.
37
38
  - **Local:** the videos on a USB drive, matched to their titles.
@@ -58,8 +59,8 @@ Three ways, all covered step by step in the **[installation guide](docs/INSTALL.
58
59
  2. **API keys**, optional: your own TMDB, OMDb and MDBList keys add ratings, *Cast & more*,
59
60
  *where to watch* and episode trailers.
60
61
  3. **Trakt**, optional: connect your account to share watched marks and Continue Watching.
61
- 4. **IPTV**, optional: your M3U playlist links, or an Xtream account (its server, username and
62
- password).
62
+ 4. **IPTV**, optional: your M3U playlist links, an Xtream account (its server, username and
63
+ password) or a Stalker portal (its address and MAC address).
63
64
  5. **A USB drive**, optional: plug it in and the Local tab appears.
64
65
 
65
66
  [Getting started](docs/USER-GUIDE.md#getting-started) in the user guide walks through each.
@@ -77,8 +78,8 @@ or TorrServer): this app embeds no torrent or debrid engine.
77
78
  > shows that notice on it); its results are rent/buy/subscription *links to external
78
79
  > services*, not video URLs. Add stream addons that return HTTP/HLS URLs for actual playback.
79
80
 
80
- The **IPTV** feature likewise hosts no content: you supply your own M3U playlist URLs or Xtream
81
- accounts. For YouTube entries, the bundled service finds the video's stream; the video itself
81
+ The **IPTV** feature likewise hosts no content: you supply your own M3U playlist URLs, Xtream
82
+ accounts or Stalker portals. For YouTube entries, the bundled service finds the video's stream; the video itself
82
83
  comes straight from YouTube. No video or audio is kept: everything plays straight from its
83
84
  source, unless you download it to your own USB drive. What StremioK does keep, on the TV, is
84
85
  your progress, settings and copies that let it start faster (see
@@ -88,7 +89,8 @@ your progress, settings and copies that let it start faster (see
88
89
 
89
90
  - AVPlay behavior varies by TV generation, codec and HLS provider.
90
91
  - Torrents play only through a streaming server you run on your network.
91
- - Home rows show a catalog's first page (up to 30 titles); Discover pages through the rest.
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.
92
94
  - No StremioK account and no profiles: settings, addons and progress stay on the TV. The
93
95
  only sync is optional: Trakt (watched marks, Continue Watching, ratings).
94
96
  - 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.2" viewmodes="maximized">
3
+ id="http://stremiok.tizen/StremioKTizen" version="2.2.3" 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/css/style.css CHANGED
@@ -48,7 +48,9 @@ html, body {
48
48
  .row { margin: 0 0 16px 0; }
49
49
  .row-title { font-size: 26px; font-weight: bold; margin: 0 0 8px 60px; color: #c7cbd4; }
50
50
  /* vertical padding leaves room for the scaled focus ring (overflow clips the rest) */
51
- .row-scroller { white-space: nowrap; padding: 26px 60px; overflow: hidden; }
51
+ /* Its own GPU layer: on the 2017 TV a D-pad move reached the screen a quarter or more sooner
52
+ (65 -> 47 ms sideways, 96 -> 72 ms up / down, measured); a layer per card was no better overall. */
53
+ .row-scroller { white-space: nowrap; padding: 26px 60px; overflow: hidden; -webkit-transform: translateZ(0); transform: translateZ(0); }
52
54
 
53
55
  /* --- Cards --- */
54
56
  .card {
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.2">
7
+ <link rel="stylesheet" href="css/style.css?v=2.2.3">
8
8
  </head>
9
9
  <body>
10
10
  <!-- CSS-applied sentinel (kept off-screen); app.js waits for its width before rendering -->
@@ -53,37 +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.2"></script>
57
- <script src="js/util.js?v=2.2.2"></script>
58
- <script src="js/iptv.js?v=2.2.2"></script>
59
- <script src="js/epg.js?v=2.2.2"></script>
60
- <script src="js/youtube.js?v=2.2.2"></script>
61
- <script src="js/stremio.js?v=2.2.2"></script>
62
- <script src="js/trakt.js?v=2.2.2"></script>
63
- <script src="js/keys.js?v=2.2.2"></script>
64
- <script src="js/focus.js?v=2.2.2"></script>
65
- <script src="js/tvapps.js?v=2.2.2"></script>
66
- <script src="js/player-core.js?v=2.2.2"></script>
67
- <script src="js/player-store.js?v=2.2.2"></script>
68
- <script src="js/player-lang.js?v=2.2.2"></script>
69
- <script src="js/player-quality.js?v=2.2.2"></script>
70
- <script src="js/player-subs.js?v=2.2.2"></script>
71
- <script src="js/player-audio.js?v=2.2.2"></script>
72
- <script src="js/player-controls.js?v=2.2.2"></script>
73
- <script src="js/player.js?v=2.2.2"></script>
74
- <script src="js/ytplay.js?v=2.2.2"></script>
75
- <script src="js/local.js?v=2.2.2"></script>
76
- <script src="js/downloads.js?v=2.2.2"></script>
77
- <script src="js/stremio-account.js?v=2.2.2"></script>
78
- <script src="js/view-core.js?v=2.2.2"></script>
79
- <script src="js/view-home.js?v=2.2.2"></script>
80
- <script src="js/view-guide.js?v=2.2.2"></script>
81
- <script src="js/view-detail.js?v=2.2.2"></script>
82
- <script src="js/view-search.js?v=2.2.2"></script>
83
- <script src="js/view-settings.js?v=2.2.2"></script>
84
- <script src="js/view-discover.js?v=2.2.2"></script>
85
- <script src="js/views.js?v=2.2.2"></script>
86
- <script src="js/app.js?v=2.2.2"></script>
87
- <script src="js/hubpreview.js?v=2.2.2"></script>
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>
88
89
  </body>
89
90
  </html>
package/js/focus.js CHANGED
@@ -85,12 +85,23 @@ var Focus = (function () {
85
85
  // UP/DOWN in a list of rows (Home, Search, Cast & more): only the next / previous
86
86
  // row's items are candidates, not every card on the screen (thousands on a big IPTV
87
87
  // tab). No row that way: as below (the top menu, …).
88
+ _rowsAsked = false;
88
89
  if ((dir === 'UP' || dir === 'DOWN') && (best = nextRowPick(dir, r))) { setFocus(enterGroup(best)); return; }
90
+ // A card in a sideways row: only its neighbor can be next along the row, and no other
91
+ // row's card is ever on its line. So the next one first, and at the row's end (or going
92
+ // up or down with no row that way) other rows' cards aren't measured at all.
93
+ var inRow = isRowCard(_current);
94
+ if ((dir === 'LEFT' || dir === 'RIGHT') && inRow) {
95
+ var nb = _current[dir === 'RIGHT' ? 'nextElementSibling' : 'previousElementSibling'];
96
+ best = nb ? pick(dir, r, [nb]) : null;
97
+ if (best) { setFocus(enterGroup(best)); return; }
98
+ }
99
+ var skip = (inRow && (dir === 'LEFT' || dir === 'RIGHT' || _rowsAsked)) ? isRowCard : null;
89
100
  // LEFT/RIGHT fast path: in a carousel row the only same-row candidates are the
90
101
  // card's siblings, so skip measuring the whole screen. At a row end (nothing
91
102
  // there) fall back to the full scan, which may reach a non-sibling on the same
92
103
  // line (e.g. last tab pill -> Search).
93
- if ((dir === 'LEFT' || dir === 'RIGHT') && _current.parentNode) {
104
+ if ((dir === 'LEFT' || dir === 'RIGHT') && _current.parentNode && !inRow) {
94
105
  best = pick(dir, r, _current.parentNode.children);
95
106
  }
96
107
  // UP/DOWN: stay inside the scrolling area focus is in (Home rows, a Settings
@@ -100,13 +111,19 @@ var Focus = (function () {
100
111
  // jump to the menu (or skip a row) instead of the row just scrolled out of view.
101
112
  if (dir === 'UP' || dir === 'DOWN') {
102
113
  for (var p = _current.parentNode; !best && p && p !== _scope && p.nodeType === 1; p = p.parentNode) {
103
- if (p.scrollHeight > p.clientHeight + 2) { best = pick(dir, r, p.querySelectorAll('.focusable')); }
114
+ if (p.scrollHeight > p.clientHeight + 2) { best = pick(dir, r, p.querySelectorAll('.focusable'), skip); }
104
115
  }
105
116
  }
106
- if (!best) { best = pick(dir, r, _scope.querySelectorAll('.focusable')); }
117
+ if (!best) { best = pick(dir, r, _scope.querySelectorAll('.focusable'), skip); }
107
118
  if (best) { setFocus(enterGroup(best)); }
108
119
  }
109
120
 
121
+ var _rowsAsked = false; // (this move: every row that way was looked at, by nextRowPick)
122
+ function isRowCard(n) {
123
+ var p = n.parentNode;
124
+ return !!p && (' ' + (p.className || '') + ' ').indexOf(' row-scroller ') !== -1;
125
+ }
126
+
110
127
  function nextRowPick(dir, r) {
111
128
  var row = null, box = null;
112
129
  for (var p = _current.parentNode; p && p !== _scope && p.nodeType === 1; p = p.parentNode) {
@@ -115,6 +132,7 @@ var Focus = (function () {
115
132
  if (row && /\s(rows|search-results|more-rows)\s/.test(cn)) { box = p; break; }
116
133
  }
117
134
  if (!row || !box) { return null; }
135
+ _rowsAsked = true;
118
136
  // a row that's a grid (Watching's): its next / previous line first (a sideways row has
119
137
  // one line: nothing more to measure)
120
138
  var grid = _current.parentNode && (' ' + (_current.parentNode.className || '') + ' ').indexOf(' card-grid ') !== -1 ? _current.parentNode : null;
@@ -139,8 +157,9 @@ var Focus = (function () {
139
157
  return target;
140
158
  }
141
159
 
142
- // Best focusable in `nodes` for a move in `dir` from rect `r` (null if none).
143
- function pick(dir, r, nodes) {
160
+ // Best focusable in `nodes` for a move in `dir` from rect `r` (null if none). skip(node): ones
161
+ // that can't be it.
162
+ function pick(dir, r, nodes, skip) {
144
163
  var cx = r.left + r.width / 2, cy = r.top + r.height / 2;
145
164
 
146
165
  // Collect candidates in the pressed direction with their primary (distance
@@ -150,6 +169,7 @@ var Focus = (function () {
150
169
  for (var i = 0; i < nodes.length; i++) {
151
170
  var node = nodes[i];
152
171
  if (node === _current || !node.classList || !node.classList.contains('focusable')) { continue; }
172
+ if (skip && skip(node)) { continue; } // (without measuring it)
153
173
  var b = node.getBoundingClientRect();
154
174
  if (b.width <= 0 || b.height <= 0) { continue; }
155
175
  var bx = b.left + b.width / 2, by = b.top + b.height / 2;
package/js/iptv.js CHANGED
@@ -30,6 +30,7 @@ var IPTV = (function () {
30
30
  if (typeof p.name === 'string' && p.name.trim()) { o.name = p.name.trim().slice(0, NAME_MAX); }
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
+ if (macOf(p.mac)) { o.mac = macOf(p.mac); } // (a Stalker portal: see addStalker)
33
34
  return o;
34
35
  });
35
36
  }
@@ -185,6 +186,45 @@ var IPTV = (function () {
185
186
  return id;
186
187
  }
187
188
 
189
+ // ---- A Stalker portal: its address and the MAC address your provider registered ----
190
+ // Read by StremioK's service, which asks as a MAG box does (YTPlay.stalkerList): its channels
191
+ // come as an M3U playlist, and a channel's link is asked for each time it plays (streams). Saved
192
+ // as a playlist with its MAC ({ url: the portal, mac }).
193
+ var STB_UA = 'Mozilla/5.0 (QtEmbedded; U; Linux; C) AppleWebKit/533.3 (KHTML, like Gecko) MAG200 stbapp ver: 2 rev: 250 Safari/533.3';
194
+ // A MAC address as typed (00:1A:79:12:34:56, with dashes, or none): 00:1A:79:12:34:56, or ''.
195
+ function macOf(v) {
196
+ var h = ('' + (v || '')).trim().toUpperCase().replace(/[:\-.\s]/g, '');
197
+ return /^[0-9A-F]{12}$/.test(h) ? h.match(/../g).join(':') : '';
198
+ }
199
+ // The portal as typed (http:// when it has no scheme): its address, or ''.
200
+ function stalkerPortal(v) {
201
+ var s = ('' + (v || '')).trim();
202
+ if (s && !/^[a-z][a-z0-9+.-]*:\/\//i.test(s)) { s = 'http://' + s.replace(/^\/+/, ''); }
203
+ return checkedUrl(s);
204
+ }
205
+ function isStalker(p) { return !!(p && p.mac); }
206
+ // Checked through the service (its channels read): { ok, count }, { refused, why },
207
+ // { unreachable, why } or { noService } (a desktop browser).
208
+ function stalkerCheck(portal, mac) {
209
+ if (typeof YTPlay === 'undefined' || !YTPlay.stalkerList) { return Promise.resolve({ noService: true }); }
210
+ return YTPlay.stalkerList(portal, mac).then(function (r) {
211
+ if (r && typeof r.m3u === 'string') { return { ok: true, count: r.count || 0 }; }
212
+ return r && r.refused ? { refused: true, why: '' + (r.why || '') } : { unreachable: true, why: '' + ((r && r.why) || '') };
213
+ }, function (e) { return /no service/.test((e && e.message) || '') ? { noService: true } : { unreachable: true, why: U.problem(e) }; });
214
+ }
215
+ // Added (named after its server: "Stalker · portal.example.com"), or the one already there with
216
+ // that portal and MAC. Its id.
217
+ function addStalker(portal, mac) {
218
+ portal = stalkerPortal(portal); mac = macOf(mac);
219
+ if (!portal || !mac) { return false; }
220
+ var list = getPlaylists();
221
+ for (var i = 0; i < list.length; i++) { if (list[i].url === portal && list[i].mac === mac) { return list[i].id; } }
222
+ var id = newId(), u = U.parseUrl(portal);
223
+ list.push({ id: id, url: portal, mac: mac, name: freeName('Stalker · ' + (u ? u.host : 'portal'), list) });
224
+ savePlaylists(list);
225
+ return id;
226
+ }
227
+
188
228
  function updatePlaylist(id, url) {
189
229
  url = checkedUrl(url);
190
230
  if (!url) { return false; }
@@ -249,6 +289,10 @@ var IPTV = (function () {
249
289
  if (n === 'user-agent') { c.ua = v; } else if (n === 'referer' || n === 'referrer') { c.ref = v; }
250
290
  }
251
291
 
292
+ // A link to a file, not a stream: a film or an episode (an Xtream account's /movie/… and
293
+ // /series/… links, or a video file's name), played as one (seeking; see Player's isLive).
294
+ var VOD_LINK = /\.(mkv|mp4|m4v|avi|mov|wmv|mpg|mpeg|webm)(?:[?#]|$)/i;
295
+ var XTREAM_VOD = /^https?:\/\/[^\/]+(?:\/[^?#]*)?\/(movie|series)\/[^\/?#]+\/[^\/?#]+\/\d+\.[a-z0-9]{2,4}(?:[?#]|$)/i;
252
296
  function truthy(v) { return /^(?:1|true|yes)$/i.test(('' + (v || '')).trim()); }
253
297
 
254
298
  function audioUrl(u) {
@@ -328,6 +372,7 @@ var IPTV = (function () {
328
372
  cur._yt =
329
373
  /^https?:\/\/(?:[^\/]+\.)?youtube\.com(?::\d+)?(?:\/|$)/i.test(u) ||
330
374
  /^https?:\/\/youtu\.be(?::\d+)?(?:\/|$)/i.test(u);
375
+ if (VOD_LINK.test(u) || XTREAM_VOD.test(u)) { cur.vod = true; } // (a film's file: played as one, see plainStreams)
331
376
  add(cur);
332
377
  }
333
378
  cur = null;
@@ -427,8 +472,9 @@ var IPTV = (function () {
427
472
  var st = { id: playlist.id, url: playlist.url, count: 0, groups: 0, error: '', uncached: false, title: '', fetchedAt: 0, stale: false };
428
473
  _status[playlist.id] = st;
429
474
  if (/^http:/i.test(playlist.url)) { // (Settings › Diagnostics › Logs)
430
- U.log('iptv', 'Playlist “' + label(playlist) + '” is downloaded over unencrypted http:// — anyone on the network path can see or change it (and any username / password in its link)');
475
+ 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') + ')');
431
476
  }
477
+ var src = playlist.url + (playlist.mac ? '#mac=' + playlist.mac : ''); // (its saved copy: this portal and MAC's)
432
478
 
433
479
  function finish(text, at) {
434
480
  st.fetchedAt = at || 0;
@@ -437,7 +483,13 @@ var IPTV = (function () {
437
483
  st.title = r.title || '';
438
484
  st.guides = r.guides || [];
439
485
  _sources = null;
440
- return counted(tagChannels(r.channels, playlist.id));
486
+ // An Xtream account's films and episodes: its Movies and Series (js/xtvod.js), not channels
487
+ var channels = r.channels;
488
+ if (isXtream(playlist.url) && typeof XtVod !== 'undefined' && XtVod.hidesVodLines && XtVod.hidesVodLines(playlist.id)) {
489
+ channels = channels.filter(function (c) { return !XTREAM_VOD.test(c.url); });
490
+ st.vodLines = r.channels.length - channels.length;
491
+ }
492
+ return counted(tagChannels(channels, playlist.id));
441
493
  });
442
494
  }
443
495
  function counted(channels) {
@@ -445,7 +497,7 @@ var IPTV = (function () {
445
497
  channels.forEach(function (c) { groups[c.type + '|' + c.group] = 1; });
446
498
  st.count = channels.length;
447
499
  st.groups = Object.keys(groups).length;
448
- if (!channels.length && !st.error) {
500
+ if (!channels.length && !st.error && !st.vodLines) {
449
501
  st.error = 'No channels parsed (is the URL returning the .m3u file?)';
450
502
  }
451
503
  return channels;
@@ -453,13 +505,23 @@ var IPTV = (function () {
453
505
 
454
506
  var saved = force ? Promise.resolve(null) : readPersist(playlist.id);
455
507
  return saved.then(function (p) {
456
- if (p && p.url === playlist.url && typeof p.text === 'string') { return finish(p.text, p.at); }
508
+ if (p && p.url === src && typeof p.text === 'string') { return finish(p.text, p.at); }
457
509
  return fetchIt();
458
510
  });
511
+ // A Stalker portal's channels, from the service (see stalkerCheck): its M3U text.
512
+ function stalkerText() {
513
+ 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; }
516
+ throw new Error((r && r.refused ? 'The portal refused it: ' : 'Couldn’t read the portal: ') + ((r && r.why) || 'no answer'));
517
+ }, function (e) {
518
+ 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));
519
+ });
520
+ }
459
521
  function fetchIt() {
460
- return U.getText(playlist.url, 15000, PLAYLIST_MAX).then(function (text) {
522
+ return (isStalker(playlist) ? stalkerText() : U.getText(playlist.url, 15000, PLAYLIST_MAX)).then(function (text) {
461
523
  var at = Date.now();
462
- return writePersist(playlist.id, playlist.url, text, at).then(function (ok) {
524
+ return writePersist(playlist.id, src, text, at).then(function (ok) {
463
525
  st.uncached = !ok;
464
526
  return finish(text, at);
465
527
  });
@@ -467,14 +529,14 @@ var IPTV = (function () {
467
529
  var msg = (e && e.message) ? e.message : 'Could not fetch the playlist URL';
468
530
  // status 0 / network error on a URL that opens fine in a browser almost
469
531
  // always means the server sent no Access-Control-Allow-Origin header.
470
- if (/HTTP 0\b/.test(msg) || /Network error|^No answer/i.test(msg)) {
532
+ if (!isStalker(playlist) && (/HTTP 0\b/.test(msg) || /Network error|^No answer/i.test(msg))) {
471
533
  msg += ' — the playlist server likely isn\'t sending an ' +
472
534
  'Access-Control-Allow-Origin header (CORS). Serve the .m3u with CORS enabled.';
473
535
  }
474
536
  st.error = msg;
475
537
  // Fall back to this playlist's saved copy so a failed refresh doesn't wipe it.
476
538
  return readPersist(playlist.id).then(function (prev) {
477
- if (!(prev && prev.url === playlist.url && typeof prev.text === 'string')) { return []; }
539
+ if (!(prev && prev.url === src && typeof prev.text === 'string')) { return []; }
478
540
  st.stale = true; // (the channels are the saved copy's)
479
541
  return finish(prev.text, prev.at);
480
542
  });
@@ -629,6 +691,8 @@ var IPTV = (function () {
629
691
  if (c._yt) {
630
692
  return [{ url: c.url, _yt: true, ytPage: c.url, name: c.name, title: 'YouTube · ' + c.group }];
631
693
  }
694
+ var list = getPlaylists(), pl = list[find(list, c._playlistId)];
695
+ if (isStalker(pl)) { return stalkerStreams(c, pl); }
632
696
  return youTubeEnd(c.url).then(function (page) {
633
697
  if (page) { return [{ url: page, _yt: true, ytPage: page, name: c.name, title: 'YouTube · ' + c.group }]; }
634
698
  return plainStreams(c);
@@ -638,11 +702,31 @@ var IPTV = (function () {
638
702
  function plainStreams(c) {
639
703
  var from = sourceOf(c);
640
704
  var st = { url: c.url, name: c.name, title: 'IPTV · ' + c.group + (from ? ' · ' + from : '') };
705
+ if (c.vod) { st._vod = true; }
641
706
  var h = U.sanitizeHeaders({ ua: c.ua, ref: c.ref }); // (only what the player takes, checked)
642
707
  if (h) { st._headers = h; }
643
708
  return [st];
644
709
  }
645
710
 
711
+ // A Stalker portal's channel: its link asked for now (create_link: most portals' links work for
712
+ // a short while, or once), played with a MAG User-Agent. None given: the one in its playlist,
713
+ // unless that's a stand-in (http://localhost/ch/…), which plays nothing.
714
+ function stalkerStreams(c, pl) {
715
+ var asked = typeof YTPlay !== 'undefined' && YTPlay.stalkerLink ? YTPlay.stalkerLink(pl.url, pl.mac, c.url) : Promise.reject(new Error('no service'));
716
+ return asked.then(function (r) {
717
+ if (r && r.url) { return r.url; }
718
+ U.log('iptv', 'Stalker: no link for “' + c.name + '” (' + ((r && r.why) || 'no answer') + ')');
719
+ return '';
720
+ }, function (e) { U.log('iptv', 'Stalker: no link for “' + c.name + '” (' + U.problem(e) + ')'); return ''; }).then(function (url) {
721
+ if (!url && /^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?\//i.test(c.url)) { return []; }
722
+ var st = plainStreams(c)[0];
723
+ st.url = url || c.url;
724
+ var h = U.sanitizeHeaders({ ua: STB_UA, ref: c.ref });
725
+ if (h) { st._headers = h; }
726
+ return [st];
727
+ });
728
+ }
729
+
646
730
  // A local addon object shaped like the HTTP addons in Stremio.loadAddons().
647
731
  // `__local` tells Stremio to route resource calls here instead of over HTTP.
648
732
  function synthAddon() {
@@ -661,6 +745,7 @@ var IPTV = (function () {
661
745
  getPlaylists: getPlaylists, addPlaylist: addPlaylist, updatePlaylist: updatePlaylist,
662
746
  removePlaylist: removePlaylist, renamePlaylist: renamePlaylist, setPlaylistOff: setPlaylistOff,
663
747
  movePlaylist: movePlaylist, setPlaylistGuide: setPlaylistGuide, label: labelOf,
748
+ macOf: macOf, stalkerPortal: stalkerPortal, stalkerCheck: stalkerCheck, addStalker: addStalker, isStalker: isStalker,
664
749
  xtreamParts: xtreamParts, xtreamUrl: xtreamUrl, xtreamCheck: xtreamCheck, addXtream: addXtream, xtreamFormat: xtreamFormat, setXtreamFormat: setXtreamFormat,
665
750
  isFavorite: isFavorite, setFavorite: setFavorite, refreshEvery: refreshEvery, setRefreshEvery: setRefreshEvery, readAt: readAt,
666
751
  channels: function () { return _cache ? _cache.channels : []; }, channel: function (id) { return _cache ? _cache.byId[id] || null : null; }, isEnabled: isEnabled, reset: reset, status: status,
package/js/player-core.js CHANGED
@@ -128,7 +128,7 @@ var PlayerParts = {};
128
128
  saveProgress();
129
129
  // (where you stopped to Trakt; past 80% nothing: Trakt takes no paused place there, and you
130
130
  // may come back)
131
- if (!S.isLive && !_creditsHandled && S.ctx && !S.ctx.trailer && !S.ctx.private && !isNotice() && S.cur > 60 && typeof Trakt !== 'undefined' && Trakt.onProgress &&
131
+ if (!S.isLive && !_creditsHandled && S.ctx && !S.ctx.trailer && !S.ctx.private && !isNotice() && !/^iptv:/.test(S.ctx.id || '') && S.cur > 60 && typeof Trakt !== 'undefined' && Trakt.onProgress &&
132
132
  !(S.dur > 0 && S.cur / S.dur >= 0.8)) {
133
133
  Trakt.onProgress(S.ctx.type, S.ctx.id, S.cur, S.dur, S.ctx.name);
134
134
  }
@@ -157,14 +157,14 @@ var PlayerParts = {};
157
157
 
158
158
  function isActive() { return S.active; }
159
159
 
160
- // fromTicker: the 5-second save while it plays: skipped when nothing moved since the last one
161
- // (paused); a stop, a leave or a jump always saves.
162
- var _savedSig = '';
160
+ // fromTicker: the save while it plays, at most every SAVE_EVERY_MS: skipped when nothing moved
161
+ // since the last one (paused); a stop, a leave or a jump always saves.
162
+ var _savedSig = '', _savedAt = 0, SAVE_EVERY_MS = 60000;
163
163
  function saveProgress(fromTicker) {
164
- if (!S.ctx || !S.dur || S.isLive || S.ctx.trailer || S.ctx.private || isNotice()) { return; } // (a notice clip, private viewing: nothing saved, nothing removed)
164
+ if (!S.ctx || !S.dur || S.isLive || S.ctx.trailer || S.ctx.private || isNotice() || /^iptv:/.test(S.ctx.id || '')) { return; } // (a notice clip, private viewing, a film in a playlist: nothing saved, nothing removed)
165
165
  var sig = progressKey(S.ctx) + '|' + Math.floor(S.cur) + '|' + Math.floor(S.dur);
166
- if (fromTicker && sig === _savedSig) { return; }
167
- _savedSig = sig;
166
+ if (fromTicker && (sig === _savedSig || Date.now() - _savedAt < SAVE_EVERY_MS)) { return; }
167
+ _savedSig = sig; _savedAt = Date.now();
168
168
  // Past the credits the episode is watched: its entry was removed and the next one
169
169
  // queued (handleCredits). Saving again would put it back next to the next episode.
170
170
  if (_creditsHandled) { return; }
@@ -433,7 +433,7 @@ var PlayerParts = {};
433
433
  if (U.crumb) { U.crumb('play ' + (ctx.type || '') + ' ' + (ctx.private ? '(private)' : /^file:/i.test(ctx.url || '') ? 'file .' + ('' + ctx.url).split('.').pop() : ('' + (ctx.url || '')).replace(/^https?:\/\/([^\/?#]+).*$/i, '$1'))); } // (Diagnostics, after an unexpected close)
434
434
  S.active = true; S.cur = 0; S.dur = 0; _bg = null; S.actual = null;
435
435
  // Stremio "tv" and "radio" types are strong live hints; refined after prepare.
436
- S.isLive = (ctx.type === 'tv' || ctx.type === 'radio') || /^iptv:/.test(ctx.id || '') || !!ctx.isLive; // (an IPTV channel: live, a sports one too)
436
+ S.isLive = !(ctx.stream && ctx.stream._vod) && ((ctx.type === 'tv' || ctx.type === 'radio') || /^iptv:/.test(ctx.id || '') || !!ctx.isLive); // (an IPTV channel: live, a sports one too; a film in a playlist isn't)
437
437
  formatStart(ctx);
438
438
  S.ctx.resumeSec = (ctx.trailer || ctx.fromStart) ? 0 : (ctx.resumeSec || getResume(ctx.type, ctx.id)); // (Play from start: 0:00)
439
439
 
@@ -580,7 +580,7 @@ var PlayerParts = {};
580
580
 
581
581
  // Decides live vs VOD from the reported duration (0 / non-finite = live).
582
582
  function markLiveFromDuration() {
583
- if (S.ctx && (S.ctx.type === 'tv' || S.ctx.type === 'radio' || /^iptv:/.test(S.ctx.id || ''))) { S.isLive = true; }
583
+ if (S.ctx && !(S.ctx.stream && S.ctx.stream._vod) && (S.ctx.type === 'tv' || S.ctx.type === 'radio' || /^iptv:/.test(S.ctx.id || ''))) { S.isLive = true; }
584
584
  if (!S.dur || S.dur <= 0 || !isFinite(S.dur)) { S.isLive = true; }
585
585
  }
586
586
 
@@ -142,7 +142,7 @@
142
142
  // ---------- progress (Continue Watching) ----------
143
143
  function progressAll() { return U.store.get(PROGRESS_KEY, {}); }
144
144
  function progressKey(ctx) { return ctx.type + ':' + ctx.id; }
145
- function writeProgress(all) { U.store.set(PROGRESS_KEY, all); }
145
+ function writeProgress(all) { U.store.set(PROGRESS_KEY, all, true); }
146
146
 
147
147
  // "Add to Continue Watching": list a title there without playing it. Also how
148
148
  // a show's next episode is queued (credits, marking episodes watched): like an added