stremiok 2.2.6 → 2.2.8

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/js/view-core.js CHANGED
@@ -140,6 +140,47 @@ var ViewParts = {};
140
140
  }, function () { if (!over) { how.textContent = 'Your phone can’t reach the TV just now (no home network, or StremioK’s service isn’t running): type it instead.'; } });
141
141
  }
142
142
  function qrSpotCanvas(text) { var s = qrSpot(text); s.className = ''; return s; }
143
+ // A file given to the phone (an export: YTPlay.entryGive): a QR to the service's one-time page
144
+ // that shows it to copy or download; kept open while the QR is on screen (asked every
145
+ // GIVE_POLL_MS, which also says once the phone has it), closed with Done.
146
+ var GIVE_POLL_MS = 3000;
147
+ function phoneGive(title, text, note) {
148
+ var existing = document.querySelector('.modal-overlay');
149
+ if (existing) { existing.parentNode.removeChild(existing); }
150
+ var overlay = U.el('div', 'modal-overlay'), box = U.el('div', 'modal-box qr-box');
151
+ box.appendChild(U.el('div', 'modal-msg', title));
152
+ var spot = U.el('div', 'qr-spot'), how = U.el('div', 'qr-note', 'Opening the page for your phone…'), link = U.el('div', 'qr-link', '');
153
+ box.appendChild(spot); box.appendChild(link); box.appendChild(how);
154
+ if (note) { box.appendChild(U.el('div', 'qr-note', note)); }
155
+ var row = U.el('div', 'modal-row'), done = U.el('div', 'pill focusable modal-btn', 'Done');
156
+ var token = null, timer = null, over = false;
157
+ done.__onselect = function () { closeModal(); };
158
+ row.appendChild(done); box.appendChild(row); overlay.appendChild(box);
159
+ document.body.appendChild(overlay);
160
+ showModal(overlay, done);
161
+ onModalClose(function () { over = true; if (timer) { clearTimeout(timer); } if (token && YTPlay.entryClose) { YTPlay.entryClose(token); } token = null; });
162
+ function poll() {
163
+ timer = setTimeout(function () {
164
+ timer = null;
165
+ if (over || !token) { return; }
166
+ YTPlay.entrySeen(token).then(function (seen) {
167
+ if (over) { return; }
168
+ if (seen) { how.textContent = 'Your phone has it: copy or download it there, then Done.'; }
169
+ poll();
170
+ }, function () { if (!over) { how.textContent = 'The phone page closed. Export again to open another.'; token = null; } });
171
+ }, GIVE_POLL_MS);
172
+ }
173
+ if (typeof YTPlay === 'undefined' || !YTPlay.entryGive) { how.textContent = 'It needs StremioK’s service on the TV (not in a desktop browser).'; return; }
174
+ YTPlay.entryGive(text).then(function (r) {
175
+ if (over) { if (r && r.token) { YTPlay.entryClose(r.token); } return; }
176
+ if (!r || !r.url) { throw new Error('no page'); }
177
+ token = r.token;
178
+ spot.appendChild(qrSpotCanvas(r.url));
179
+ link.textContent = r.url;
180
+ how.textContent = 'Scan it with your phone (on the same Wi-Fi as the TV): the page shows the file to copy or download. For the next 5 minutes, unencrypted over your home network: only on a network you trust.';
181
+ poll();
182
+ }, function () { if (!over) { how.textContent = 'Your phone can’t reach the TV just now (no home network, or StremioK’s service isn’t running).'; } });
183
+ }
143
184
 
144
185
  // Show `overlay` (already in the page) as the modal: focus moves into it, and
145
186
  // closeModal() returns focus to where it was on the screen underneath.
@@ -365,6 +406,7 @@ var ViewParts = {};
365
406
  closeModal();
366
407
  U.toast('Reloading playlist…', 4000);
367
408
  if (typeof XtVod !== 'undefined' && XtVod.reload) { XtVod.reload(playlist.id); } // (an Xtream account: its films and series too)
