stremiok 2.4.2 → 2.4.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/js/lang/tr.js CHANGED
@@ -73,6 +73,7 @@ I18N.add("tr", {
73
73
  "A name, please": "Lütfen bir ad girin",
74
74
  "A new profile": "Yeni bir profil",
75
75
  "A new profile: “{name}”": "Yeni bir profil: “{name}”",
76
+ "A picture for “{name}”": "“{name}” için bir resim",
76
77
  "A source that doesn’t start takes you back to the list": "Başlamayan bir kaynak sizi listeye geri götürür",
77
78
  "A source the TV refuses, or that hasn’t started after 45 s, gives way to the next best one (up to 3 more)": "TV’nin reddettiği veya 45 sn sonra başlamayan kaynak, sıradaki en iyi kaynağa yerini bırakır (en fazla 3 tane daha)",
78
79
  "A source with one of them in its name, description or file name (a whole word: “CAM” isn’t in “CAMERA”) goes to the bottom, for every title · OK to change": "Adında, açıklamasında veya dosya adında bunlardan biri geçen kaynak (tam sözcük olarak: “CAMERA” içinde “CAM” yok) her içerikte en alta gider · değiştirmek için OK",
@@ -159,6 +160,7 @@ I18N.add("tr", {
159
160
  "An addon on the internet may send links into your home network (router, NAS, cameras…)": "İnternetteki bir eklenti ev ağınıza (modem, NAS, kameralar…) bağlantı gönderebilir",
160
161
  "An address like http://192.168.0.50:8096": "http://192.168.0.50:8096 gibi bir adres",
161
162
  "An episode of a series": "Bir dizinin bölümü",
163
+ "An image’s link": "Bir resmin bağlantısı",
162
164
  "Animation": "Animasyon",
163
165
  "Anime": "Anime",
164
166
  "Another address… (your own: type it, or ▣ from your phone)": "Başka bir adres… (kendinizinkini yazın veya telefonunuzdan ▣)",
@@ -354,6 +356,7 @@ I18N.add("tr", {
354
356
  "Couldn’t start Quick Connect ({why}).": "Quick Connect başlatılamadı ({why}).",
355
357
  "Couldn’t start the download: {why}": "İndirme başlatılamadı: {why}",
356
358
  "Couldn’t tidy it up (Diagnostics › Logs says why)": "Düzenlenemedi (nedeni Tanılama › Günlükler’de)",
359
+ "Couldn’t use that picture": "Bu resim kullanılamadı",
357
360
  "Cousine (closed-caption style)": "Cousine (altyazı tarzı)",
358
361
  "Creator": "Yaratıcı",
359
362
  "Crime": "Suç",
@@ -432,6 +435,7 @@ I18N.add("tr", {
432
435
  "Emby {v} is too old: 4.7 or newer is needed.": "Emby {v} çok eski: 4.7 veya daha yenisi gerekir.",
433
436
  "Emerald": "Zümrüt",
434
437
  "Endcards / credits": "Bitiş kartları / jenerik",
438
+ "Ends {time}": "{time} bitiyor",
435
439
  "English": "İngilizce",
436
440
  "Enter a Stremio addon manifest URL on its own page": "Kendi sayfasında bir Stremio eklenti manifest URL’si girin",
437
441
  "Enter a URL": "Bir URL girin",
@@ -512,12 +516,14 @@ I18N.add("tr", {
512
516
  "From the account connected in Integrations: tick the addons to add": "Entegrasyonlar’da bağlı hesaptan: eklenecek eklentileri işaretleyin",
513
517
  "From your network folder": "Ağ klasörünüzden",
514
518
  "From your phone: check it, then Confirm": "Telefonunuzdan: denetleyin, ardından Onayla",
519
+ "From your phone: one of its photos, or an image’s link. Typed here: an image’s link.": "Telefonunuzdan: fotoğraflarından biri ya da bir resmin bağlantısı. Buraya yazarak: bir resmin bağlantısı.",
515
520
  "Full": "Tam",
516
521
  "Galician": "Galiçyaca",
517
522
  "Genre": "Tür",
518
523
  "Georgian": "Gürcüce",
519
524
  "German": "Almanca",
520
525
  "Germany": "Almanya",
526
+ "Getting the picture…": "Resim alınıyor…",
521
527
  "Gives back the space of old versions of what StremioK saved, which the TV’s database keeps (StremioK’s data stays). Done on its own when they take over half of what the TV allows": "TV veritabanının sakladığı, StremioK kayıtlarının eski sürümlerinin alanını geri kazanır (StremioK verileri kalır). TV’nin izin verdiğinin yarısını aştıklarında kendiliğinden yapılır",
522
528
  "Gives: {what}": "Sağladıkları: {what}",
523
529
  "Good": "İyi",
@@ -899,6 +905,7 @@ I18N.add("tr", {
899
905
  "Not a link": "Bağlantı değil",
900
906
  "Not a movie or episode": "Film veya bölüm değil",
901
907
  "Not a movie or episode (a plain file)": "Film veya bölüm değil (düz dosya)",
908
+ "Not a picture, nor an image’s link": "Ne resim ne de resim bağlantısı",
902
909
  "Not allowed": "İzin verilmedi",
903
910
  "Not available here": "Burada kullanılamıyor",
904
911
  "Not available here.": "Burada kullanılamıyor.",
@@ -1049,8 +1056,10 @@ I18N.add("tr", {
1049
1056
  "Peru": "Peru",
1050
1057
  "Philippines": "Filipinler",
1051
1058
  "Pick the line being said": "Söylenen satırı seçin",
1052
- "Picture": "Görüntü",
1059
+ "Picture": "Resim",
1053
1060
  "Picture (this channel)": "Görüntü (bu kanal)",
1061
+ "Picture removed": "Resim kaldırıldı",
1062
+ "Picture set": "Resim ayarlandı",
1054
1063
  "Pictures": "Görseller",
1055
1064
  "Pictures and synopses": "Görseller ve özetler",
1056
1065
  "Pink": "Pembe",
@@ -1172,6 +1181,7 @@ I18N.add("tr", {
1172
1181
  "Remove from Stremio Library": "Stremio Kitaplığından kaldır",
1173
1182
  "Remove from the list": "Listeden kaldır",
1174
1183
  "Remove from the list (the file stays)": "Listeden kaldır (dosya kalır)",
1184
+ "Remove picture": "Resmi kaldır",
1175
1185
  "Remove rating": "Puanı kaldır",
1176
1186
  "Remove the YouTube catalog “{name}”?": "“{name}” YouTube kataloğu kaldırılsın mı?",
1177
1187
  "Remove the YouTubio addon? Its catalogs are in your YouTube now.": "YouTubio eklentisi kaldırılsın mı? Katalogları artık YouTube’unuzda.",
package/js/lang/zh-CN.js CHANGED
@@ -73,6 +73,7 @@ I18N.add("zh-CN", {
73
73
  "A name, please": "请输入名称",
74
74
  "A new profile": "新个人资料",
75
75
  "A new profile: “{name}”": "新个人资料:“{name}”",
76
+ "A picture for “{name}”": "“{name}”的头像",
76
77
  "A source that doesn’t start takes you back to the list": "片源无法播放时返回列表",
77
78
  "A source the TV refuses, or that hasn’t started after 45 s, gives way to the next best one (up to 3 more)": "电视拒绝播放或 45 秒后仍未开始的片源,将自动换成下一个最佳片源(最多再试 3 个)",
78
79
  "A source with one of them in its name, description or file name (a whole word: “CAM” isn’t in “CAMERA”) goes to the bottom, for every title · OK to change": "名称、描述或文件名中含有其中任一词(需为完整单词:“CAMERA”不算含有“CAM”)的片源,在所有影片中都排到最后 · 按 OK 更改",
@@ -159,6 +160,7 @@ I18N.add("zh-CN", {
159
160
  "An addon on the internet may send links into your home network (router, NAS, cameras…)": "互联网上的插件可能会发送指向你家庭网络的链接(路由器、NAS、摄像头…)",
160
161
  "An address like http://192.168.0.50:8096": "地址,例如 http://192.168.0.50:8096",
161
162
  "An episode of a series": "剧集中的一集",
163
+ "An image’s link": "图片链接",
162
164
  "Animation": "动画",
163
165
  "Anime": "日本动漫",
164
166
  "Another address… (your own: type it, or ▣ from your phone)": "其他地址… (自定义:输入,或用手机 ▣)",
@@ -354,6 +356,7 @@ I18N.add("zh-CN", {
354
356
  "Couldn’t start Quick Connect ({why}).": "无法启动快速连接({why})。",
355
357
  "Couldn’t start the download: {why}": "无法开始下载:{why}",
356
358
  "Couldn’t tidy it up (Diagnostics › Logs says why)": "无法整理(原因见 诊断 › 日志)",
359
+ "Couldn’t use that picture": "无法使用这张图片",
357
360
  "Cousine (closed-caption style)": "Cousine(隐藏式字幕风格)",
358
361
  "Creator": "创作者",
359
362
  "Crime": "犯罪",
@@ -432,6 +435,7 @@ I18N.add("zh-CN", {
432
435
  "Emby {v} is too old: 4.7 or newer is needed.": "Emby {v} 版本过旧:需要 4.7 或更高版本。",
433
436
  "Emerald": "翠绿色",
434
437
  "Endcards / credits": "片尾卡片 / 片尾字幕",
438
+ "Ends {time}": "{time} 结束",
435
439
  "English": "英语",
436
440
  "Enter a Stremio addon manifest URL on its own page": "在单独的页面中输入 Stremio 插件清单 URL",
437
441
  "Enter a URL": "输入 URL",
@@ -512,12 +516,14 @@ I18N.add("zh-CN", {
512
516
  "From the account connected in Integrations: tick the addons to add": "来自集成中连接的账号:勾选要添加的插件",
513
517
  "From your network folder": "来自你的网络文件夹",
514
518
  "From your phone: check it, then Confirm": "来自你的手机:检查后确认",
519
+ "From your phone: one of its photos, or an image’s link. Typed here: an image’s link.": "从手机:手机里的一张照片,或一个图片链接。在这里输入:一个图片链接。",
515
520
  "Full": "完整",
516
521
  "Galician": "加利西亚语",
517
522
  "Genre": "类型",
518
523
  "Georgian": "格鲁吉亚语",
519
524
  "German": "德语",
520
525
  "Germany": "德国",
526
+ "Getting the picture…": "正在获取图片…",
521
527
  "Gives back the space of old versions of what StremioK saved, which the TV’s database keeps (StremioK’s data stays). Done on its own when they take over half of what the TV allows": "释放电视数据库中保留的 StremioK 旧版本数据所占空间(StremioK 的数据不受影响)。当其占用超过电视允许空间的一半时会自动执行",
522
528
  "Gives: {what}": "提供:{what}",
523
529
  "Good": "良好",
@@ -899,6 +905,7 @@ I18N.add("zh-CN", {
899
905
  "Not a link": "不是链接",
900
906
  "Not a movie or episode": "不是电影或剧集",
901
907
  "Not a movie or episode (a plain file)": "不是电影或剧集(普通文件)",
908
+ "Not a picture, nor an image’s link": "既不是图片也不是图片链接",
902
909
  "Not allowed": "不允许",
903
910
  "Not available here": "此处不可用",
904
911
  "Not available here.": "此处不可用。",
@@ -1049,8 +1056,10 @@ I18N.add("zh-CN", {
1049
1056
  "Peru": "秘鲁",
1050
1057
  "Philippines": "菲律宾",
1051
1058
  "Pick the line being said": "选择正在说的台词",
1052
- "Picture": "画面",
1059
+ "Picture": "头像",
1053
1060
  "Picture (this channel)": "画面(此频道)",
1061
+ "Picture removed": "已移除头像",
1062
+ "Picture set": "已设置头像",
1054
1063
  "Pictures": "图片",
1055
1064
  "Pictures and synopses": "图片和简介",
1056
1065
  "Pink": "粉色",
@@ -1172,6 +1181,7 @@ I18N.add("zh-CN", {
1172
1181
  "Remove from Stremio Library": "从 Stremio 片库中移除",
1173
1182
  "Remove from the list": "从列表中移除",
1174
1183
  "Remove from the list (the file stays)": "从列表中移除(保留文件)",
1184
+ "Remove picture": "移除头像",
1175
1185
  "Remove rating": "移除评分",
1176
1186
  "Remove the YouTube catalog “{name}”?": "移除 YouTube 目录“{name}”?",
1177
1187
  "Remove the YouTubio addon? Its catalogs are in your YouTube now.": "移除 YouTubio 插件?其目录现已在你的 YouTube 中。",
@@ -225,6 +225,7 @@
225
225
  U.log('player', 'Audio switch to track ' + index + (force ? ' (again)' : '') + '. The TV lists: ' + rawAudio() + '. Playing: ' + playingRaw());
226
226
  if (!setAudioTrack(index)) { hold(index, message, false, 'refused'); return; }
227
227
  _held = null;
228
+ if (P.subsAfterAudio) { P.subsAfterAudio(); } // (the 2017 TV drops back to its first text track on an audio switch)
228
229
  setTimeout(function () { // (what the TV says it plays once it's had time: a switch it took without following shows here)
229
230
  if (S.active && _audioIdx === index && Date.now() - asked < 10000) { U.log('player', 'Audio switch to track ' + index + ': the TV now plays ' + playingRaw()); }
230
231
  }, SWITCH_CHECK_MS);
@@ -910,9 +910,11 @@
910
910
  if (mi.duration > 0) { parts.push(U.fmtTime(mi.duration)); }
911
911
  lines.push([U.t('In the file'), parts.filter(Boolean).join(' · ')]);
912
912
  if (v && v.dv) { lines.push([U.t('Dolby Vision'), dvNote(v.dv)]); }
913
- if (mi.audio && mi.audio.length) { lines.push([U.t('Audio tracks'), trackList(mi.audio)]); }
913
+ var auds = mi.audio || [], ao = S.ctx && S.ctx._relay && S.ctx._blank && S.ctx._audioOrder;
914
+ if (ao && ao.length) { auds = ao.map(function (i) { return auds[i]; }).filter(Boolean).concat(auds.filter(function (t, i) { return ao.indexOf(i) === -1; })); } // (as the service put them: yours first)
915
+ if (auds.length) { lines.push([U.t('Audio tracks'), trackList(auds)]); }
914
916
  var subs = mi.subs || [], bl = S.ctx && S.ctx._relay && S.ctx._blank;
915
- if (bl) { subs = subs.filter(function (t, i) { return bl.indexOf(i) !== -1; }); } // (the others left out: "Plays" says how many)
917
+ if (bl) { subs = bl.map(function (i) { return subs[i]; }).filter(Boolean); } // (the others left out: "Plays" says how many; in the order the service put them in)
916
918
  if (subs.length) { lines.push([U.t('Subtitle tracks'), trackList(subs)]); }
917
919
  }
918
920
  // How it reaches the player (no link): straight from its server, or through StremioK's service.
package/js/player-core.js CHANGED
@@ -325,7 +325,12 @@ var PlayerParts = {};
325
325
  function renderOSD() {
326
326
  U.byId('osd-title').textContent = S.ctx ? S.ctx.name : '';
327
327
  var ck = U.byId('osd-clock'); // (the time of day, top right while the bar is on screen)
328
- if (ck) { ck.textContent = clock(Date.now() / 1000); }
328
+ if (ck) {
329
+ ck.textContent = clock(Date.now() / 1000);
330
+ // (under it, when what plays has a length: when it ends, at this pace — later while paused)
331
+ var left = !S.isLive && S.dur > 0 ? S.dur - S.cur : 0;
332
+ if (left > 30) { ck.appendChild(U.el('div', 'osd-ends', U.t('Ends {time}', { time: clock(Date.now() / 1000 + left) }))); }
333
+ }
329
334
  renderTags();
330
335
  renderChapters();
331
336
  if (S.isLive) {
@@ -461,11 +466,13 @@ var PlayerParts = {};
461
466
  var known = _miSeen.get(job.key);
462
467
  if (known) { fileInfoIn(ctx, known); return; }
463
468
  var look = _miLook = U.cancelToken();
469
+ // (meanwhile a built-in subtitle pick waits for it when the TV states no language: P.miPending)
470
+ function over() { if (_miLook === look) { _miLook = null; } if (P.subsMiIn && S.ctx === ctx && S.active) { P.subsMiIn(); } }
464
471
  job.ask(look).then(function (mi) {
465
- if (look.cancelled || !mi || typeof mi !== 'object' || !mi.container) { return; }
466
- _miSeen.set(job.key, mi);
467
- if (S.ctx === ctx && S.active) { fileInfoIn(ctx, mi); }
468
- }, function (e) { if (!look.cancelled) { U.log('player', 'The file\'s details couldn\'t be read: ' + ((e && e.message) || 'unknown')); } });
472
+ if (look.cancelled) { return; }
473
+ if (mi && typeof mi === 'object' && mi.container) { _miSeen.set(job.key, mi); if (S.ctx === ctx && S.active) { S.mi = mi; fileInfoIn(ctx, mi); } }
474
+ over();
475
+ }, function (e) { if (!look.cancelled) { U.log('player', 'The file\'s details couldn\'t be read: ' + ((e && e.message) || 'unknown')); over(); } });
469
476
  }
470
477
  // The answer in: S.mi, and the source's details corrected by it (Stremio.withFileInfo): what
471
478
  // the player shows (its tags, Stream info) and what Formats learns from it are the file's.
@@ -482,6 +489,7 @@ var PlayerParts = {};
482
489
  var what = P.fileSummary(S.mi);
483
490
  return what ? U.t('This TV didn’t play this file: {what}', { what: what }) : why;
484
491
  }
492
+ P.miPending = function () { return !!_miLook && !_miLook.cancelled && !S.mi; };
485
493
  P.fileInfoFor = function (ctx) { var j = fileInfoAsk(ctx); return j ? _miSeen.get(j.key) || null : null; };
486
494
 
487
495
  function play(ctx, onExit) {
@@ -1313,8 +1321,15 @@ var PlayerParts = {};
1313
1321
  function blankKeep(ctx, mi) {
1314
1322
  var cfg = P.getSubCfg(), mine = P.recallSub ? P.recallSub(ctx.id) : null;
1315
1323
  var keys = [mine && mine.lang, cfg.lang, cfg.lang2].filter(function (l) { return l && l !== 'off' && l !== 'none'; }).map(P.langKey);
1316
- var keep = [];
1317
- (mi.subs || []).forEach(function (t, i) { if (keep.length < BLANK_KEEP && keys.some(function (k) { return P.langMatches(k, t.lang || ''); })) { keep.push(i); } });
1324
+ // (in the order wanted: the service puts them first in that order, so the TV's first text
1325
+ // track is yours. A language's: plain, then SDH, then forced, then pictures)
1326
+ var keep = [], subs = mi.subs || [];
1327
+ var rank = function (t) { return t.text === false ? 3 : t.forced ? 2 : t.hi ? 1 : 0; };
1328
+ keys.forEach(function (k) {
1329
+ subs.map(function (t, i) { return i; }).filter(function (i) { return keep.indexOf(i) === -1 && P.langMatches(k, subs[i].lang || ''); })
1330
+ .sort(function (a, b) { return rank(subs[a]) - rank(subs[b]) || a - b; })
1331
+ .forEach(function (i) { if (keep.length < BLANK_KEEP) { keep.push(i); } });
1332
+ });
1318
1333
  return keep;
1319
1334
  }
1320
1335
  function blankFits(ctx, mi) {
@@ -1326,7 +1341,18 @@ var PlayerParts = {};
1326
1341
  if (blankKeep(ctx, mi).length >= mi.subs.length) { return false; } // (every one kept: nothing to leave out)
1327
1342
  return typeof YTPlay !== 'undefined' && !!YTPlay.fileOpen && YTPlay.installMode() !== 'browser';
1328
1343
  }
1329
- function setBlank(ctx, mi) { ctx._blank = blankKeep(ctx, mi); ctx._blankOf = mi.subs.length; }
1344
+ // The audio tracks in the order wanted (a choice made for the title, your language, your second
1345
+ // choice; commentaries last): the service puts them so, the first is the one the TV starts on.
1346
+ function audioOrder(ctx, mi) {
1347
+ var cfg = P.getAudioCfg ? P.getAudioCfg() : {}, mine = P.recallAudio ? P.recallAudio(ctx.id) : null, aud = mi.audio || [];
1348
+ var keys = [mine && mine.lang, cfg.lang, cfg.lang2].filter(function (l) { return l && l !== 'default' && l !== 'none'; }).map(P.langKey);
1349
+ var out = [];
1350
+ keys.forEach(function (k) {
1351
+ aud.forEach(function (t, i) { if (out.indexOf(i) === -1 && !t.commentary && P.langMatches(k, t.lang || '')) { out.push(i); } });
1352
+ });
1353
+ return out;
1354
+ }
1355
+ function setBlank(ctx, mi) { ctx._blank = blankKeep(ctx, mi); ctx._blankOf = mi.subs.length; ctx._audioOrder = audioOrder(ctx, mi); }
1330
1356
  // Always / More than 5: an MKV's tracks read before it starts (when not known yet); then(): on.
1331
1357
  function blankBefore(ctx, then) {
1332
1358
  var mode = P.playerCfg().blank;
@@ -1660,7 +1686,7 @@ var PlayerParts = {};
1660
1686
  if (S.ctx !== ctx || !S.active) { return; }
1661
1687
  if (useAV) { startLive(ctx, settle); } else { startHTML5(ctx._relay && ctx._relayFor === ctx.url ? ctx._relay : ctx.url); }
1662
1688
  }
1663
- YTPlay.fileOpen(ctx.url, U.sanitizeHeaders(ctx._headers), lan, ctx._blank || null).then(function (r) {
1689
+ YTPlay.fileOpen(ctx.url, U.sanitizeHeaders(ctx._headers), lan, ctx._blank || null, ctx._blank ? ctx._audioOrder : null).then(function (r) {
1664
1690
  if (S.ctx === ctx && S.active && relayed(ctx, r, null, false)) {
1665
1691
  U.log('player', ctx._blank ? 'Through StremioK\'s service: ' + ctx._blankOf + ' subtitle tracks, ' + ctx._blank.length + ' kept, the others left out (jumps stay clean; ' + where(ctx.url) + ')' : 'Through StremioK\'s service, with the source\'s headers (' + where(ctx.url) + ')');
1666
1692
  }
package/js/player-lang.js CHANGED
@@ -34,7 +34,7 @@
34
34
  fre: ['fre', 'fra', 'fr', 'french', 'français', 'francais'],
35
35
  ger: ['ger', 'deu', 'de', 'german', 'deutsch'],
36
36
  ita: ['ita', 'it', 'italian', 'italiano'],
37
- por: ['por', 'pob', 'pom', 'pt', 'portuguese', 'português', 'portugues'],
37
+ por: ['por', 'pob', 'pom', 'pt', 'po', 'portuguese', 'português', 'portugues'], // ("po": the 2017 TV's)
38
38
  dut: ['dut', 'nld', 'nl', 'dutch', 'nederlands'],
39
39
  rus: ['rus', 'ru', 'russian'],
40
40
  ara: ['ara', 'ar', 'arabic'],
@@ -221,7 +221,9 @@
221
221
  var list = P.S.mi && P.S.mi[kind];
222
222
  if (!list || !tracks || !list.length || !tracks.length) { return null; }
223
223
  var bl = kind === 'subs' && P.S.ctx && P.S.ctx._relay && P.S.ctx._blank; // (the others blanked by the service: the kept ones, in order)
224
- if (bl) { list = list.filter(function (t, i) { return bl.indexOf(i) !== -1; }); }
224
+ if (bl) { list = bl.map(function (i) { return list[i]; }).filter(Boolean); } // (in the order the service put them in)
225
+ var ao = kind === 'audio' && P.S.ctx && P.S.ctx._relay && P.S.ctx._blank && P.S.ctx._audioOrder; // (the audio reordered by the service too: yours first)
226
+ if (ao && ao.length) { var all = list; list = ao.map(function (i) { return all[i]; }).filter(Boolean).concat(all.filter(function (t, i) { return ao.indexOf(i) === -1; })); }
225
227
  var got = byPosition(list, tracks);
226
228
  if (!got && list.length > tracks.length) {
227
229
  got = byPosition(list.filter(function (t) { return t.text !== false; }), tracks) || inOrder(list, tracks) || firstOnes(list, tracks);
package/js/player-subs.js CHANGED
@@ -90,8 +90,13 @@
90
90
  ? LocalMedia.ensure().then(function () { return LocalMedia.ready(); }).then(function () { return LocalMedia.subsForTitle(ctx.type, ctx.id); }).then(null, function () { return []; })
91
91
  : Promise.resolve([]);
92
92
  if (localSubs.length) { localReady.then(function () { early = pickSubs(localSubs, true); }); }
93
+ // (your default language built into the file: on as soon as it plays, not after the addons)
94
+ var cfg0 = getSubCfg();
95
+ if (!recallSub(ctx.id) && cfg0.lang && cfg0.lang !== 'off' && P.useAV) { wantEmbedded({ lang: cfg0.lang, early: true }); }
93
96
  Promise.all([fromAddons, fromYouTube, localReady, usbSubs]).then(function (r) {
94
- var all = localSubs.concat(ctx.sourceSubs || [], r[0] || [], r[1], r[3] || []); // (a source's own: made for its file, so first after a USB file's)
97
+ // (in the order they're picked in: a source's own, made for its file, then the addons' in
98
+ // their order, then a USB drive's, then YouTube's; built-in tracks before all: applyEmbeddedWant)
99
+ var all = (ctx.sourceSubs || []).concat(r[0] || [], localSubs, r[3] || [], r[1] || []);
95
100
  if (!S.active || S.ctx !== ctx) { return; } // (another playback started meanwhile: not its tracks)
96
101
  if (early || _subOn || _embSub != null) { _subTracks = all; updateHint(); startSecond(); return; }
97
102
  pickSubs(all, false);
@@ -128,16 +133,13 @@
128
133
  if (partial) { return false; }
129
134
  }
130
135
 
131
- // 2) Otherwise the default language: an addon track, else one built into the file;
132
- // then the second choice, the same way (see applyEmbeddedWant: once the file's own
133
- // tracks are known, so the default language built into it comes first).
136
+ // 2) Otherwise your default language: built into the file, else an addon's (in their
137
+ // order), a USB drive's, YouTube's; then the second choice, the same way. Decided in
138
+ // applyEmbeddedWant, once the file's own tracks are known (all the files in by then).
134
139
  var cfg = getSubCfg();
135
140
  if (!cfg.lang || cfg.lang === 'off') { return !partial; }
136
- // "spa" also matches "es", "es-419", "Spanish", "Español"...
137
- var match = _subTracks.find(function (t) { return langMatches(cfg.lang, t.lang); });
138
- if (match) { loadTrack(match); return true; }
139
141
  if (partial) { return false; }
140
- wantEmbedded({ lang: cfg.lang, lang2: (cfg.lang2 && cfg.lang2 !== 'none' && cfg.lang2 !== cfg.lang) ? cfg.lang2 : null });
142
+ wantEmbedded({ lang: cfg.lang, lang2: (cfg.lang2 && cfg.lang2 !== 'none' && cfg.lang2 !== cfg.lang) ? cfg.lang2 : null, auto: true });
141
143
  return true;
142
144
  }
143
145
  }
@@ -178,17 +180,39 @@
178
180
  // screen; picking it again by hand works). So it's picked once more when playback has run
179
181
  // a moment: through another text track first (or off and on, with only one), since picking
180
182
  // the track the TV already reports is ignored.
181
- var EMB_NUDGE_MS = 2500, _embNudge = null;
183
+ // The way back after a moment (EMB_NUDGE_GAP_MS: the 2017 TV ignores two switches in a row,
184
+ // as with audio; its lines meanwhile not shown), then a look at what the TV reports a few
185
+ // seconds on (EMB_CHECK_MS): not the track picked, picked once more.
186
+ var EMB_NUDGE_MS = 2500, EMB_NUDGE_GAP_MS = 1000, EMB_CHECK_MS = 4000, _embNudge = null, _embQuiet = 0;
187
+ function selectText(index) {
188
+ try { avplay.setSelectTrack('TEXT', index); }
189
+ catch (e) { try { avplay.setSelectTrack('TEXT', '' + index); } catch (e2) {} }
190
+ }
191
+ function textNow() { // the text track the TV reports playing, or null
192
+ try { var l = avplay.getCurrentStreamInfo() || []; for (var i = 0; i < l.length; i++) { if (('' + l[i].type).toUpperCase() === 'TEXT') { return '' + l[i].index; } } } catch (e) {}
193
+ return null;
194
+ }
182
195
  function nudgeEmbedded() {
183
196
  var n = _embNudge; _embNudge = null;
184
197
  if (!n || _subOn || _embSub !== n.index) { return; } // (another choice meanwhile)
185
198
  var other = getTextTracks().filter(function (t) { return t.index !== n.index; })[0];
186
- if (other) { try { avplay.setSelectTrack('TEXT', other.index); } catch (e1) {} }
199
+ _embQuiet = Date.now() + EMB_NUDGE_GAP_MS + 500;
200
+ if (other) { selectText(other.index); }
187
201
  else { try { avplay.setSilentSubtitle(true); } catch (e2) {} }
188
- try { avplay.setSilentSubtitle(false); } catch (e3) {}
189
- try { avplay.setSelectTrack('TEXT', n.index); }
190
- catch (e4) { try { avplay.setSelectTrack('TEXT', '' + n.index); } catch (e5) {} }
202
+ setTimeout(function () {
203
+ if (_subOn || _embSub !== n.index || !S.active) { return; }
204
+ try { avplay.setSilentSubtitle(false); } catch (e3) {}
205
+ selectText(n.index);
206
+ setTimeout(function () {
207
+ if (_subOn || _embSub !== n.index || !S.active) { return; }
208
+ var now = textNow();
209
+ if (now !== null && now !== '' + n.index) { U.log('player', 'Built-in subtitle: the TV played track ' + now + ', not ' + n.index + ': picked again'); selectText(n.index); }
210
+ }, EMB_CHECK_MS);
211
+ }, EMB_NUDGE_GAP_MS);
191
212
  }
213
+ // An audio switch: the 2017 TV goes back to its first text track meanwhile (the one picked
214
+ // still ticked; a pause and play brings it back): picked once more, the same way, a moment on.
215
+ P.subsAfterAudio = function () { if (_embSub != null && !_subOn) { _embNudge = { index: _embSub, at: Date.now() + EMB_NUDGE_MS }; } };
192
216
  // Stream info's "Subtitles" line.
193
217
  function subtitleSummary() {
194
218
  return _subOn ? (_subLabel + (_subDelay ? ' (' + fmtDelay(_subDelay) + ')' : '')) : (_embSub != null ? (_embLang || U.t('on')) + ' ' + U.t('(built-in)') : U.t('Off'));
@@ -684,7 +708,12 @@
684
708
  return own && own.lang ? own.lang : l;
685
709
  }
686
710
 
687
- function wantEmbedded(w) { _embWant = w; if (_ticked) { applyEmbeddedWant(); } }
711
+ // (applied once playback runs and the TV lists its tracks; at once when there can be none to
712
+ // wait for: no TV player, a YouTube video, a file whose details list no subtitle track)
713
+ function noBuiltIn() { return !P.useAV || !!(S.ctx && S.ctx.yt) || !!(S.mi && S.mi.container && !(S.mi.subs || []).length); }
714
+ function wantEmbedded(w) { _embWant = w; if (_ticked || noBuiltIn()) { applyEmbeddedWant(); } }
715
+ // The file's details in (or not to be had): a pick that waited for them, now.
716
+ P.subsMiIn = function () { if (_embWant && _ticked) { try { applyEmbeddedWant(); } catch (e) {} } };
688
717
  function applyEmbeddedWant() {
689
718
  var w = _embWant; _embWant = null;
690
719
  if (!w || _subOn) { return; } // an addon track was chosen meanwhile
@@ -703,12 +732,19 @@
703
732
  pick = tracks.find(function (t) { return t.index === w.index && (!key || langKey(textLang(t)) === key); }) || null;
704
733
  }
705
734
  if (!pick && key) { pick = best(function (t) { return langMatches(key, textLang(t)); }); }
735
+ // (no language from the TV, the file's details still being read: picked once they're in,
736
+ // subsMiIn, so your language built into the file isn't passed over)
737
+ if (!pick && P.miPending && P.miPending() && tracks.length && tracks.every(function (t) { return P.langUnstated(trackLang(t)); })) { _embWant = w; return; }
738
+ if (!pick && w.early) { return; } // (only a built-in one, early: the rest once the files are in)
739
+ // (your default language not built in: a subtitle file in it, in the list's order)
740
+ var file = !pick && key && w.auto ? _subTracks.find(function (t) { return langMatches(key, t.lang); }) : null;
741
+ if (file) { loadTrack(file); return; }
706
742
  if (!pick && w.nth != null && S.ctx && S.ctx._relayCc) { pick = tracks[w.nth] || null; } // (a live channel's closed captions: in the order asked for)
707
- if (!pick && w.lang2) { // nothing in the default language anywhere: the second choice, a track to download first
743
+ if (!pick && w.lang2) { // nothing in the default language anywhere: the second choice, the same way
708
744
  var key2 = langKey(w.lang2);
709
- var dl = _subTracks.find(function (t) { return langMatches(key2, t.lang); });
710
- if (dl) { loadTrack(dl); return; }
711
745
  pick = best(function (t) { return langMatches(key2, textLang(t)); });
746
+ var dl = pick ? null : _subTracks.find(function (t) { return langMatches(key2, t.lang); });
747
+ if (dl) { loadTrack(dl); return; }
712
748
  }
713
749
  if (pick) { selectEmbeddedSub(pick); _embNudge = { index: pick.index, at: Date.now() + EMB_NUDGE_MS }; }
714
750
  }
@@ -744,7 +780,7 @@
744
780
  };
745
781
  }
746
782
  function showEmbeddedText(text, duration) {
747
- if (_embSub == null || _subOn) { return; }
783
+ if (_embSub == null || _subOn || Date.now() < _embQuiet) { return; } // (the other track's, while nudging)
748
784
  text = skipper()('' + (text || ''));
749
785
  if (!text) { return; }
750
786
  if (_embDelay > 0) {
package/js/profiles.js CHANGED
@@ -78,7 +78,17 @@ var Profiles = (function () {
78
78
  if (m) { return m[1]; }
79
79
  return isTv(physical) ? null : '';
80
80
  }
81
- function list() { return _data ? _data.list.map(function (p) { return { id: p.id, name: p.name, color: p.color, slot: p.slot, at: p.at }; }) : []; }
81
+ function list() { return _data ? _data.list.map(function (p) { return { id: p.id, name: p.name, color: p.color, slot: p.slot, at: p.at, pic: picOf(p) }; }) : []; }
82
+ // A profile's picture (Settings › Profiles › Picture): a small JPEG as a data: link (made
83
+ // PIC_PX square by the app or the phone), PIC_MAX characters at most; '' none.
84
+ var PIC_MAX = 120000;
85
+ function picOf(p) { return p && typeof p.pic === 'string' && p.pic.length <= PIC_MAX && /^data:image\/jpeg;base64,[A-Za-z0-9+\/=]+$/.test(p.pic) ? p.pic : ''; }
86
+ function setPic(id, pic) {
87
+ var p = find(id);
88
+ if (!p) { return false; }
89
+ if (pic) { if (!picOf({ pic: pic })) { return false; } p.pic = pic; } else { delete p.pic; }
90
+ return save();
91
+ }
82
92
 
83
93
  // ---- changing the list (Settings › Profiles, the picker) ----
84
94
  function save() { try { window.localStorage.setItem(KEY, JSON.stringify(_data)); return true; } catch (e) { return false; } }
@@ -170,12 +180,12 @@ var Profiles = (function () {
170
180
  key: key, keyFor: keyFor, isTv: isTv, slotOf: slotOf,
171
181
  slot: function () { return _slot; },
172
182
  list: list,
173
- active: function () { var a = active(); return a ? { id: a.id, name: a.name, color: a.color, slot: a.slot } : null; },
183
+ active: function () { var a = active(); return a ? { id: a.id, name: a.name, color: a.color, slot: a.slot, pic: picOf(a) } : null; },
174
184
  count: function () { return _data ? _data.list.length : 1; },
175
185
  justSwitched: justSwitched,
176
186
  ask: function () { return !!(_data && _data.list.length > 1 && _data.ask !== false); },
177
187
  askSetting: function () { return !_data || _data.ask !== false; },
178
- ensure: function (firstName) { ensure(firstName); save(); }, add: add, rename: rename, recolor: recolor, setAsk: setAsk, startChoice: startChoice, setStart: setStart, setActive: setActive, remove: remove, copyInto: copyInto, keysOf: keysOf, COPY: COPY,
188
+ ensure: function (firstName) { ensure(firstName); save(); }, add: add, rename: rename, recolor: recolor, setPic: setPic, setAsk: setAsk, startChoice: startChoice, setStart: setStart, setActive: setActive, remove: remove, copyInto: copyInto, keysOf: keysOf, COPY: COPY,
179
189
  __data: function () { return _data; }, __reload: function () { _data = read(); _slot = (active() || { slot: '' }).slot; }
180
190
  };
181
191
  })();
package/js/view-core.js CHANGED
@@ -209,7 +209,12 @@ var ViewParts = {};
209
209
  // A profile's round badge: its color, the first character of its name.
210
210
  function profileBadge(p, cls) {
211
211
  var b = U.el('span', 'pf-badge' + (cls ? ' ' + cls : ''));
212
- b.style.background = PROFILE_COLORS[p.color] || PROFILE_COLORS.indigo;
212
+ b.style.backgroundColor = PROFILE_COLORS[p.color] || PROFILE_COLORS.indigo;
213
+ if (p.pic) { // (its picture: Settings › Profiles › Picture; filling the badge, its middle in view)
214
+ b.className += ' pf-pic';
215
+ b.style.backgroundImage = 'url("' + p.pic + '")'; b.style.backgroundSize = 'cover'; b.style.backgroundPosition = 'center center'; b.style.backgroundRepeat = 'no-repeat';
216
+ return b;
217
+ }
213
218
  var m = /^[\uD800-\uDBFF][\uDC00-\uDFFF]|^[\s\S]/.exec(('' + (p.name || '?')).trim() || '?');
214
219
  b.textContent = (m ? m[0] : '?').toUpperCase();
215
220
  return b;
@@ -489,6 +489,50 @@
489
489
  // this one (addons, settings, media server sign-ins; not its history or accounts) or empty.
490
490
  // Ask who's watching when StremioK opens (two or more).
491
491
  var PROFILE_COLOR_NAMES = { indigo: U.t('Indigo'), teal: U.t('Teal'), orange: U.t('Orange'), pink: U.t('Pink'), green: U.t('Green'), red: U.t('Red'), purple: U.t('Purple'), amber: U.t('Amber') };
492
+ // A profile's picture: from the phone (a photo it made small, or an image's link) or typed (a
493
+ // link); a link downloaded by the service (YTPlay.imageBytes). Made PROFILE_PIC_PX square here
494
+ // (centred, cut to fit) and kept as a small JPEG (Profiles.setPic), never the link.
495
+ var PROFILE_PIC_PX = 240;
496
+ function picSource(bytes) {
497
+ try { return URL.createObjectURL(new Blob([bytes])); } catch (e) {}
498
+ var s = ''; for (var i = 0; i < bytes.length; i++) { s += String.fromCharCode(bytes[i]); }
499
+ return 'data:image/jpeg;base64,' + btoa(s);
500
+ }
501
+ function shrinkPicture(src) {
502
+ return new Promise(function (resolve, reject) {
503
+ var img = new Image();
504
+ img.onload = function () {
505
+ try {
506
+ var w = img.naturalWidth, h = img.naturalHeight, side = Math.min(w, h), c = document.createElement('canvas');
507
+ if (!side) { reject(new Error('empty')); return; }
508
+ c.width = c.height = PROFILE_PIC_PX;
509
+ c.getContext('2d').drawImage(img, (w - side) / 2, (h - side) / 2, side, side, 0, 0, PROFILE_PIC_PX, PROFILE_PIC_PX);
510
+ var out = c.toDataURL('image/jpeg', 0.85);
511
+ if (out.length > 110000) { out = c.toDataURL('image/jpeg', 0.6); }
512
+ resolve(out);
513
+ } catch (e) { reject(e); }
514
+ if (/^blob:/.test(src)) { try { URL.revokeObjectURL(src); } catch (e2) {} }
515
+ };
516
+ img.onerror = function () { reject(new Error('not an image')); };
517
+ img.src = src;
518
+ });
519
+ }
520
+ function profilePicture(p) {
521
+ V.phoneEntry({ title: U.t('A picture for “{name}”', { name: p.name }), what: 'picture', typeTitle: U.t('An image’s link'), placeholder: 'https://…/picture.jpg',
522
+ hint: U.t('From your phone: one of its photos, or an image’s link. Typed here: an image’s link.'),
523
+ validate: function (v) { v = ('' + v).trim(); return /^data:image\/jpeg;base64,/.test(v) || /^https?:\/\/\S+$/i.test(v) ? null : U.t('Not a picture, nor an image’s link'); },
524
+ onText: function (v) {
525
+ v = ('' + v).trim();
526
+ U.toast(U.t('Getting the picture…'), 20000);
527
+ var got = /^data:/.test(v) ? Promise.resolve(v) : YTPlay.imageBytes(v).then(picSource);
528
+ got.then(shrinkPicture).then(function (pic) {
529
+ profileEnsure();
530
+ if (!Profiles.setPic(p.id || Profiles.active().id, pic)) { throw new Error('not kept'); }
531
+ U.toast(U.t('Picture set'));
532
+ renderSettings();
533
+ }).then(null, function (e) { U.log('profiles', 'A profile picture couldn\'t be used: ' + ((e && e.message) || 'unknown')); U.toast(U.t('Couldn’t use that picture'), 4000); });
534
+ } });
535
+ }
492
536
  var PROFILE_STORAGE_MAX = 4194304; // (bytes of the settings storage used: no new profile past this, the 2017 TV keeps about 5 MB)
493
537
  function storageUsed() {
494
538
  var n = 0;
@@ -508,7 +552,8 @@
508
552
  r.__onselect = function () {
509
553
  var opts = [];
510
554
  if (!mine) { opts.push(['switch', U.t('Switch to it')]); }
511
- opts.push(['rename', U.t('Rename')], ['color', U.t('Color')]);
555
+ opts.push(['rename', U.t('Rename')], ['color', U.t('Color')], ['picture', U.t('Picture')]);
556
+ if (p.pic) { opts.push(['nopic', U.t('Remove picture')]); }
512
557
  if (!mine && list.length > 1) { opts.push(['delete', U.t('Delete')]); }
513
558
  pickList(p.name, opts, null, function (v) {
514
559
  _focusChild = 'pf:' + p.id;
@@ -516,7 +561,9 @@
516
561
  else if (v === 'rename') { profileName(U.t('Rename “{name}”', { name: p.name }), p.name, function (name) { profileEnsure(); Profiles.rename(p.id || Profiles.active().id, name); renderSettings(); }); }
517
562
  else if (v === 'color') {
518
563
  pickList(U.t('Color'), Profiles.COLORS.map(function (c) { return [c, PROFILE_COLOR_NAMES[c] || c, null, V.PROFILE_COLORS[c]]; }), p.color, function (c) { profileEnsure(); Profiles.recolor(p.id || Profiles.active().id, c); renderSettings(); });
519
- } else if (v === 'delete') {
564
+ } else if (v === 'picture') { profilePicture(p); }
565
+ else if (v === 'nopic') { Profiles.setPic(p.id, ''); U.toast(U.t('Picture removed')); renderSettings(); }
566
+ else if (v === 'delete') {
520
567
  confirm(U.t('Delete “{name}”? Its addons, settings, progress, watched marks and sign-ins go with it; the rest of the TV’s doesn’t.', { name: p.name }), U.t('Delete'), function () {
521
568
  Profiles.remove(p.id, U.bigStore && U.bigStore.removeExact);
522
569
  U.toast(U.t('“{name}” deleted', { name: p.name }));
package/js/ytplay.js CHANGED
@@ -81,6 +81,11 @@ var YTPlay = (function () {
81
81
  return U.getJSON(PROXY + '/bak/read?drive=' + encodeURIComponent(drive) + a.q, 15000, 3 * 1048576, null, a.h);
82
82
  });
83
83
  }
84
+ // An image's link, downloaded by the service (a profile picture): its bytes (Uint8Array).
85
+ function imageBytes(url) {
86
+ if (MODE === 'browser') { return Promise.reject(new Error('no service')); }
87
+ return ensureService().then(entryAuth).then(function (a) { return U.getText(PROXY + '/img?u=' + encodeURIComponent(url) + a.q, 25000, 8388608, null, true, a.h, null, true); });
88
+ }
84
89
  function entryOpen(what) {
85
90
  return entryAuth().then(function (a) { return U.getJSON(PROXY + '/entry/open?what=' + encodeURIComponent(what || 'link') + a.q, 8000, undefined, null, a.h); });
86
91
  }
@@ -114,10 +119,10 @@ var YTPlay = (function () {
114
119
  // (Settings › Content › Addons › Local-network links from internet addons).
115
120
  // keep: an MKV's subtitle tracks to keep, by their place among its subtitle tracks; the others
116
121
  // are blanked (the service's mkvBlanker); none: the file as it is.
117
- function fileOpen(url, h, lan, keep) {
122
+ function fileOpen(url, h, lan, keep, audio) {
118
123
  if (MODE === 'browser') { return Promise.reject(new Error('no service')); }
119
124
  return ensureService().then(entryAuth).then(function (a) {
120
- return U.getJSON(PROXY + '/live/file?u=' + encodeURIComponent(url) + headerQuery(h) + (lan ? '&lan=1' : '') + (keep ? '&blank=1&keep=' + keep.join(',') : '') + a.q, 5000, 65536, null, a.h);
125
+ return U.getJSON(PROXY + '/live/file?u=' + encodeURIComponent(url) + headerQuery(h) + (lan ? '&lan=1' : '') + (keep ? '&blank=1&keep=' + keep.join(',') + (audio && audio.length ? '&audio=' + audio.join(',') : '') : '') + a.q, 5000, 65536, null, a.h);
121
126
  });
122
127
  }
123
128
  // What's in a source's file, from its header (the service's /live/mi: its container, codecs,
@@ -364,6 +369,6 @@ var YTPlay = (function () {
364
369
  return MODE === 'tizenbrew' ? U.t('TizenBrew module') : MODE === 'wgt' ? U.t('Sideloaded app (.wgt)') : U.t('Browser (development)');
365
370
  }
366
371
 
367
- return { ensureService: ensureService, resolverUrl: resolverUrl, infoUrl: infoUrl, canPlay: canPlay, liveOpen: liveOpen, fileOpen: fileOpen, mediaInfo: mediaInfo, pluginNet: pluginNet, 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, bakWrite: bakWrite, bakRead: bakRead, entrySeen: entrySeen, entryPoll: entryPoll, entryClose: entryClose, subsUrl: subsUrl, audioLang: audioLang, setAudioLang: setAudioLang, installMode: function () { return MODE; },
372
+ return { ensureService: ensureService, resolverUrl: resolverUrl, infoUrl: infoUrl, canPlay: canPlay, liveOpen: liveOpen, fileOpen: fileOpen, mediaInfo: mediaInfo, pluginNet: pluginNet, 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, imageBytes: imageBytes, entryGive: entryGive, bakWrite: bakWrite, bakRead: bakRead, entrySeen: entrySeen, entryPoll: entryPoll, entryClose: entryClose, subsUrl: subsUrl, audioLang: audioLang, setAudioLang: setAudioLang, installMode: function () { return MODE; },
368
373
  installLabel: installLabel, unavailableMessage: unavailableMessage, isRunning: isRunning, port: PORT };
369
374
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stremiok",
3
- "version": "2.4.2",
3
+ "version": "2.4.4",
4
4
  "description": "StremioK streaming client for Tizen 3.0+ Samsung TVs (TizenBrew app module).",
5
5
  "packageType": "app",
6
6
  "appName": "StremioK",