stremiok 2.3.4 → 2.3.6
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 +19 -0
- package/README.md +14 -13
- package/config.xml +1 -1
- package/css/style.css +5 -0
- package/index.html +43 -40
- package/js/app.js +3 -3
- package/js/downloads.js +16 -16
- package/js/epg.js +2 -3
- package/js/hubpreview.js +1 -1
- package/js/i18n.js +108 -0
- package/js/iptv.js +13 -13
- package/js/jellyfin.js +19 -19
- package/js/lang/ar.js +1972 -0
- package/js/lang/de.js +1972 -0
- package/js/lang/es.js +1972 -0
- package/js/lang/fi.js +1972 -0
- package/js/lang/fr.js +1972 -0
- package/js/lang/he.js +1972 -0
- package/js/lang/hi.js +1972 -0
- package/js/lang/it.js +1972 -0
- package/js/lang/ja.js +1972 -0
- package/js/lang/ko.js +1972 -0
- package/js/lang/languages.js +21 -0
- package/js/lang/pl.js +1972 -0
- package/js/lang/pt-BR.js +1972 -0
- package/js/lang/ru.js +1972 -0
- package/js/lang/tr.js +1972 -0
- package/js/lang/zh-CN.js +1972 -0
- package/js/local.js +9 -9
- package/js/netfolders.js +13 -13
- package/js/player-audio.js +17 -17
- package/js/player-controls.js +100 -100
- package/js/player-core.js +90 -58
- package/js/player-lang.js +22 -22
- package/js/player-quality.js +15 -15
- package/js/player-store.js +13 -13
- package/js/player-subs.js +69 -69
- package/js/plex.js +11 -11
- package/js/plugins.js +270 -0
- package/js/stremio-account.js +8 -8
- package/js/stremio-sync.js +5 -5
- package/js/stremio.js +81 -78
- package/js/stvod.js +4 -4
- package/js/trakt.js +23 -23
- package/js/tvapps.js +4 -4
- package/js/util.js +48 -27
- package/js/vendor/quickjs/LICENSES.md +412 -0
- package/js/vendor/quickjs/crypto-js.js +6659 -0
- package/js/vendor/quickjs/plugin-worker-legacy.js +1364 -0
- package/js/vendor/quickjs/plugin-worker.js +8774 -0
- package/js/vendor/quickjs/quickjs.wasm +0 -0
- package/js/view-core.js +93 -93
- package/js/view-detail.js +132 -130
- package/js/view-discover.js +27 -27
- package/js/view-guide.js +13 -13
- package/js/view-home.js +124 -118
- package/js/view-search.js +25 -25
- package/js/view-settings.js +743 -643
- package/js/xtvod.js +2 -2
- package/js/youtube.js +17 -17
- package/js/ytplay.js +39 -9
- package/package.json +1 -1
- package/service/index.js +227 -13
- package/tizenbrew.html +1 -1
package/js/trakt.js
CHANGED
|
@@ -111,7 +111,7 @@ var Trakt = (function () {
|
|
|
111
111
|
function lostSignIn() { // (401 / 403, or the token can't be renewed: nothing more is sent until you connect again)
|
|
112
112
|
if (!isConnected()) { return; }
|
|
113
113
|
if (!needsReconnect()) { setSyncState({ reconnect: true }); }
|
|
114
|
-
if (!_toldReconnect) { _toldReconnect = true; U.toast('Trakt needs reconnecting: Settings › Content › Integrations', 6000); U.log('trakt', 'Trakt sign-in no longer works: reconnect in Settings'); }
|
|
114
|
+
if (!_toldReconnect) { _toldReconnect = true; U.toast(U.t('Trakt needs reconnecting: Settings › Content › Integrations'), 6000); U.log('trakt', 'Trakt sign-in no longer works: reconnect in Settings'); }
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
// Renew the access token when it's near expiry. A renewal Trakt refuses means the sign-in
|
|
@@ -156,19 +156,19 @@ var Trakt = (function () {
|
|
|
156
156
|
cb = cb || {};
|
|
157
157
|
var canceled = false, timer = null, g0 = _gen;
|
|
158
158
|
var c = getCreds();
|
|
159
|
-
if (!c.id) { if (cb.onError) { cb.onError('Enter your Trakt Client ID first.'); } return function () {}; }
|
|
159
|
+
if (!c.id) { if (cb.onError) { cb.onError(U.t('Enter your Trakt Client ID first.')); } return function () {}; }
|
|
160
160
|
|
|
161
161
|
req('POST', '/oauth/device/code', { client_id: c.id }, false).then(function (r) {
|
|
162
162
|
if (canceled) { return; }
|
|
163
163
|
var d = r.data || {};
|
|
164
|
-
if (!d.device_code) { if (cb.onError) { cb.onError('Trakt did not return a device code.'); } return; }
|
|
164
|
+
if (!d.device_code) { if (cb.onError) { cb.onError(U.t('Trakt did not return a device code.')); } return; }
|
|
165
165
|
if (cb.onCode) { cb.onCode(d.user_code, d.verification_url || 'https://trakt.tv/activate'); }
|
|
166
166
|
var interval = (d.interval || 5) * 1000;
|
|
167
167
|
var deadline = Date.now() + ((d.expires_in || 600) * 1000);
|
|
168
168
|
|
|
169
169
|
function pollOnce() {
|
|
170
170
|
if (canceled) { return; }
|
|
171
|
-
if (Date.now() > deadline) { if (cb.onError) { cb.onError('Code expired — try again.'); } return; }
|
|
171
|
+
if (Date.now() > deadline) { if (cb.onError) { cb.onError(U.t('Code expired — try again.')); } return; }
|
|
172
172
|
req('POST', '/oauth/device/token', client({ code: d.device_code }), false)
|
|
173
173
|
.then(function (tr) {
|
|
174
174
|
if (canceled || !current(g0)) { return; }
|
|
@@ -188,15 +188,15 @@ var Trakt = (function () {
|
|
|
188
188
|
var s = err && err.status;
|
|
189
189
|
if (s === 400) { timer = setTimeout(pollOnce, interval); return; } // authorization pending
|
|
190
190
|
if (s === 429) { timer = setTimeout(pollOnce, interval + 1000); return; } // slow down
|
|
191
|
-
if (s === 418) { if (cb.onError) { cb.onError('Sign-in was denied.'); } return; }
|
|
192
|
-
if (s === 410) { if (cb.onError) { cb.onError('Code expired — try again.'); } return; }
|
|
193
|
-
if (s === 409) { if (cb.onError) { cb.onError('Code already used.'); } return; }
|
|
191
|
+
if (s === 418) { if (cb.onError) { cb.onError(U.t('Sign-in was denied.')); } return; }
|
|
192
|
+
if (s === 410) { if (cb.onError) { cb.onError(U.t('Code expired — try again.')); } return; }
|
|
193
|
+
if (s === 409) { if (cb.onError) { cb.onError(U.t('Code already used.')); } return; }
|
|
194
194
|
if (cb.onPending) { cb.onPending(); }
|
|
195
195
|
timer = setTimeout(pollOnce, interval);
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
198
|
timer = setTimeout(pollOnce, interval);
|
|
199
|
-
}, function () { if (cb.onError) { cb.onError('Could not reach Trakt (or CORS blocked on desktop).'); } });
|
|
199
|
+
}, function () { if (cb.onError) { cb.onError(U.t('Could not reach Trakt (or CORS blocked on desktop).')); } });
|
|
200
200
|
|
|
201
201
|
return function cancel() { canceled = true; if (timer) { clearTimeout(timer); } };
|
|
202
202
|
}
|
|
@@ -507,16 +507,16 @@ var Trakt = (function () {
|
|
|
507
507
|
}
|
|
508
508
|
return Promise.resolve(list.map(function (x) {
|
|
509
509
|
return { id: x.imdb, type: x.type, name: x.title || x.imdb, poster: poster(x.imdb), posterShape: 'poster',
|
|
510
|
-
releaseInfo: x.year ? '' + x.year : '', description: x.next ? 'Up next: '
|
|
510
|
+
releaseInfo: x.year ? '' + x.year : '', description: x.next ? U.t('Up next: {ep}', { ep: x.next }) : '' };
|
|
511
511
|
}));
|
|
512
512
|
}
|
|
513
513
|
function synthAddon() {
|
|
514
514
|
return {
|
|
515
515
|
__local: true, __impl: { catalog: synthCatalog }, url: 'local:trakt', base: 'local:trakt',
|
|
516
516
|
manifest: { id: 'org.stremiok.trakt', name: 'Trakt', version: '1.0.0', types: ['movie', 'series'], resources: ['catalog'],
|
|
517
|
-
catalogs: [{ type: 'series', id: 'trakt_upnext', name: 'Up next', extra: [{ name: 'skip' }] },
|
|
518
|
-
{ type: 'movie', id: 'trakt_watchlist_movies', name: 'Watchlist', extra: [{ name: 'skip' }] },
|
|
519
|
-
{ type: 'series', id: 'trakt_watchlist_shows', name: 'Watchlist', extra: [{ name: 'skip' }] }] }
|
|
517
|
+
catalogs: [{ type: 'series', id: 'trakt_upnext', name: U.t('Up next'), extra: [{ name: 'skip' }] },
|
|
518
|
+
{ type: 'movie', id: 'trakt_watchlist_movies', name: U.t('Watchlist'), extra: [{ name: 'skip' }] },
|
|
519
|
+
{ type: 'series', id: 'trakt_watchlist_shows', name: U.t('Watchlist'), extra: [{ name: 'skip' }] }] }
|
|
520
520
|
};
|
|
521
521
|
}
|
|
522
522
|
|
|
@@ -535,7 +535,7 @@ var Trakt = (function () {
|
|
|
535
535
|
(U.store.get(UPNEXT_KEY, []) || []).forEach(function (u) {
|
|
536
536
|
if (!u || !u.imdb || paused[u.imdb]) { return; }
|
|
537
537
|
var e = { id: u.imdb + ':' + u.season + ':' + u.episode, type: 'series', parent: u.imdb,
|
|
538
|
-
name: (u.title || 'Show') + ' S' + u.season + 'E' + u.episode, poster: poster(u.imdb),
|
|
538
|
+
name: (u.title || U.t('Show')) + ' S' + u.season + 'E' + u.episode, poster: poster(u.imdb),
|
|
539
539
|
position: 0, duration: 0, updated: u.at || 0, _trakt: true, upNext: u.epTitle || '' };
|
|
540
540
|
if (kept(e)) { list.push(e); }
|
|
541
541
|
});
|
|
@@ -563,13 +563,13 @@ var Trakt = (function () {
|
|
|
563
563
|
if (it.type === 'movie' && it.movie) {
|
|
564
564
|
var mi = imdbOf(it.movie.ids);
|
|
565
565
|
if (!mi) { return; }
|
|
566
|
-
out.push({ id: mi, type: 'movie', name: str(it.movie.title, 200) || 'Movie', poster: poster(mi),
|
|
566
|
+
out.push({ id: mi, type: 'movie', name: str(it.movie.title, 200) || U.t('Movie'), poster: poster(mi),
|
|
567
567
|
position: prog, duration: 100, updated: updated, _trakt: true });
|
|
568
568
|
} else if (it.type === 'episode' && it.show && it.episode) {
|
|
569
569
|
var si = imdbOf(it.show.ids), sn = num(it.episode.season, 1000), en = num(it.episode.number, 10000);
|
|
570
570
|
if (!si || sn === null || en === null) { return; }
|
|
571
571
|
out.push({ id: si + ':' + sn + ':' + en, type: 'series',
|
|
572
|
-
name: (str(it.show.title, 200) || 'Show') + ' S' + sn + 'E' + en,
|
|
572
|
+
name: (str(it.show.title, 200) || U.t('Show')) + ' S' + sn + 'E' + en,
|
|
573
573
|
poster: poster(si), position: prog, duration: 100, updated: updated, _trakt: true });
|
|
574
574
|
}
|
|
575
575
|
});
|
|
@@ -644,12 +644,12 @@ var Trakt = (function () {
|
|
|
644
644
|
function saveOutbox(b) {
|
|
645
645
|
if (b.length > OUTBOX_MAX) {
|
|
646
646
|
U.log('trakt', (b.length - OUTBOX_MAX) + ' older change(s) dropped, not sent to Trakt: more than ' + OUTBOX_MAX + ' waiting');
|
|
647
|
-
if (!_toldFull) { _toldFull = true; U.toast('Trakt: too many changes waiting, the oldest were dropped', 6000); }
|
|
647
|
+
if (!_toldFull) { _toldFull = true; U.toast(U.t('Trakt: too many changes waiting, the oldest were dropped'), 6000); }
|
|
648
648
|
b = b.slice(-OUTBOX_MAX);
|
|
649
649
|
}
|
|
650
650
|
if (U.store.set(OUTBOX_KEY, b) === false) {
|
|
651
651
|
U.log('trakt', 'The changes waiting for Trakt couldn’t be saved on the TV (its storage is full): they’re lost if StremioK closes');
|
|
652
|
-
if (!_toldUnsaved) { _toldUnsaved = true; U.toast('Trakt: the changes waiting couldn’t be saved on the TV (storage full)', 6000); }
|
|
652
|
+
if (!_toldUnsaved) { _toldUnsaved = true; U.toast(U.t('Trakt: the changes waiting couldn’t be saved on the TV (storage full)'), 6000); }
|
|
653
653
|
}
|
|
654
654
|
}
|
|
655
655
|
function newId() { return Date.now().toString(36) + Math.floor(Math.random() * 1e6).toString(36); }
|
|
@@ -695,15 +695,15 @@ var Trakt = (function () {
|
|
|
695
695
|
var soonest = Math.min.apply(null, waiting.map(function (x) { return x.next || 0; }));
|
|
696
696
|
flushSoon(Math.max(1000, soonest - Date.now()));
|
|
697
697
|
}
|
|
698
|
-
function what(x) { return x.kind === 'add' ? 'watched' : x.kind === 'remove' ? 'not watched' : x.kind === 'stop' ? 'watched (finished)' : x.kind === 'rate' ? 'rated '
|
|
698
|
+
function what(x) { return x.kind === 'add' ? U.t('watched') : x.kind === 'remove' ? U.t('not watched') : x.kind === 'stop' ? U.t('watched (finished)') : x.kind === 'rate' ? U.t('rated {n}', { n: x.rating }) : x.kind === 'unrate' ? U.t('rating removed') : U.t('where you stopped'); }
|
|
699
699
|
// The change's title: its name when it has one, else its IMDb id (and episode), or how many.
|
|
700
700
|
function titleOf(x) {
|
|
701
701
|
var keys = x.keys || [];
|
|
702
702
|
if (x.name) { return x.name; }
|
|
703
|
-
if (keys.length > 1) { return
|
|
703
|
+
if (keys.length > 1) { return U.t('{n} titles / episodes', { n: keys.length }); }
|
|
704
704
|
var m = ('' + (keys[0] || '')).match(/^(?:movie|series):(tt\d+)(?::(\d+):(\d+))?$/);
|
|
705
705
|
var s = ('' + (keys[0] || '')).match(/^season:(tt\d+):(\d+)$/);
|
|
706
|
-
if (s) { return
|
|
706
|
+
if (s) { return U.t('{show} Season {n}', { show: s[1], n: s[2] }); }
|
|
707
707
|
return m ? m[1] + (m[2] ? ' S' + m[2] + 'E' + m[3] : '') : '';
|
|
708
708
|
}
|
|
709
709
|
function describe(x) { var t = titleOf(x); return what(x) + (t ? ', ' + t : ''); }
|
|
@@ -742,8 +742,8 @@ var Trakt = (function () {
|
|
|
742
742
|
// that isn't is retried, not taken as done).
|
|
743
743
|
function ackProblem(r) {
|
|
744
744
|
var d = r && r.data;
|
|
745
|
-
if (r && r.bad) { return 'an answer that isn’t Trakt’s JSON'; }
|
|
746
|
-
if (!d || typeof d !== 'object' || Array.isArray(d)) { return 'an unexpected answer'; }
|
|
745
|
+
if (r && r.bad) { return U.t('an answer that isn’t Trakt’s JSON'); }
|
|
746
|
+
if (!d || typeof d !== 'object' || Array.isArray(d)) { return U.t('an unexpected answer'); }
|
|
747
747
|
return '';
|
|
748
748
|
}
|
|
749
749
|
function update(due, fn) {
|
|
@@ -791,7 +791,7 @@ var Trakt = (function () {
|
|
|
791
791
|
var refused = st >= 400 && st < 500 && st !== 408 && st !== 429;
|
|
792
792
|
if (refused || x.tries >= TRIES_MAX) {
|
|
793
793
|
var said = err && err.data && typeof err.data.message === 'string' ? err.data.message.replace(/\s+/g, ' ').trim().slice(0, 200) : '';
|
|
794
|
-
x.failed = true; x.err = st ? 'HTTP ' + st + (said ? ': ' + said : '') : (err && err.unexpected) || (err && err.tooBig ? 'answer too large' : 'no answer');
|
|
794
|
+
x.failed = true; x.err = st ? 'HTTP ' + st + (said ? ': ' + said : '') : (err && err.unexpected) || (err && err.tooBig ? U.t('answer too large') : U.t('no answer'));
|
|
795
795
|
U.log('trakt', 'Not sent to Trakt: ' + describe(x) + ' (' + x.err + ')');
|
|
796
796
|
} else {
|
|
797
797
|
x.next = Date.now() + Math.max(((err && err.retryAfter) || 0) * 1000, Math.min(30000 * Math.pow(2, x.tries - 1), 3600000));
|
package/js/tvapps.js
CHANGED
|
@@ -12,7 +12,7 @@ var TVApps = (function () {
|
|
|
12
12
|
|
|
13
13
|
function api() { return (window.tizen && tizen.application) || null; }
|
|
14
14
|
function available() { var a = api(); return !!(a && a.getAppsInfo && a.launch); }
|
|
15
|
-
function errText(e) { return '' + ((e && (e.name || e.message)) || 'unknown error'); }
|
|
15
|
+
function errText(e) { return '' + ((e && (e.name || e.message)) || U.t('unknown error')); }
|
|
16
16
|
function byName(x, y) { var p = x.name.toLowerCase(), q = y.name.toLowerCase(); return p < q ? -1 : p > q ? 1 : 0; }
|
|
17
17
|
|
|
18
18
|
// The installed apps, by name: [{ id, name, version, show }] (show false: a hidden
|
|
@@ -27,7 +27,7 @@ var TVApps = (function () {
|
|
|
27
27
|
reject(new Error(m));
|
|
28
28
|
}
|
|
29
29
|
var a = api();
|
|
30
|
-
if (!a || !a.getAppsInfo) { reject(new Error('Not available here')); return; }
|
|
30
|
+
if (!a || !a.getAppsInfo) { reject(new Error(U.t('Not available here'))); return; }
|
|
31
31
|
try {
|
|
32
32
|
a.getAppsInfo(function (apps) {
|
|
33
33
|
var list = [];
|
|
@@ -52,7 +52,7 @@ var TVApps = (function () {
|
|
|
52
52
|
reject(new Error(m));
|
|
53
53
|
}
|
|
54
54
|
var a = api();
|
|
55
|
-
if (!a || !a.launch) { fail(new Error('Not available here')); return; }
|
|
55
|
+
if (!a || !a.launch) { fail(new Error(U.t('Not available here'))); return; }
|
|
56
56
|
try { a.launch(app.id, function () { resolve(); }, fail); } catch (e) { fail(e); }
|
|
57
57
|
});
|
|
58
58
|
}
|
|
@@ -65,7 +65,7 @@ var TVApps = (function () {
|
|
|
65
65
|
function sendControl(appId, spec) {
|
|
66
66
|
return new Promise(function (resolve, reject) {
|
|
67
67
|
var a = api();
|
|
68
|
-
if (!a || !a.launchAppControl || !window.tizen.ApplicationControl) { reject(new Error('Not available here')); return; }
|
|
68
|
+
if (!a || !a.launchAppControl || !window.tizen.ApplicationControl) { reject(new Error(U.t('Not available here'))); return; }
|
|
69
69
|
try {
|
|
70
70
|
var data = (spec.data || []).map(function (d) { return new tizen.ApplicationControlData(d[0], ['' + d[1]]); });
|
|
71
71
|
var ctl = new tizen.ApplicationControl(OP[spec.operation] || spec.operation, spec.uri || null, null, null, data);
|
package/js/util.js
CHANGED
|
@@ -167,30 +167,30 @@ var U = (function () {
|
|
|
167
167
|
function urlProblem(input) { return parseUrlWhy(input).why; }
|
|
168
168
|
function parseUrlWhy(input) {
|
|
169
169
|
var u = ('' + (input || '')).trim();
|
|
170
|
-
if (!u || u === 'https://' || u === 'http://') { return { why: 'Enter a URL' }; }
|
|
171
|
-
if (/\s/.test(u)) { return { why: 'A URL can’t contain spaces' }; }
|
|
170
|
+
if (!u || u === 'https://' || u === 'http://') { return { why: t('Enter a URL') }; }
|
|
171
|
+
if (/\s/.test(u)) { return { why: t('A URL can’t contain spaces') }; }
|
|
172
172
|
if (/^stremio:\/\//i.test(u)) { u = 'https://' + u.slice(10); }
|
|
173
173
|
else if (!/^[a-z][a-z0-9+.-]*:/i.test(u)) { u = 'https://' + u.replace(/^\/\//, ''); }
|
|
174
174
|
var m = u.match(/^([a-z][a-z0-9+.-]*):\/\/([^\/?#]*)([^?#]*)(\?[^#]*)?(#.*)?$/i);
|
|
175
|
-
if (!m) { return { why: 'That isn’t a URL' }; }
|
|
175
|
+
if (!m) { return { why: t('That isn’t a URL') }; }
|
|
176
176
|
var scheme = m[1].toLowerCase();
|
|
177
|
-
if (scheme !== 'http' && scheme !== 'https') { return { why: 'Only http:// and https:// URLs are supported' }; }
|
|
177
|
+
if (scheme !== 'http' && scheme !== 'https') { return { why: t('Only http:// and https:// URLs are supported') }; }
|
|
178
178
|
if (m[2].indexOf('@') !== -1) { return { why: 'Remove the user:password@ part (put credentials where your provider says, e.g. ?username=…&password=…)' }; }
|
|
179
179
|
var hp = m[2].match(/^(\[[0-9a-f:.]+\]|[^\[\]:]+)(?::(\d{1,5}))?$/i);
|
|
180
|
-
if (!hp) { return { why: 'That address has no valid host' }; }
|
|
180
|
+
if (!hp) { return { why: t('That address has no valid host') }; }
|
|
181
181
|
var host = canonicalHost(hp[1]);
|
|
182
|
-
if (host === null) { return { why: 'That address has no valid host' }; }
|
|
182
|
+
if (host === null) { return { why: t('That address has no valid host') }; }
|
|
183
183
|
if (host.charAt(0) === '[') {
|
|
184
|
-
if (!v6Words(host.slice(1, -1))) { return { why: 'That address has no valid host' }; }
|
|
184
|
+
if (!v6Words(host.slice(1, -1))) { return { why: t('That address has no valid host') }; }
|
|
185
185
|
} else {
|
|
186
186
|
if (/[^.]\.$/.test(host)) { host = host.slice(0, -1); } // "localhost." is localhost
|
|
187
|
-
if (!/^[a-z0-9\u00a1-\uffff._-]+$/.test(host) || /^[.-]|[.-]$|\.\./.test(host)) { return { why: 'That address has no valid host' }; }
|
|
187
|
+
if (!/^[a-z0-9\u00a1-\uffff._-]+$/.test(host) || /^[.-]|[.-]$|\.\./.test(host)) { return { why: t('That address has no valid host') }; }
|
|
188
188
|
// an IP address only in its usual form: 127.1, 2130706433, 0x7f.0.0.1, 0177.0.0.1
|
|
189
189
|
// all mean 127.0.0.1 to the browser, and would slip past the checks below
|
|
190
|
-
if (numericHost(host) && !quad(host)) { return { why: 'Write the IP address the usual way (four numbers 0–255, like 203.0.113.5)' }; }
|
|
190
|
+
if (numericHost(host) && !quad(host)) { return { why: t('Write the IP address the usual way (four numbers 0–255, like 203.0.113.5)') }; }
|
|
191
191
|
}
|
|
192
192
|
var port = hp[2] ? parseInt(hp[2], 10) : null;
|
|
193
|
-
if (port !== null && (port < 1 || port > 65535)) { return { why: 'That port isn’t valid' }; }
|
|
193
|
+
if (port !== null && (port < 1 || port > 65535)) { return { why: t('That port isn’t valid') }; }
|
|
194
194
|
var path = m[3] || '';
|
|
195
195
|
return { url: { href: scheme + '://' + host + (hp[2] ? ':' + hp[2] : '') + path + (m[4] || '') + (m[5] || ''),
|
|
196
196
|
scheme: scheme, host: host, port: port, path: path || '/', query: m[4] ? m[4].slice(1) : '', hash: m[5] || '' } };
|
|
@@ -398,12 +398,21 @@ var U = (function () {
|
|
|
398
398
|
var ua = headerValue(h.ua != null ? h.ua : (h['User-Agent'] || h['user-agent']), HEADER_MAX.ua);
|
|
399
399
|
var ref = headerValue(h.ref != null ? h.ref : (h.Referer || h.referer), HEADER_MAX.ref);
|
|
400
400
|
var cookie = headerValue(h.cookie != null ? h.cookie : (h.Cookie || h.COOKIE), HEADER_MAX.cookie);
|
|
401
|
+
// (and three the TV's player can't send, played through the service: see player-core's
|
|
402
|
+
// fileViaService) an Origin is a site's address alone
|
|
403
|
+
var origin = headerValue(h.origin != null ? h.origin : (h.Origin || h.ORIGIN), HEADER_MAX.ref);
|
|
404
|
+
var accept = headerValue(h.accept != null ? h.accept : (h.Accept || h.ACCEPT), HEADER_MAX.ua);
|
|
405
|
+
var lang = headerValue(h.lang != null ? h.lang : (h['Accept-Language'] || h['accept-language']), HEADER_MAX.ua);
|
|
401
406
|
if (ref && !/^https?:\/\/[^\s]+$/i.test(ref)) { ref = ''; }
|
|
402
|
-
if (
|
|
407
|
+
if (origin && !/^https?:\/\/[^\s\/?#]+$/i.test(origin)) { origin = ''; }
|
|
408
|
+
if (!ua && !ref && !cookie && !origin && !accept && !lang) { return null; }
|
|
403
409
|
var out = {};
|
|
404
410
|
if (ua) { out.ua = ua; }
|
|
405
411
|
if (ref) { out.ref = ref; }
|
|
406
412
|
if (cookie) { out.cookie = cookie; }
|
|
413
|
+
if (origin) { out.origin = origin; }
|
|
414
|
+
if (accept) { out.accept = accept; }
|
|
415
|
+
if (lang) { out.lang = lang; }
|
|
407
416
|
return out;
|
|
408
417
|
}
|
|
409
418
|
|
|
@@ -414,16 +423,16 @@ var U = (function () {
|
|
|
414
423
|
function problem(err) {
|
|
415
424
|
var m = '' + ((err && err.message) || err || '');
|
|
416
425
|
var big = m.match(/^Too large \((over [^)]+)\)/);
|
|
417
|
-
if (big) { return 'too large ('
|
|
418
|
-
if (/^Bad JSON/.test(m)) { return 'not valid JSON'; }
|
|
426
|
+
if (big) { return t('too large ({what})', { what: big[1] }); }
|
|
427
|
+
if (/^Bad JSON/.test(m)) { return t('not valid JSON'); }
|
|
419
428
|
var late = m.match(/^Timed out after (\d+ s)/);
|
|
420
|
-
if (late) { return 'timed out after '
|
|
421
|
-
if (/^Timeout/.test(m)) { return 'timed out'; }
|
|
422
|
-
if (/^(No answer|Network error)/.test(m)) { return 'no answer (connection refused, blocked or certificate)'; }
|
|
423
|
-
if (/^Redirected into the home network/.test(m)) { return 'redirected into the home network'; }
|
|
429
|
+
if (late) { return t('timed out after {time}', { time: late[1] }); }
|
|
430
|
+
if (/^Timeout/.test(m)) { return t('timed out'); }
|
|
431
|
+
if (/^(No answer|Network error)/.test(m)) { return t('no answer (connection refused, blocked or certificate)'); }
|
|
432
|
+
if (/^Redirected into the home network/.test(m)) { return t('redirected into the home network'); }
|
|
424
433
|
var st = m.match(/^HTTP (\d+)/);
|
|
425
|
-
if (st) { return st[1] === '0' ? 'no answer (connection refused, blocked or certificate)' : 'HTTP ' + st[1]; }
|
|
426
|
-
return m.split(':')[0] || 'failed';
|
|
434
|
+
if (st) { return st[1] === '0' ? t('no answer (connection refused, blocked or certificate)') : 'HTTP ' + st[1]; }
|
|
435
|
+
return m.split(':')[0] || t('failed');
|
|
427
436
|
}
|
|
428
437
|
|
|
429
438
|
/* A list from an answer: [] unless it really is one, only its object items (the rest
|
|
@@ -966,8 +975,8 @@ var U = (function () {
|
|
|
966
975
|
// "6 KB; the database: 380 KB used of 15.3 MB; the TV: 225 MB free" (what's known)
|
|
967
976
|
function figures(size, q) {
|
|
968
977
|
return diskInfo().then(function (d) {
|
|
969
|
-
return fmtSize(size) + (q && q.quota ? '; the database: '
|
|
970
|
-
(d ? '; the TV: '
|
|
978
|
+
return fmtSize(size) + (q && q.quota ? '; ' + t('the database: {used} used of {quota}', { used: fmtSize(q.usage || 0), quota: fmtSize(q.quota) }) : '') +
|
|
979
|
+
(d ? '; ' + t('the TV: {free} free', { free: fmtSize(d.free) }) : '');
|
|
971
980
|
});
|
|
972
981
|
}
|
|
973
982
|
function fmtSize(n) { return n >= 1048576 ? (n / 1048576).toFixed(1).replace(/\.0$/, '') + ' MB' : Math.max(1, Math.round(n / 1024)) + ' KB'; }
|
|
@@ -1071,7 +1080,7 @@ var U = (function () {
|
|
|
1071
1080
|
}
|
|
1072
1081
|
log('storage', 'TV storage full: could not save ' + key);
|
|
1073
1082
|
var now = Date.now();
|
|
1074
|
-
if (_fullToldAt === null || now - _fullToldAt > 60000) { _fullToldAt = now; try { toast('The TV’s storage is full: a change couldn’t be saved (Settings › Diagnostics).', 4000); } catch (e2) {} }
|
|
1083
|
+
if (_fullToldAt === null || now - _fullToldAt > 60000) { _fullToldAt = now; try { toast(t('The TV’s storage is full: a change couldn’t be saved (Settings › Diagnostics).'), 4000); } catch (e2) {} }
|
|
1075
1084
|
return false;
|
|
1076
1085
|
},
|
|
1077
1086
|
remove: function (key) {
|
|
@@ -1574,19 +1583,30 @@ var U = (function () {
|
|
|
1574
1583
|
}
|
|
1575
1584
|
|
|
1576
1585
|
// A day relative to today: "today", "tomorrow", "yesterday", else "Thu 2 Oct" (and the
|
|
1577
|
-
// year when it isn't this one).
|
|
1586
|
+
// year when it isn't this one), in the interface's language.
|
|
1578
1587
|
var WDAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
1579
1588
|
var MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
1589
|
+
function weekday(d) { return t(WDAYS[d]); }
|
|
1590
|
+
function month(m) { return t(MONTHS[m]); }
|
|
1580
1591
|
function dayLabel(ms) {
|
|
1581
1592
|
var d = new Date(ms), today = new Date(Date.now());
|
|
1582
1593
|
function startOf(x) { return new Date(x.getFullYear(), x.getMonth(), x.getDate()).getTime(); }
|
|
1583
1594
|
var diff = Math.round((startOf(d) - startOf(today)) / 86400000);
|
|
1584
|
-
if (diff === 0) { return 'today'; }
|
|
1585
|
-
if (diff === 1) { return 'tomorrow'; }
|
|
1586
|
-
if (diff === -1) { return 'yesterday'; }
|
|
1587
|
-
return
|
|
1595
|
+
if (diff === 0) { return t('today'); }
|
|
1596
|
+
if (diff === 1) { return t('tomorrow'); }
|
|
1597
|
+
if (diff === -1) { return t('yesterday'); }
|
|
1598
|
+
return weekday(d.getDay()) + ' ' + d.getDate() + ' ' + month(d.getMonth()) +
|
|
1588
1599
|
(d.getFullYear() !== today.getFullYear() ? ' ' + d.getFullYear() : '');
|
|
1589
1600
|
}
|
|
1601
|
+
// The interface's language (js/i18n.js): a phrase by its English text, {name}s filled in; a
|
|
1602
|
+
// number's singular or plural form. Without it (a test, a page that didn't load it): English.
|
|
1603
|
+
function t(s, vars) { return (typeof I18N !== 'undefined') ? I18N.t(s, vars) : ('' + s).replace(/\{(\w+)\}/g, function (m, k) { return vars && Object.prototype.hasOwnProperty.call(vars, k) ? '' + vars[k] : m; }); }
|
|
1604
|
+
function tn(n, one, other, vars) {
|
|
1605
|
+
if (typeof I18N !== 'undefined') { return I18N.tn(n, one, other, vars); }
|
|
1606
|
+
var v = { n: n };
|
|
1607
|
+
if (vars) { Object.keys(vars).forEach(function (k) { v[k] = vars[k]; }); }
|
|
1608
|
+
return t(n === 1 ? one : other, v);
|
|
1609
|
+
}
|
|
1590
1610
|
|
|
1591
1611
|
/* Run an array of promise-returning fns with limited concurrency; never rejects.
|
|
1592
1612
|
Returns Promise of array of {ok, value|error} in original order. */
|
|
@@ -1686,6 +1706,7 @@ var U = (function () {
|
|
|
1686
1706
|
postJSON: postJSON, redactUrl: redactUrl, problem: problem, problemDetail: problemDetail, listOf: listOf, lru: lru, randomHex: randomHex, cachedJSON: cachedJSON,
|
|
1687
1707
|
parseUrl: parseUrl, urlProblem: urlProblem, isPlaylistUrl: isPlaylistUrl, isManifestUrl: isManifestUrl,
|
|
1688
1708
|
isPrivateHost: isPrivateHost, urlIsPrivate: urlIsPrivate, setLocalPolicy: setLocalPolicy, sanitizeHeaders: sanitizeHeaders, drawable: drawable,
|
|
1709
|
+
t: t, tn: tn, weekday: weekday, month: month,
|
|
1689
1710
|
look: look, setLook: setLook, canBlur: canBlur, heroImages: heroImages, log: log, logEntries: logEntries, clearLog: clearLog, bigStore: bigStore, diskInfo: diskInfo,
|
|
1690
1711
|
store: store, toast: toast, spinner: spinner,
|
|
1691
1712
|
deferImage: deferImage, deferBg: deferBg, cardImage: cardImage, prioritizeImages: prioritizeImages, requeueImages: requeueImages,
|