409
+ if (typeof StVod !== 'undefined' && StVod.reload) { StVod.reload(playlist.id); } // (a Stalker portal: the same)
368
410
  Stremio.iptvReload(playlist.id).then(function () {
369
411
  refreshAddonRows('local:iptv');
370
412
  var st = Stremio.iptvStatus(playlist.id);
@@ -443,7 +485,7 @@ var ViewParts = {};
443
485
  var go = U.el('div', 'pill focusable modal-btn');
444
486
  function ticked() { return items.filter(function (it) { return on[it.key]; }).map(function (it) { return it.key; }); }
445
487
  function drawGo() { go.textContent = opts.button(ticked().length); }
446
- var all = U.el('div', 'pick-item focusable', 'Select all');
488
+ var all = U.el('div', 'pick-item focusable', can.length && can.every(function (it) { return on[it.key]; }) ? 'Select none' : 'Select all'); // (all ticked at first: an export's)
447
489
  all.__onselect = function () {
448
490
  var every = can.every(function (it) { return on[it.key]; });
449
491
  can.forEach(function (it) { on[it.key] = !every; });
@@ -889,7 +931,7 @@ var ViewParts = {};
889
931
  V.buildTopMenu = buildTopMenu;
890
932
  V.closeModal = closeModal;
891
933
  V.confirm = confirm;
892
- V.qrModal = qrModal;
934
+ V.qrModal = qrModal; V.phoneGive = phoneGive;
893
935
  V.phoneEntry = phoneEntry;
894
936
  V.header = header;
895
937
  V.isModalOpen = isModalOpen;
package/js/view-detail.js CHANGED
@@ -151,8 +151,22 @@
151
151
  }
152
152
  function openTitle(v, opts) { App.openDetail('movie', v.id, { id: v.id, type: 'movie', name: v.title || v.name || '', poster: v.thumbnail }, null, opts); }
153
153
 
154
+ // A series by its details, whatever its card or row called it (an anime addon's: a film,
155
+ // "anime", "other"): they say it's a series, or list numbered episodes without files of
156
+ // their own. Its seasons and episodes, then, not sources. (A YouTube list: as it is.)
157
+ var AS_SERIES = /^(movie|anime|other)$/;
158
+ function asSeries() {
159
+ var meta = _d.meta, vids = (meta && Array.isArray(meta.videos)) ? meta.videos : [];
160
+ if (!vids.length || !AS_SERIES.test('' + _d.type) || /^(ytk|yt_id):/.test('' + (meta.id || _d.id))) { return false; }
161
+ if (vids.some(function (v) { return !v || (v.streams && v.streams.length); })) { return false; }
162
+ var numbered = vids.length > 1 && vids.every(function (v) { return typeof v.season === 'number' && typeof v.episode === 'number'; });
163
+ if (meta.type !== 'series' && !numbered) { return false; }
164
+ _d.type = 'series';
165
+ return true;
166
+ }
167
+
154
168
  function asEpisodeList() {
155
- if (asCollection()) { return; }
169
+ if (asCollection() || asSeries()) { return; } // (a collection first: its films are numbered too)
156
170
  var meta = _d.meta, t = _d.type;
157
171
  // (opened again as a series, from Continue Watching: still a YouTube list, by its own type)
158
172
  var again = !!meta && t === 'series' && /^(ytk|yt_id):/.test('' + (meta.id || _d.id)) && !!meta.type && meta.type !== 'series';
package/js/view-home.js CHANGED
@@ -35,7 +35,7 @@
35
35
  function hasLocal() { return typeof LocalMedia !== 'undefined' && LocalMedia.present(); }
36
36
  function hasGuide() { return typeof EPG !== 'undefined' && !!EPG.hasAny && EPG.hasAny(); }
37
37
 
38
- // The top menu's order (Settings › Appearance › Menu): Watching first and Settings last, the
38
+ // The top menu's order (Settings › Home › Menu): Watching first and Settings last, the
39
39
  // rest (the tabs, Discover, Search) in yours. A saved order is kept as far as it goes: an
40
40
  // item it doesn't have (one added since) goes after the one it usually follows, and one
41
41
  // that no longer exists is dropped.
@@ -72,7 +72,7 @@
72
72
 
73
73
  // Which tabs to show in the top menu (needs the home catalogs; falls back to the
74
74
  // standard set before they've loaded so the menu is consistent everywhere).
75
- // Tabs you hid (Settings › Appearance › Menu) aren't shown; Watching always is.
75
+ // Tabs you hid (Settings › Home › Menu) aren't shown; Watching always is.
76
76
  function availableTabs() {
77
77
  var hidden = Stremio.getPrefs().hiddenTabs || [];
78
78
  function shown(t) { return t.key === 'continue' || (hidden.indexOf(t.key) === -1 && (t.key !== 'guide' || hasGuide())); }
@@ -928,7 +928,7 @@
928
928
  }
929
929
  function previewTiles() {
930
930
  var out = [];
931
- var recent = Stremio.getPrefs().homePreviewOrder !== 'watching'; // (Settings › Appearance › Home bar order)
931
+ var recent = Stremio.getPrefs().homePreviewOrder !== 'watching'; // (Settings › Home › Home bar preview)
932
932
  continueEntries(recent).forEach(function (e) { // (the latest first: what you're bingeing leads; or Watching's order)
933
933
  if (out.length >= PREVIEW_MAX || !playableNow(e)) { return; }
934
934
  var base = e.parent || e.id.split(':')[0], code = e.type === 'series' ? codeOfId(e.id) : '';
@@ -1202,7 +1202,7 @@
1202
1202
  // A tab asked for whose rows are still coming (a first playlist's IPTV tab): shown when they
1203
1203
  // come, if Home is still on the tab it showed instead. { key, instead }
1204
1204
  var _wantTab = null;
1205
- // Start on the Guide (Settings › Appearance › Start on): at a launch its guides aren't read yet,
1205
+ // Start on the Guide (Settings › Home › Start on): at a launch its guides aren't read yet,
1206
1206
  // so Home opens on Watching and switches once they are, if it's still there (a tab you picked:
1207
1207
  // not). The tab shown instead, or null.
1208
1208
  var _wantGuide = null;
@@ -1230,7 +1230,7 @@
1230
1230
 
1231
1231
  if (_homeCatalogs === null) { useHomeCache(); }
1232
1232
  var launch = _homeTab === null;
1233
- if (launch) { _homeTab = Stremio.getPrefs().startTab; } // (a launch: Settings › Appearance › Start on)
1233
+ if (launch) { _homeTab = Stremio.getPrefs().startTab; } // (a launch: Settings › Home › Start on)
1234
1234
  // Keep the active tab valid for what's actually available.
1235
1235
  var avail = availableTabs();
1236
1236
  if (!_homeTab || !avail.some(function (t) { return t.key === _homeTab; })) {
@@ -1440,6 +1440,7 @@
1440
1440
  // The IPTV playlists read after your addons loaded (they aren't waited for): their rows join.
1441
1441
  if (typeof Stremio !== 'undefined' && Stremio.onIptvReady) { Stremio.onIptvReady(function () { refreshAddonRows('local:iptv'); }); }
1442
1442
  if (typeof XtVod !== 'undefined' && XtVod.onChange) { XtVod.onChange(function () { refreshAddonRows('local:xtvod'); }); } // (an Xtream account's films and series, once its categories came)
1443
+ if (typeof StVod !== 'undefined' && StVod.onChange) { StVod.onChange(function () { refreshAddonRows('local:stvod'); }); } // (a Stalker portal's, the same)
1443
1444
  var PARTIAL_DELAY = 150; // coalesces catalogs that arrive together into one redraw
1444
1445
  function loadHomeCatalogs() {
1445
1446
  if (_homeLoading) { return; }
@@ -1533,7 +1534,7 @@
1533
1534
 
1534
1535
  // Catalogs of type "other" (e.g. Torrentio's RealDebrid downloads) aren't live TV:
1535
1536
  // their items go to a Movies row and a Series row, split by the release name.
1536
- // Everything is capped to the cards a Home row shows (Settings › Appearance › Titles in a Home
1537
+ // Everything is capped to the cards a Home row shows (Settings › Home › Titles in a Home
1537
1538
  // row), but for IPTV's ★ Favorites (all: every one you picked, up to the 300 kept).
1538
1539
  var ROW_CARDS = 30;
1539
1540
  function rowCards() { var n = Stremio.getPrefs().rowCards; return n === 'all' ? Infinity : n || ROW_CARDS; }
package/js/view-search.js CHANGED
@@ -156,7 +156,7 @@
156
156
 
157
157
  // Results come as one row per search source (Stremio.searchSources): each searchable
158
158
  // catalog ("Series · Popular · Cinemeta"), IPTV's groups as one per type, in the order
159
- // and with the ones shown in Settings > Appearance > Search results; each row in its
159
+ // and with the ones shown in Settings > Home > Search results; each row in its
160
160
  // addon's own order (its best match first). A row appears as its catalog answers, in its
161
161
  // place; one whose catalog pages loads more as focus nears its end.
162
162
  var LOAD_AHEAD = 6;
@@ -259,7 +259,7 @@
259
259
  }
260
260
  if (!found) {
261
261
  results.appendChild(U.el('div', 'search-empty', (failed && failed === defs.length) ? 'Search failed. Check your network.'
262
- : (!defs.length && !people) ? 'Nothing to search: no addon can, or all are hidden (Settings › Appearance › Search results).'
262
+ : (!defs.length && !people) ? 'Nothing to search: no addon can, or all are hidden (Settings › Home › Search results).'
263
263
  : 'No results for “' + query + '”.' + (silent.length ? ' No answer from: ' + silent.join(', ') + ' (try again).' : '')));
264
264
  }
265
265
  });
@@ -74,8 +74,9 @@
74
74
  if (cfg.phone && V.phoneEntry) {
75
75
  var phoneBtn = U.el('div', 'pill focusable', '▣ From your phone');
76
76
  phoneBtn.__onselect = function () {
77
- V.phoneEntry({ title: cfg.title || 'Enter value', what: cfg.phone, validate: cfg.validate,
78
- onText: function (t) { input.value = t; Focus.setFocus(confirmBtn); U.toast('From your phone: check it, then Confirm', 3500); },
77
+ var takes = cfg.phoneText; // (text the caller takes as it is from the phone: an import's pasted file)
78
+ V.phoneEntry({ title: cfg.title || 'Enter value', what: cfg.phone, validate: function (t) { return takes && takes.accepts(t) ? null : (cfg.validate ? cfg.validate(t) : null); },
79
+ onText: function (t) { if (takes && takes.accepts(t)) { takes.take(t); return; } input.value = t; Focus.setFocus(confirmBtn); U.toast('From your phone: check it, then Confirm', 3500); },
79
80
  onType: function () { Focus.setFocus(input); } });
80
81
  };
81
82
  row.appendChild(phoneBtn);
@@ -215,11 +216,6 @@
215
216
  get: function () { return { zoom: '' + zoomPct() }; },
216
217
  set: function (cfg) { Stremio.setPref('zoom', +cfg.zoom); applyAppearance(); }
217
218
  }));
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',
220
- get: function () { return { rowCards: '' + Stremio.getPrefs().rowCards }; },
221
- set: function (cfg) { Stremio.setPref('rowCards', cfg.rowCards === 'all' ? 'all' : +cfg.rowCards); clearCatalogCache(); } // (the rows read again, with more pages or fewer)
222
- }));
223
219
  wrap.appendChild(subPickRow('Poster orientation', POSTER_SHAPES, 'posterShape', {
224
220
  get: function () { return { posterShape: Stremio.getPrefs().posterShape }; },
225
221
  set: function (cfg) { Stremio.setPref('posterShape', cfg.posterShape); markHomeDirty(); } // Home redraws on return
@@ -228,6 +224,25 @@
228
224
  get: function () { return { posterRatings: Stremio.getPrefs().posterRatings ? 'on' : 'off' }; },
229
225
  set: function (cfg) { Stremio.setPref('posterRatings', cfg.posterRatings === 'on'); markHomeDirty(); }
230
226
  }));
227
+ wrap.appendChild(subPickRow('Hide spoilers', [['off', 'Off'], ['pictures', 'Pictures'], ['all', 'Pictures and synopses']], 'spoilers', {
228
+ get: function () { return { spoilers: Stremio.getPrefs().spoilers }; },
229
+ set: function (cfg) { Stremio.setPref('spoilers', cfg.spoilers); }
230
+ }));
231
+ focusSettings();
232
+ }
233
+ // Home: the tab a launch opens on, how many titles a row holds, the TV's home bar, and the
234
+ // pages ordering the top menu, the Home rows and the Search rows.
235
+ function settingsHome(wrap) {
236
+ wrap.appendChild(U.el('h2', null, 'Home'));
237
+ wrap.appendChild(subPickRow('Start on', V.HOME_TABS.map(function (t) { return [t.key, t.label]; }), 'startTab', {
238
+ get: function () { return { startTab: Stremio.getPrefs().startTab }; },
239
+ set: function (cfg) { Stremio.setPref('startTab', cfg.startTab); } // (the next launch: Home stays where it is now)
240
+ }));
241
+ wrap.appendChild(subPickRow('Titles in a Home row', [['30', '30'], ['50', '50'], ['100', '100'], ['200', '200'], ['all', 'Unlimited']], 'rowCards', {
242
+ 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',
243
+ get: function () { return { rowCards: '' + Stremio.getPrefs().rowCards }; },
244
+ set: function (cfg) { Stremio.setPref('rowCards', cfg.rowCards === 'all' ? 'all' : +cfg.rowCards); clearCatalogCache(); } // (the rows read again, with more pages or fewer)
245
+ }));
231
246
  if (typeof HubPreview !== 'undefined' && HubPreview.available()) { // (the sideloaded app: see js/hubpreview.js)
232
247
  // one choice: the tiles' order, or none (sent at once, whatever the wait)
233
248
  wrap.appendChild(subPickRow('Home bar preview', [['recent', 'Most recent first'], ['watching', 'As in Watching'], ['off', 'Off']], 'homeBar', {
@@ -239,14 +254,6 @@
239
254
  }
240
255
  }));
241
256
  }
242
- wrap.appendChild(subPickRow('Hide spoilers', [['off', 'Off'], ['pictures', 'Pictures'], ['all', 'Pictures and synopses']], 'spoilers', {
243
- get: function () { return { spoilers: Stremio.getPrefs().spoilers }; },
244
- set: function (cfg) { Stremio.setPref('spoilers', cfg.spoilers); }
245
- }));
246
- wrap.appendChild(subPickRow('Start on', V.HOME_TABS.map(function (t) { return [t.key, t.label]; }), 'startTab', {
247
- get: function () { return { startTab: Stremio.getPrefs().startTab }; },
248
- set: function (cfg) { Stremio.setPref('startTab', cfg.startTab); } // (the next launch: Home stays where it is now)
249
- }));
250
257
  var menu = sectionRow('Menu ›', 'Order the top menu, and show or hide its tabs', 'menuorder');
251
258
  menu.className += ' cfg-row';
252
259
  wrap.appendChild(menu);
@@ -349,9 +356,9 @@
349
356
  Focus.setScope(s, s.querySelector('.settings-wrap .focusable') || undefined);
350
357
  }
351
358
 
352
- // Settings is four groups (Content, Playback, Appearance, Diagnostics); each opens a page of
353
- // its sections. [title, description, section] rows; Appearance is its own page (its
354
- // look settings are right on it, above Home feeds and Search results).
359
+ // Settings is five groups (Content, Playback, Appearance, Home, Diagnostics); each opens a page
360
+ // of its sections. [title, description, section] rows; Appearance and Home are pages of their
361
+ // own (their settings right on them; Home's Menu, Home feeds and Search results open pages).
355
362
  var SETTINGS_GROUPS = {
356
363
  content: { title: 'Content', rows: [
357
364
  ['Addons', 'Catalog, stream & subtitle addons', 'addons'],
@@ -361,7 +368,8 @@
361
368
  ['YouTube', 'Your YouTube channels, playlists and searches; YouTube in Search', 'youtube'],
362
369
  ['Streaming apps', 'Your apps (Prime Video, Netflix, …) that open a title\'s "where to watch" sources', 'appshortcuts'],
363
370
  ['USB drive', 'The Local tab: what\'s on your drive, matched to titles; hidden files', 'usb'],
364
- ['Import configuration file', 'Import addons, API keys & IPTV playlists', 'import']] },
371
+ ['Import configuration file', 'Import addons, API keys & IPTV playlists', 'import'],
372
+ ['Export configuration', 'Your addons, playlists, API keys and settings, to your phone', 'export']] },
365
373
  playback: { title: 'Playback', rows: [
366
374
  ['Audio', 'Preferred and second-choice audio language', 'audio'],
367
375
  ['Subtitles', 'Default language, size, color, background, position, font', 'subtitles'],
@@ -378,9 +386,9 @@
378
386
 
379
387
  // Return true if BACK stepped a settings section back to the menu.
380
388
  // BACK goes up one level, onto the row it came from: from a section to its group (on
381
- // that section, not the first one), from Home feeds / Search results to Appearance,
389
+ // that section, not the first one), from Menu / Home feeds / Search results to Home,
382
390
  // from a group to the Settings list (on that group).
383
- var SECTION_PARENT = { menuorder: 'appearance', feeds: 'appearance', searchfeeds: 'appearance', aiomanager: 'addons', subtitlelook: 'subtitles', rankfilters: 'ranking', rankplay: 'ranking' };
391
+ var SECTION_PARENT = { menuorder: 'home', feeds: 'home', searchfeeds: 'home', aiomanager: 'addons', subtitlelook: 'subtitles', rankfilters: 'ranking', rankplay: 'ranking' };
384
392
  Object.keys(SETTINGS_GROUPS).forEach(function (g) {
385
393
  SETTINGS_GROUPS[g].rows.forEach(function (row) { SECTION_PARENT[row[2]] = g; });
386
394
  });
@@ -424,9 +432,11 @@
424
432
  else if (_settingsSection === 'private') { settingsPrivate(wrap); }
425
433
  else if (_settingsSection === 'appshortcuts') { settingsAppShortcuts(wrap); }
426
434
  else if (_settingsSection === 'import') { settingsImport(wrap); }
435
+ else if (_settingsSection === 'export') { settingsExport(wrap); }
427
436
  else if (_settingsSection === 'aiomanager') { settingsAiom(wrap); }
428
437
  else if (_settingsSection === 'server') { settingsServer(wrap); }
429
438
  else if (_settingsSection === 'appearance') { settingsAppearance(wrap); }
439
+ else if (_settingsSection === 'home') { settingsHome(wrap); }
430
440
  else if (_settingsSection === 'formats') { settingsFormats(wrap); }
431
441
  else { settingsMenu(wrap); }
432
442
  var ver = appVersion();
@@ -468,7 +478,8 @@
468
478
  wrap.appendChild(U.el('h2', null, 'Settings'));
469
479
  wrap.appendChild(sectionRow('Content', 'Addons, API keys, IPTV playlists, streaming apps, importing a configuration file', 'content'));
470
480
  wrap.appendChild(sectionRow('Playback', 'Audio and subtitles, source ranking, feed sources, formats', 'playback'));
471
- wrap.appendChild(sectionRow('Appearance', 'Background, accent color, zoom, poster orientation, Home feeds, Search results', 'appearance'));
481
+ wrap.appendChild(sectionRow('Appearance', 'Background, accent color, zoom, posters, spoilers', 'appearance'));
482
+ wrap.appendChild(sectionRow('Home', 'The tab it opens on, the top menu, Home feeds, Search results', 'home'));
472
483
  wrap.appendChild(sectionRow('Diagnostics', 'Logs, storage, installed apps; how StremioK was installed', 'diagnostics'));
473
484
  if (typeof YTPlay !== 'undefined' && YTPlay.installMode && YTPlay.installMode() === 'tizenbrew') { wrap.appendChild(U.el('div', 'hint', TIZENBREW_NOTE)); }
474
485
  focusBack(wrap);
@@ -848,6 +859,53 @@
848
859
  var IMPORT_URL_KEY = 'stremiok.importurl';
849
860
 
850
861
  var _importGen = 0; // (the configuration file being imported, the latest)
862
+ // A configuration file's text: what it has listed, none ticked, to tick and import. here():
863
+ // the entry screen still showing (back to Settings from it). Imported settings: StremioK
864
+ // starts again with them.
865
+ function importText(text, here) {
866
+ var parsed = Stremio.parseSetupList(text);
867
+ if (!parsed.items.length) { U.toast('No supported entries found in that file' + (parsed.ignored ? ' (' + parsed.ignored + ' ignored)' : ''), 4500); return; }
868
+ if (here()) { App.back(); renderSettings(); }
869
+ pickMany('In that file: tick what to import', parsed.items.map(function (it, i) { return { key: '' + i, label: it.label, have: it.have, note: it.note }; }),
870
+ { button: function (n) { return 'Import ' + n; } }, function (keys) {
871
+ var imported = Stremio.applySetupEntries(keys.map(function (k) { return parsed.items[+k]; })), parts = [];
872
+ if (imported.addons) { parts.push(imported.addons + ' addon' + (imported.addons === 1 ? '' : 's')); }
873
+ if (imported.playlists) { parts.push(imported.playlists + ' playlist' + (imported.playlists === 1 ? '' : 's')); }
874
+ if (imported.omdb) { parts.push('OMDb key'); }
875
+ if (imported.tmdb) { parts.push('TMDB key'); }
876
+ if (imported.mdblist) { parts.push('MDBList key'); }
877
+ if (imported.settings) { parts.push('your settings'); }
878
+ if (imported.addons || imported.playlists) { clearCatalogCache(); }
879
+ var message = parts.length ? ('Imported: ' + parts.join(', ')) : 'Nothing imported';
880
+ if (parsed.ignored) { message += ' (' + parsed.ignored + ' ignored)'; }
881
+ if (imported.settings) { // (every part of StremioK reads them afresh)
882
+ U.toast(message + '. StremioK starts again with them…', 4000);
883
+ setTimeout(function () { try { window.location.reload(); } catch (e) {} }, 2500);
884
+ return;
885
+ }
886
+ U.toast(message, 4500);
887
+ renderSettings();
888
+ });
889
+ }
890
+ // Settings › Content › Export configuration: what goes in, all ticked at first, given to your
891
+ // phone (V.phoneGive) as the file Import configuration file reads (Stremio.exportSetup).
892
+ function settingsExport(wrap) {
893
+ wrap.appendChild(U.el('h2', null, 'Export configuration'));
894
+ var row = U.el('div', 'addon-item focusable add-row');
895
+ row.appendChild(U.el('div', 'a-name', '⇧ Export to your phone'));
896
+ row.appendChild(U.el('div', 'a-url', 'Your addons, IPTV playlists, API keys and settings, as a file to import later'));
897
+ row.__onselect = function () {
898
+ var groups = Stremio.exportGroups();
899
+ pickMany('Tick what to export', groups.map(function (g) { return { key: g.key, label: g.label }; }),
900
+ { on: groups.map(function (g) { return g.key; }), button: function (n) { return 'Export ' + n; } }, function (keys) {
901
+ V.phoneGive('Export configuration', Stremio.exportSetup(keys, appVersion()),
902
+ 'It holds your addon links, playlist logins, API keys and MAC addresses: keep the file private. Not in it: your Trakt sign-in, history and progress.');
903
+ });
904
+ };
905
+ wrap.appendChild(row);
906
+ wrap.appendChild(U.el('div', 'hint', 'To restore it (after a reinstall, or on another TV): Import configuration file › ▣ From your phone, then choose the file there (or paste it).'));
907
+ focusSettings();
908
+ }
851
909
  function settingsImport(wrap) {
852
910
  wrap.appendChild(U.el('h2', null, 'Import configuration file'));
853
911
  var lastUrl = U.store.get(IMPORT_URL_KEY, '') || '';
@@ -873,34 +931,17 @@
873
931
  var entry = scr('addaddon'), mine = ++_importGen;
874
932
  function here() { return mine === _importGen && !/\bhidden\b/.test(entry.className); }
875
933
  U.getText(v, 15000, 256 * 1024).then(function (text) { // (a list of URLs and keys: 256 KB is plenty)
876
- var parsed = Stremio.parseSetupList(text);
877
- if (!parsed.items.length) { U.toast('No supported entries found in that file' + (parsed.ignored ? ' (' + parsed.ignored + ' ignored)' : ''), 4500); return; }
878
- if (here()) { App.back(); renderSettings(); }
879
- // what the file has, none ticked: you tick what to import
880
- pickMany('In that file: tick what to import', parsed.items.map(function (it, i) { return { key: '' + i, label: it.label, have: it.have, note: it.note }; }),
881
- { button: function (n) { return 'Import ' + n; } }, function (keys) {
882
- done(Stremio.applySetupEntries(keys.map(function (k) { return parsed.items[+k]; })), parsed.ignored);
883
- });
934
+ importText(text, here);
884
935
  }, function (err) {
885
936
  if (!here()) { return; }
886
937
  var why = U.problem(err);
887
938
  U.toast(/^too large/.test(why) ? 'That file is ' + why + ': a configuration file is a short list of URLs and keys.'
888
939
  : 'Could not fetch that configuration file (' + why + '; check the URL / CORS).', 5000);
889
940
  });
890
- function done(imported, ignored) {
891
- var parts = [];
892
- if (imported.addons) { parts.push(imported.addons + ' addon' + (imported.addons === 1 ? '' : 's')); }
893
- if (imported.playlists) { parts.push(imported.playlists + ' playlist' + (imported.playlists === 1 ? '' : 's')); }
894
- if (imported.omdb) { parts.push('OMDb key'); }
895
- if (imported.tmdb) { parts.push('TMDB key'); }
896
- if (imported.mdblist) { parts.push('MDBList key'); }
897
- if (imported.addons || imported.playlists) { clearCatalogCache(); }
898
- var message = parts.length ? ('Imported: ' + parts.join(', ')) : 'Nothing imported';
899
- if (ignored) { message += ' (' + ignored + ' ignored)'; }
900
- U.toast(message, 4500);
901
- renderSettings();
902
- }
903
- }
941
+ },
942
+ // From your phone, the file itself pasted (not a link): imported as it is
943
+ phoneText: { accepts: function (t) { return /\n/.test(t) || !/^https?:\/\//i.test(('' + t).trim()); },
944
+ take: function (t) { ++_importGen; importText(t, function () { return true; }); } }
904
945
  });
905
946
  };
906
947
  wrap.appendChild(listRow);
@@ -2055,7 +2096,7 @@
2055
2096
  return first;
2056
2097
  }
2057
2098
 
2058
- // ----- Home feeds and Search results (Settings > Appearance): order, show / hide -----
2099
+ // ----- Home feeds and Search results (Settings > Home): order, show / hide -----
2059
2100
  // kind 'home': the Home rows (every catalog); 'search': the Search rows (every catalog
2060
2101
  // that can search, IPTV as one per type). ▲/▼ moves one; OK on its name shows / hides it.
2061
2102
  // 'menu': the top menu between Watching and Settings (the tabs, Discover, Search: ViewParts'
@@ -2063,7 +2104,7 @@
2063
2104
  var MENU_FIXED = { discover: 'Discover', search: 'Search' };
2064
2105
  function menuHidden(k) { return !MENU_FIXED[k] && (Stremio.getPrefs().hiddenTabs || []).indexOf(k) !== -1; }
2065
2106
  var FEED_KINDS = {
2066
- menu: { section: 'menuorder', title: 'Appearance › Menu', hint: 'Watching comes first and Settings last: ⇈ ▲ ▼ ⇊ put the rest in your order · OK on a tab shows/hides it.',
2107
+ menu: { section: 'menuorder', title: 'Home › Menu', hint: 'Watching comes first and Settings last: ⇈ ▲ ▼ ⇊ put the rest in your order · OK on a tab shows/hides it.',
2067
2108
  list: function () {
2068
2109
  return Promise.resolve(V.menuOrder().map(function (k) {
2069
2110
  var t = (V.HOME_TABS || []).filter(function (x) { return x.key === k; })[0];
@@ -2080,11 +2121,11 @@
2080
2121
  markHomeDirty();
2081
2122
  },
2082
2123
  hidden: menuHidden },
2083
- home: { section: 'feeds', title: 'Appearance › Home feeds', hint: '▲/▼ reorder a feed · OK on the name shows/hides it on Home.',
2124
+ home: { section: 'feeds', title: 'Home › Home feeds', hint: '▲/▼ reorder a feed · OK on the name shows/hides it on Home.',
2084
2125
  list: function () { return Stremio.listCatalogsOrdered(); }, keyOf: function (c) { return Stremio.catalogKey(c); },
2085
2126
  move: function (k, d) { return Stremio.moveFeed(k, d); }, toggle: function (k) { Stremio.toggleFeed(k); },
2086
2127
  hidden: function (k) { return Stremio.isFeedHidden(k); } },
2087
- search: { section: 'searchfeeds', title: 'Appearance › Search results', hint: '▲/▼ reorder the Search rows · OK on the name shows/hides one in Search.',
2128
+ search: { section: 'searchfeeds', title: 'Home › Search results', hint: '▲/▼ reorder the Search rows · OK on the name shows/hides one in Search.',
2088
2129
  list: function () { return Stremio.searchSourcesOrdered(); }, keyOf: function (src) { return src.key; },
2089
2130
  move: function (k, d) { return Stremio.moveSearchFeed(k, d); }, toggle: function (k) { Stremio.toggleSearchFeed(k); },
2090
2131
  hidden: function (k) { return Stremio.isSearchFeedHidden(k); } },
package/js/ytplay.js CHANGED
@@ -50,6 +50,17 @@ var YTPlay = (function () {
50
50
  var t = (typeof LocalMedia !== 'undefined' && LocalMedia.serviceToken) ? LocalMedia.serviceToken() : Promise.resolve('');
51
51
  return t.then(function (tk) { return tk ? { q: '&token=' + encodeURIComponent(tk), h: null } : HEADER; }, function () { return HEADER; });
52
52
  }
53
+ // An export (a configuration file) given to the phone: a one-time page to copy or download it
54
+ // -> { url, token } (polled like an entry: { seen }; closed with entryClose). POSTed: the token,
55
+ // or the guide ticket (the page's POST carries an Origin the header alone doesn't pass).
56
+ function entryGive(text) {
57
+ if (MODE === 'browser') { return Promise.reject(new Error('no service')); }
58
+ return ensureService().then(entryAuth).then(function (a) {
59
+ return (a.q ? Promise.resolve(a.q) : ticketOf(a)).then(function (cred) {
60
+ return U.postJSON(PROXY + '/entry/give' + (cred ? '?' + cred.replace(/^&/, '') : ''), text, 10000, 65536, a.h);
61
+ });
62
+ });
63
+ }
53
64
  function entryOpen(what) {
54
65
  return entryAuth().then(function (a) { return U.getJSON(PROXY + '/entry/open?what=' + encodeURIComponent(what || 'link') + a.q, 8000, undefined, null, a.h); });
55
66
  }
@@ -57,6 +68,10 @@ var YTPlay = (function () {
57
68
  return entryAuth().then(function (a) { return U.getJSON(PROXY + '/entry/poll?t=' + encodeURIComponent(token) + a.q, 5000, undefined, null, a.h); })
58
69
  .then(function (r) { return (r && typeof r.text === 'string') ? r.text : null; });
59
70
  }
71
+ function entrySeen(token) { // (an export's page: kept open by asking, and whether the phone has opened it)
72
+ return entryAuth().then(function (a) { return U.getJSON(PROXY + '/entry/poll?t=' + encodeURIComponent(token) + a.q, 5000, undefined, null, a.h); })
73
+ .then(function (r) { return !!(r && r.seen); });
74
+ }
60
75
  function entryClose(token) {
61
76
  return entryAuth().then(function (a) { return U.getText(PROXY + '/entry/close?t=' + encodeURIComponent(token) + a.q, 4000, 4096, null, true, a.h); }).then(null, function () {});
62
77
  }
@@ -71,7 +86,7 @@ var YTPlay = (function () {
71
86
  if (MODE === 'browser') { return Promise.reject(new Error('no service')); }
72
87
  var cc = opts && opts.cc ? opts.cc.map(function (c) { return c.ch + (c.lang ? '-' + c.lang : ''); }).join(',') : '';
73
88
  return ensureService().then(entryAuth).then(function (a) {
74
- var q = '/live/open?u=' + encodeURIComponent(url) + (h && h.ua ? '&ua=' + encodeURIComponent(h.ua) : '') + (h && h.ref ? '&ref=' + encodeURIComponent(h.ref) : '') + (force ? '&force=1' : '') +
89
+ var q = '/live/open?u=' + encodeURIComponent(url) + (h && h.ua ? '&ua=' + encodeURIComponent(h.ua) : '') + (h && h.ref ? '&ref=' + encodeURIComponent(h.ref) : '') + (h && h.cookie ? '&cookie=' + encodeURIComponent(h.cookie) : '') + (force ? '&force=1' : '') +
75
90
  (force && opts && opts.fix === false ? '&fix=0' : '') + (force && cc ? '&cc=' + encodeURIComponent(cc) : '');
76
91
  return U.getJSON(PROXY + q + a.q, force ? 5000 : 30000, 65536, cancel || null, a.h);
77
92
  });
@@ -81,7 +96,7 @@ var YTPlay = (function () {
81
96
  function hlsMaster(url, h) {
82
97
  if (MODE === 'browser') { return Promise.reject(new Error('no service')); }
83
98
  return ensureService().then(entryAuth).then(function (a) {
84
- var q = '/live/master?u=' + encodeURIComponent(url) + (h && h.ua ? '&ua=' + encodeURIComponent(h.ua) : '') + (h && h.ref ? '&ref=' + encodeURIComponent(h.ref) : '');
99
+ var q = '/live/master?u=' + encodeURIComponent(url) + (h && h.ua ? '&ua=' + encodeURIComponent(h.ua) : '') + (h && h.ref ? '&ref=' + encodeURIComponent(h.ref) : '') + (h && h.cookie ? '&cookie=' + encodeURIComponent(h.cookie) : '');
85
100
  return U.getText(PROXY + q + a.q, 12000, 524288, null, false, a.h);
86
101
  });
87
102
  }
@@ -112,6 +127,18 @@ var YTPlay = (function () {
112
127
  }
113
128
  function stalkerGenres(portal, mac) { return stalkerAsk('/stalker/genres', portal, mac, '', 40000, 1048576); }
114
129
  function stalkerLink(portal, mac, u, cancel) { return stalkerAsk('/stalker/link', portal, mac, '&u=' + encodeURIComponent(u), 25000, 65536, cancel); }
130
+ // Its films and series (see js/stvod.js): more, the request (&type=&do=cats|list|seasons…) ->
131
+ // { cats } | { items, more } | { seasons }, or { why }.
132
+ function stalkerVod(portal, mac, more) { return stalkerAsk('/stalker/vod', portal, mac, more, 45000, 4 * 1048576); }
133
+ // A film's or episode's source: the service's link that asks the portal for one when it's
134
+ // played (cmd, and ep: an episode of a season's cmd), with the token, or the guide ticket (the
135
+ // player sends no header; a ticket is the service's until it starts again).
136
+ function stalkerPlayUrl(portal, mac, cmd, ep) {
137
+ if (MODE === 'browser') { return Promise.reject(new Error('no service')); }
138
+ return ensureService().then(entryAuth).then(function (a) { return a.q ? a.q : ticketOf(a); }).then(function (cred) {
139
+ return PROXY + '/stalker/play?portal=' + encodeURIComponent(portal) + '&mac=' + encodeURIComponent(mac) + '&cmd=' + encodeURIComponent(cmd) + (ep >= 0 ? '&ep=' + ep : '') + (cred || '');
140
+ });
141
+ }
115
142
  // An Xtream account's films or series, kept by the service (see service/index.js, xtvControl;
116
143
  // user= and pass=: names Diagnostics masks):
117
144
  // path 'list' (the newest; more: &q= for a search, &skip=) or 'find' (a title's copies: &tmdb=
@@ -135,6 +162,9 @@ var YTPlay = (function () {
135
162
  var _ticket = null;
136
163
  function epgTicket(a) {
137
164
  if (a.q || MODE === 'tizenbrew') { return Promise.resolve(a.q); } // (the token; TizenBrew's origin passes as it is)
165
+ return ticketOf(a);
166
+ }
167
+ function ticketOf(a) {
138
168
  if (!_ticket) {
139
169
  _ticket = U.getJSON(PROXY + '/epg/ticket', 8000, 4096, null, a.h).then(function (r) {
140
170
  return r && /^[0-9a-f]{48}$/.test(r.ticket || '') ? '&ticket=' + r.ticket : '';
@@ -155,6 +185,18 @@ var YTPlay = (function () {
155
185
  });
156
186
  });
157
187
  }
188
+ // A Widevine channel's license request (challenge: base64), posted by the service to its
189
+ // license server with the playlist's headers (see service/index.js, drmControl) -> { license:
190
+ // base64 } or { why }. b64: the server answers in base64 already.
191
+ function drmLicense(server, headers, challenge, b64) {
192
+ if (MODE === 'browser') { return Promise.reject(new Error('no service')); }
193
+ return ensureService().then(entryAuth).then(function (a) {
194
+ return (a.q ? Promise.resolve(a.q) : ticketOf(a)).then(function (cred) {
195
+ var body = JSON.stringify({ u: server, h: headers || {}, c: challenge, b64: !!b64 });
196
+ return U.postJSON(PROXY + '/drm/license' + (cred ? '?' + cred.replace(/^&/, '') : ''), body, 20000, 2 * 1048576, a.h);
197
+ });
198
+ });
199
+ }
158
200
  // Settings › Storage: the saved guides ({ count, bytes }), and deleting them all.
159
201
  function epgFiles() {
160
202
  if (MODE === 'browser') { return Promise.resolve(null); }
@@ -257,6 +299,6 @@ var YTPlay = (function () {
257
299
  return MODE === 'tizenbrew' ? 'TizenBrew module' : MODE === 'wgt' ? 'Sideloaded app (.wgt)' : 'Browser (development)';
258
300
  }
259
301
 
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; },
302
+ return { ensureService: ensureService, resolverUrl: resolverUrl, infoUrl: infoUrl, canPlay: canPlay, liveOpen: liveOpen, hlsMaster: hlsMaster, aiomAddons: aiomAddons, stalkerList: stalkerList, stalkerVod: stalkerVod, drmLicense: drmLicense, stalkerPlayUrl: stalkerPlayUrl, stalkerGenres: stalkerGenres, stalkerLink: stalkerLink, xtvodAsk: xtvodAsk, epgLoad: epgLoad, epgGet: epgGet, epgFiles: epgFiles, epgClear: epgClear, entryOpen: entryOpen, entryGive: entryGive, entrySeen: entrySeen, entryPoll: entryPoll, entryClose: entryClose, subsUrl: subsUrl, audioLang: audioLang, setAudioLang: setAudioLang, installMode: function () { return MODE; },
261
303
  installLabel: installLabel, unavailableMessage: unavailableMessage, isRunning: isRunning, port: PORT };
262
304
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stremiok",
3
- "version": "2.2.6",
3
+ "version": "2.2.8",
4
4
  "description": "StremioK streaming client for Tizen 3.0+ Samsung TVs (TizenBrew app module).",
5
5
  "packageType": "app",
6
6
  "appName": "StremioK",