stremiok 2.3.0 → 2.3.2
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 +21 -0
- package/config.xml +1 -1
- package/css/style.css +2 -0
- package/index.html +38 -38
- package/js/app.js +21 -0
- package/js/jellyfin.js +208 -18
- package/js/player-audio.js +61 -4
- package/js/player-store.js +9 -4
- package/js/plex.js +63 -14
- package/js/stremio.js +2 -0
- package/js/util.js +11 -6
- package/js/view-core.js +28 -5
- package/js/view-discover.js +6 -2
- package/js/view-home.js +4 -0
- package/js/view-settings.js +26 -6
- package/js/views.js +1 -1
- package/package.json +3 -2
- package/tizenbrew.html +20 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,27 @@
|
|
|
3
3
|
What changed in each version of StremioK, newest first. How everything works is in the
|
|
4
4
|
[user guide](docs/USER-GUIDE.md).
|
|
5
5
|
|
|
6
|
+
## 2.3.2 — 2026-11-07
|
|
7
|
+
- **TizenBrew runs one version at a time:** a TV could keep an old version, or a mix of two, for
|
|
8
|
+
hours after a release (2.3.0 with 2.3.1 listed, #17). TizenBrew now opens a start page that
|
|
9
|
+
loads one version's own copy.
|
|
10
|
+
- **Your media server's watched marks:** what Jellyfin, Emby or Plex has played is ticked here
|
|
11
|
+
too, a show once all of it is; read at launch and every 30 minutes. A mark made here since wins.
|
|
12
|
+
- **Watched titles** (Settings › Appearance): their cards ticked (Show), dimmed too (Dim), or left
|
|
13
|
+
out of Home's and Discover's rows (Hide).
|
|
14
|
+
- **Emby's seek pictures** above the marker as ◀ ▶ move it, where the library's thumbnail
|
|
15
|
+
extraction made them.
|
|
16
|
+
- **A media server turned off and on** (Settings › Content › Media servers, OK on it): off, its
|
|
17
|
+
rows, sources and watched marks are set aside, still signed in; *Turn on* brings them back.
|
|
18
|
+
- **Wait for a server** (Settings › Content › Media servers): 45, 90 or 180 seconds instead of 20,
|
|
19
|
+
for a slow one whose rows or Discover pages timed out.
|
|
20
|
+
|
|
21
|
+
## 2.3.1 — 2026-11-07
|
|
22
|
+
- **An audio track chosen while paused, or during a jump,** now plays: the TV refuses a switch
|
|
23
|
+
then, and the menu ticked the track all the same. It's made once the video plays on (#17).
|
|
24
|
+
- **Diagnostics › Logs on an audio switch:** the tracks the TV lists, the one asked for, whether
|
|
25
|
+
the TV refused it, and the one it played next.
|
|
26
|
+
|
|
6
27
|
## 2.3.0 — 2026-11-07
|
|
7
28
|
- **Jellyfin, Emby and Plex** (Settings › Content › Media servers): your server's Movies and Shows
|
|
8
29
|
libraries, *Continue watching* and *Next up* as Home rows, and its copy of a film or episode first
|
package/config.xml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets"
|
|
3
|
-
id="http://stremiok.tizen/StremioKTizen" version="2.3.
|
|
3
|
+
id="http://stremiok.tizen/StremioKTizen" version="2.3.2" viewmodes="maximized">
|
|
4
4
|
<tizen:application id="StremioK01.StremioK" package="StremioK01" required_version="3.0"/>
|
|
5
5
|
<content src="index.html"/>
|
|
6
6
|
<feature name="http://tizen.org/feature/screen.size.all"/>
|
package/css/style.css
CHANGED
|
@@ -284,6 +284,8 @@ html, body {
|
|
|
284
284
|
/* --- Watched mark on posters --- */
|
|
285
285
|
.card .card-rating { position: absolute; top: 8px; left: 8px; z-index: 2; padding: 3px 9px; border-radius: 12px; background: rgba(0,0,0,0.72); color: #ffd257; font-size: 17px; font-weight: bold; }
|
|
286
286
|
.card .card-watched { position: absolute; top: 8px; right: 8px; z-index: 2; width: 34px; height: 34px; line-height: 34px; text-align: center; border-radius: 17px; background: rgba(99,102,241,0.95); color: #fff; font-size: 20px; font-weight: bold; }
|
|
287
|
+
.card.watched-dim .poster, .card.watched-dim .fallback { opacity: 0.4; } /* Settings › Appearance › Watched titles: Dim (focused: clearer) */
|
|
288
|
+
.card.watched-dim.focused .poster, .card.watched-dim.focused .fallback { opacity: 0.85; }
|
|
287
289
|
|
|
288
290
|
/* --- Contextual quick-action bar (UP) --- */
|
|
289
291
|
#player-bar { position: absolute; left: 0; right: 0; bottom: 250px; z-index: 22; text-align: center; white-space: nowrap; } /* (up to ten buttons: one line, compact) */
|
package/index.html
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<meta name="viewport" content="width=1920, height=1080, user-scalable=no">
|
|
6
6
|
<title>StremioK</title>
|
|
7
|
-
<link rel="stylesheet" href="css/style.css?v=2.3.
|
|
8
|
-
<link rel="stylesheet" href="css/modern.css?v=2.3.
|
|
7
|
+
<link rel="stylesheet" href="css/style.css?v=2.3.2">
|
|
8
|
+
<link rel="stylesheet" href="css/modern.css?v=2.3.2">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
11
11
|
<!-- CSS-applied sentinel (kept off-screen); app.js waits for its width before rendering -->
|
|
@@ -54,41 +54,41 @@
|
|
|
54
54
|
|
|
55
55
|
<!-- Load order matters: polyfills -> util -> iptv -> data -> input -> tvapps -> player parts -> player -> ytplay -> view parts -> views -> app -->
|
|
56
56
|
<!-- ?v= busts the TV webview cache on every release (keep in sync with package.json) -->
|
|
57
|
-
<script src="js/polyfills.js?v=2.3.
|
|
58
|
-
<script src="js/util.js?v=2.3.
|
|
59
|
-
<script src="js/iptv.js?v=2.3.
|
|
60
|
-
<script src="js/xtvod.js?v=2.3.
|
|
61
|
-
<script src="js/stvod.js?v=2.3.
|
|
62
|
-
<script src="js/jellyfin.js?v=2.3.
|
|
63
|
-
<script src="js/plex.js?v=2.3.
|
|
64
|
-
<script src="js/epg.js?v=2.3.
|
|
65
|
-
<script src="js/youtube.js?v=2.3.
|
|
66
|
-
<script src="js/stremio.js?v=2.3.
|
|
67
|
-
<script src="js/trakt.js?v=2.3.
|
|
68
|
-
<script src="js/keys.js?v=2.3.
|
|
69
|
-
<script src="js/focus.js?v=2.3.
|
|
70
|
-
<script src="js/tvapps.js?v=2.3.
|
|
71
|
-
<script src="js/player-core.js?v=2.3.
|
|
72
|
-
<script src="js/player-store.js?v=2.3.
|
|
73
|
-
<script src="js/player-lang.js?v=2.3.
|
|
74
|
-
<script src="js/player-quality.js?v=2.3.
|
|
75
|
-
<script src="js/player-subs.js?v=2.3.
|
|
76
|
-
<script src="js/player-audio.js?v=2.3.
|
|
77
|
-
<script src="js/player-controls.js?v=2.3.
|
|
78
|
-
<script src="js/player.js?v=2.3.
|
|
79
|
-
<script src="js/ytplay.js?v=2.3.
|
|
80
|
-
<script src="js/local.js?v=2.3.
|
|
81
|
-
<script src="js/downloads.js?v=2.3.
|
|
82
|
-
<script src="js/stremio-account.js?v=2.3.
|
|
83
|
-
<script src="js/view-core.js?v=2.3.
|
|
84
|
-
<script src="js/view-home.js?v=2.3.
|
|
85
|
-
<script src="js/view-guide.js?v=2.3.
|
|
86
|
-
<script src="js/view-detail.js?v=2.3.
|
|
87
|
-
<script src="js/view-search.js?v=2.3.
|
|
88
|
-
<script src="js/view-settings.js?v=2.3.
|
|
89
|
-
<script src="js/view-discover.js?v=2.3.
|
|
90
|
-
<script src="js/views.js?v=2.3.
|
|
91
|
-
<script src="js/app.js?v=2.3.
|
|
92
|
-
<script src="js/hubpreview.js?v=2.3.
|
|
57
|
+
<script src="js/polyfills.js?v=2.3.2"></script>
|
|
58
|
+
<script src="js/util.js?v=2.3.2"></script>
|
|
59
|
+
<script src="js/iptv.js?v=2.3.2"></script>
|
|
60
|
+
<script src="js/xtvod.js?v=2.3.2"></script>
|
|
61
|
+
<script src="js/stvod.js?v=2.3.2"></script>
|
|
62
|
+
<script src="js/jellyfin.js?v=2.3.2"></script>
|
|
63
|
+
<script src="js/plex.js?v=2.3.2"></script>
|
|
64
|
+
<script src="js/epg.js?v=2.3.2"></script>
|
|
65
|
+
<script src="js/youtube.js?v=2.3.2"></script>
|
|
66
|
+
<script src="js/stremio.js?v=2.3.2"></script>
|
|
67
|
+
<script src="js/trakt.js?v=2.3.2"></script>
|
|
68
|
+
<script src="js/keys.js?v=2.3.2"></script>
|
|
69
|
+
<script src="js/focus.js?v=2.3.2"></script>
|
|
70
|
+
<script src="js/tvapps.js?v=2.3.2"></script>
|
|
71
|
+
<script src="js/player-core.js?v=2.3.2"></script>
|
|
72
|
+
<script src="js/player-store.js?v=2.3.2"></script>
|
|
73
|
+
<script src="js/player-lang.js?v=2.3.2"></script>
|
|
74
|
+
<script src="js/player-quality.js?v=2.3.2"></script>
|
|
75
|
+
<script src="js/player-subs.js?v=2.3.2"></script>
|
|
76
|
+
<script src="js/player-audio.js?v=2.3.2"></script>
|
|
77
|
+
<script src="js/player-controls.js?v=2.3.2"></script>
|
|
78
|
+
<script src="js/player.js?v=2.3.2"></script>
|
|
79
|
+
<script src="js/ytplay.js?v=2.3.2"></script>
|
|
80
|
+
<script src="js/local.js?v=2.3.2"></script>
|
|
81
|
+
<script src="js/downloads.js?v=2.3.2"></script>
|
|
82
|
+
<script src="js/stremio-account.js?v=2.3.2"></script>
|
|
83
|
+
<script src="js/view-core.js?v=2.3.2"></script>
|
|
84
|
+
<script src="js/view-home.js?v=2.3.2"></script>
|
|
85
|
+
<script src="js/view-guide.js?v=2.3.2"></script>
|
|
86
|
+
<script src="js/view-detail.js?v=2.3.2"></script>
|
|
87
|
+
<script src="js/view-search.js?v=2.3.2"></script>
|
|
88
|
+
<script src="js/view-settings.js?v=2.3.2"></script>
|
|
89
|
+
<script src="js/view-discover.js?v=2.3.2"></script>
|
|
90
|
+
<script src="js/views.js?v=2.3.2"></script>
|
|
91
|
+
<script src="js/app.js?v=2.3.2"></script>
|
|
92
|
+
<script src="js/hubpreview.js?v=2.3.2"></script>
|
|
93
93
|
</body>
|
|
94
94
|
</html>
|
package/js/app.js
CHANGED
|
@@ -270,6 +270,27 @@ var App = (function () {
|
|
|
270
270
|
if (typeof Trakt !== 'undefined' && Trakt.isConnected()) {
|
|
271
271
|
Trakt.refreshCaches().then(function () { if (_current === 'home') { Views.renderHome(); } });
|
|
272
272
|
}
|
|
273
|
+
serverMarks();
|
|
274
|
+
}
|
|
275
|
+
// Your media servers' watched marks: read at launch, when a server is added, reloaded or
|
|
276
|
+
// removed, on coming back to the foreground and every MARKS_EVERY (each one again once it's
|
|
277
|
+
// 30 minutes old, js/jellyfin.js); when they changed, the cards on screen ticked again (Hide:
|
|
278
|
+
// Home redrawn, if it's there).
|
|
279
|
+
var MARKS_EVERY = 10 * 60000, _marksHooked = false;
|
|
280
|
+
function serverMarks() {
|
|
281
|
+
if (typeof Jellyfin === 'undefined' || !Jellyfin.refreshMarks) { return; }
|
|
282
|
+
if (!_marksHooked) {
|
|
283
|
+
_marksHooked = true;
|
|
284
|
+
Jellyfin.onChange(serverMarks);
|
|
285
|
+
if (typeof Plex !== 'undefined' && Plex.onChange) { Plex.onChange(serverMarks); }
|
|
286
|
+
document.addEventListener('visibilitychange', function () { if (!document.hidden) { serverMarks(); } }, false);
|
|
287
|
+
setInterval(serverMarks, MARKS_EVERY);
|
|
288
|
+
}
|
|
289
|
+
Jellyfin.refreshMarks().then(function (changed) {
|
|
290
|
+
if (!changed || !Views.watchedChanged) { return; }
|
|
291
|
+
Views.watchedChanged();
|
|
292
|
+
if (Stremio.getPrefs().watchedCards === 'hide' && _current === 'home' && !Player.isActive() && !Views.isModalOpen()) { Views.renderHome(); }
|
|
293
|
+
});
|
|
273
294
|
}
|
|
274
295
|
|
|
275
296
|
// On a cold launch the stylesheet fetch can race/fail, leaving the app unstyled.
|
package/js/jellyfin.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
and version, who's signed in and the sign-in it gave back (never the password).
|
|
5
5
|
- Emby speaks the same API family (Jellyfin started as its fork): its paths under /emby, per
|
|
6
6
|
user (/Users/<id>/Items…), its sign-in line as X-Emby-Authorization, api_key in links; no
|
|
7
|
-
Quick Connect
|
|
8
|
-
(KINDS: what differs).
|
|
7
|
+
Quick Connect or media segments, but intro and credits markers in its chapters, and its seek
|
|
8
|
+
pictures in a BIF file, not trickplay (KINDS: what differs).
|
|
9
9
|
- As local addons like Xtream's, one per kind ("Jellyfin", "Emby"): a catalog per Movies or
|
|
10
10
|
Shows library (Home rows, Discover, Search); a title the server knows the IMDb id of is a
|
|
11
11
|
card with that id (the usual title page, your addons' sources too), any other
|
|
@@ -15,7 +15,10 @@
|
|
|
15
15
|
of films and series with their ids, read when first needed and again after INDEX_FRESH_MS.
|
|
16
16
|
- Played as the file is (/Videos/<item>/stream.<container>?static=true: nothing converted),
|
|
17
17
|
its subtitle files with it; what you play is reported back (Jellyfin's sessions: where you
|
|
18
|
-
are, stopped, played), except during private viewing. Jellyfin 10.9 or newer, Emby 4.7.
|
|
18
|
+
are, stopped, played), except during private viewing. Jellyfin 10.9 or newer, Emby 4.7.
|
|
19
|
+
- Watched marks: what each server (Plex's too) has played, by the ids its titles go by here,
|
|
20
|
+
read at launch and after MARKS_FRESH_MS; Player weighs them against its own by time
|
|
21
|
+
(player-store), as Trakt's. */
|
|
19
22
|
var Jellyfin = (function () {
|
|
20
23
|
'use strict';
|
|
21
24
|
|
|
@@ -47,11 +50,30 @@ var Jellyfin = (function () {
|
|
|
47
50
|
function uid(srv) { return enc(srv.userId); }
|
|
48
51
|
|
|
49
52
|
// ---- Your servers ----
|
|
50
|
-
|
|
53
|
+
// (every one kept, on or off: Settings' list; servers: the ones on, all that's used)
|
|
54
|
+
function allServers(kind) {
|
|
51
55
|
var l = U.store.get(KEY, []);
|
|
52
56
|
return Array.isArray(l) ? l.filter(function (s) { return s && s.id && s.url && s.token && s.userId && (!kind || kindOf(s) === kind); }) : [];
|
|
53
57
|
}
|
|
58
|
+
function servers(kind) { return allServers(kind).filter(function (s) { return !s.off; }); }
|
|
54
59
|
function server(id) { return servers().filter(function (s) { return s.id === id; })[0] || null; }
|
|
60
|
+
function anyServer(id) { return allServers().filter(function (s) { return s.id === id; })[0] || null; }
|
|
61
|
+
// Turned off: its rows, sources and watched marks set aside, nothing asked of it, its sign-in
|
|
62
|
+
// kept; on again: its libraries read again.
|
|
63
|
+
function setOn(id, on) {
|
|
64
|
+
if (!anyServer(id)) { return; }
|
|
65
|
+
U.store.set(KEY, allServers().map(function (s) {
|
|
66
|
+
if (s.id !== id) { return s; }
|
|
67
|
+
var t = {};
|
|
68
|
+
Object.keys(s).forEach(function (k) { if (k !== 'off') { t[k] = s[k]; } });
|
|
69
|
+
if (!on) { t.off = true; }
|
|
70
|
+
return t;
|
|
71
|
+
}));
|
|
72
|
+
forget(id);
|
|
73
|
+
fillAll();
|
|
74
|
+
if (on) { delete _libsAsked[id]; _libsP[id] = refreshLibs(true, id); }
|
|
75
|
+
changed();
|
|
76
|
+
}
|
|
55
77
|
function isEnabled(kind) { return servers(kind).length > 0; }
|
|
56
78
|
function kindsOn() { return Object.keys(KINDS).filter(function (k) { return isEnabled(k); }); }
|
|
57
79
|
function deviceId() {
|
|
@@ -78,7 +100,10 @@ var Jellyfin = (function () {
|
|
|
78
100
|
if (json) { h['Content-Type'] = 'application/json'; }
|
|
79
101
|
return h;
|
|
80
102
|
}
|
|
81
|
-
|
|
103
|
+
// How long to wait for its answer: Settings › Media servers › Wait for a server (Normal: 20 s;
|
|
104
|
+
// Plex's too).
|
|
105
|
+
function waitMs() { var w = typeof Stremio !== 'undefined' && Stremio.getPrefs ? +Stremio.getPrefs().serverWait : 0; return w > 0 ? w * 1000 : 20000; }
|
|
106
|
+
function get(srv, path, max) { return U.getJSON(api(srv) + path, waitMs(), max || 4 * 1048576, null, headers(srv, srv.token)); }
|
|
82
107
|
function post(srv, path, body) { return U.getText(api(srv) + path, 15000, 65536, null, true, headers(srv, srv.token, true), body == null ? '' : JSON.stringify(body)); }
|
|
83
108
|
|
|
84
109
|
// An address as typed (192.168.0.50, http://nas:8096/web/…, …/emby/web/…): with http:// and
|
|
@@ -113,7 +138,7 @@ var Jellyfin = (function () {
|
|
|
113
138
|
// Signed in: kept (the same server and user again: in its place, its id kept).
|
|
114
139
|
function added(info, r) {
|
|
115
140
|
if (!r || !r.AccessToken || !r.User || !r.User.Id) { throw new Error(kindName(info) + ' didn’t sign in.'); }
|
|
116
|
-
var list =
|
|
141
|
+
var list = allServers(), old = list.filter(function (s) { return s.serverId === info.serverId && s.userId === '' + r.User.Id; })[0];
|
|
117
142
|
var srv = { id: old ? old.id : 's' + rand(8), url: info.url, kind: kindOf(info), serverId: info.serverId, name: info.name, version: info.version,
|
|
118
143
|
user: ('' + (r.User.Name || '')).slice(0, 60), userId: '' + r.User.Id, token: '' + r.AccessToken, at: Date.now() };
|
|
119
144
|
list = list.filter(function (s) { return s !== old; });
|
|
@@ -177,10 +202,10 @@ var Jellyfin = (function () {
|
|
|
177
202
|
}
|
|
178
203
|
// Sign out and remove: its sign-in ended on the server too (if it answers).
|
|
179
204
|
function remove(id) {
|
|
180
|
-
var srv =
|
|
205
|
+
var srv = anyServer(id);
|
|
181
206
|
if (!srv) { return; }
|
|
182
207
|
post(srv, '/Sessions/Logout', null).then(null, function () {});
|
|
183
|
-
U.store.set(KEY,
|
|
208
|
+
U.store.set(KEY, allServers().filter(function (s) { return s.id !== id; }));
|
|
184
209
|
var libs = libsAll();
|
|
185
210
|
delete libs[id];
|
|
186
211
|
U.store.set(LIBS_KEY, libs);
|
|
@@ -220,7 +245,7 @@ var Jellyfin = (function () {
|
|
|
220
245
|
});
|
|
221
246
|
if (!server(srv.id)) { return; } // (removed meanwhile)
|
|
222
247
|
var all = libsAll(), keep = {}, before = JSON.stringify(all[srv.id] && all[srv.id].list);
|
|
223
|
-
|
|
248
|
+
allServers().forEach(function (s) { if (all[s.id]) { keep[s.id] = all[s.id]; } });
|
|
224
249
|
keep[srv.id] = { at: Date.now(), list: list };
|
|
225
250
|
_libs = keep;
|
|
226
251
|
U.store.set(LIBS_KEY, keep);
|
|
@@ -386,26 +411,36 @@ var Jellyfin = (function () {
|
|
|
386
411
|
var x = _index[srv.id];
|
|
387
412
|
if (x && x.map && (x.p || Date.now() - x.at < INDEX_FRESH_MS)) { return Promise.resolve(x.map); }
|
|
388
413
|
if (x && x.p) { return x.p; }
|
|
389
|
-
var p = get(srv, K(srv).items(uid(srv)) + 'recursive=true&includeItemTypes=Movie,Series&fields=ProviderIds&enableImages=false&enableUserData=
|
|
390
|
-
var map = { __ids: {} }; // (__ids: an item's IMDb id, for Next up's cards)
|
|
414
|
+
var p = get(srv, K(srv).items(uid(srv)) + 'recursive=true&includeItemTypes=Movie,Series&fields=ProviderIds&enableImages=false&enableUserData=true&enableTotalRecordCount=false', 16 * 1048576).then(function (r) {
|
|
415
|
+
var map = { __ids: {}, __tm: {}, __played: [] }; // (__ids, __tm: an item's IMDb, TMDB id, for Next up's cards and watched marks; __played: its played films and shows)
|
|
391
416
|
function add(k, v) { (map[k] = map[k] || []).push(v); }
|
|
392
417
|
U.listOf(r && r.Items, 100000).forEach(function (it) {
|
|
393
418
|
var t = it.Type === 'Movie' ? 'movie' : it.Type === 'Series' ? 'series' : '', tt = imdbOf(it), tm = tmdbOf(it);
|
|
394
419
|
if (!t || !it.Id) { return; }
|
|
395
420
|
if (tt) { add(t + '|' + tt, '' + it.Id); map.__ids['' + it.Id] = tt; }
|
|
396
|
-
if (tm) { add(t + '|tmdb:' + tm, '' + it.Id); }
|
|
421
|
+
if (tm) { add(t + '|tmdb:' + tm, '' + it.Id); map.__tm['' + it.Id] = tm; }
|
|
422
|
+
if (it.UserData && it.UserData.Played) { map.__played.push({ t: t, ids: titleIds(map, (t === 'movie' ? 'jfm.' : 'jfs.') + srv.id + '.', '' + it.Id), at: Date.parse(it.UserData.LastPlayedDate || '') || 1 }); }
|
|
397
423
|
});
|
|
398
424
|
if (_index[srv.id] && _index[srv.id].p === p) { _index[srv.id] = { at: Date.now(), map: map }; }
|
|
399
425
|
return map;
|
|
400
426
|
}, function (e) {
|
|
401
427
|
U.log('jellyfin', '“' + srv.name + '” (' + kindName(srv) + '): its titles couldn’t be read (' + U.problem(e) + ')');
|
|
402
|
-
var old = _index[srv.id], map = (old && old.map) || { __ids: {} };
|
|
428
|
+
var old = _index[srv.id], map = (old && old.map) || { __ids: {}, __tm: {}, __played: [], __err: true }; // (__err: never read)
|
|
403
429
|
if (old && old.p === p) { _index[srv.id] = { at: Date.now() - INDEX_FRESH_MS + INDEX_RETRY_MS, map: map }; } // (asked again in a minute)
|
|
404
430
|
return map;
|
|
405
431
|
});
|
|
406
432
|
_index[srv.id] = { at: x ? x.at : 0, map: x ? x.map : null, p: p };
|
|
407
433
|
return x && x.map ? Promise.resolve(x.map) : p;
|
|
408
434
|
}
|
|
435
|
+
// The list as it is now: one being read again waited for (index answers with the old one).
|
|
436
|
+
function indexFresh(srv) { var p = index(srv), x = _index[srv.id]; return x && x.p ? x.p : p; }
|
|
437
|
+
// The ids a server's title goes by here: its IMDb and TMDB ones, and its own (own: its prefix).
|
|
438
|
+
function titleIds(map, own, id) {
|
|
439
|
+
var l = [own + id];
|
|
440
|
+
if (map.__ids[id]) { l.unshift(map.__ids[id]); }
|
|
441
|
+
if (map.__tm && map.__tm[id]) { l.push('tmdb:' + map.__tm[id]); }
|
|
442
|
+
return l;
|
|
443
|
+
}
|
|
409
444
|
function copies(type, id, kind) {
|
|
410
445
|
var key = '', season = null, episode = null;
|
|
411
446
|
if (type === 'movie') { key = /^(tt\d+|tmdb:\d+)$/.test('' + id) ? '' + id : ''; }
|
|
@@ -423,6 +458,96 @@ var Jellyfin = (function () {
|
|
|
423
458
|
})).then(flat);
|
|
424
459
|
}
|
|
425
460
|
|
|
461
|
+
// ---- Watched marks (Jellyfin, Emby; Plex's from js/plex.js) ----
|
|
462
|
+
// { 'movie:<id>': when, 'series:<id>': when (the whole show), 'series:<show>:<s>:<e>': when }
|
|
463
|
+
// from [{ t, ids, at, s?, e? }].
|
|
464
|
+
var MARKS_MAX = 50000;
|
|
465
|
+
function marksFrom(list) {
|
|
466
|
+
var out = {}, n = 0;
|
|
467
|
+
(list || []).forEach(function (x) {
|
|
468
|
+
(x.ids || []).forEach(function (id) {
|
|
469
|
+
var k = x.t + ':' + id + (x.s != null ? ':' + x.s + ':' + x.e : '');
|
|
470
|
+
if (out[k] == null) { if (n >= MARKS_MAX) { return; } n++; }
|
|
471
|
+
out[k] = Math.max(out[k] || 0, x.at > 0 ? x.at : 1);
|
|
472
|
+
});
|
|
473
|
+
});
|
|
474
|
+
return out;
|
|
475
|
+
}
|
|
476
|
+
// Its played films and shows (its list of titles) and episodes.
|
|
477
|
+
function jfMarks(srv) {
|
|
478
|
+
return Promise.all([indexFresh(srv), get(srv, K(srv).items(uid(srv)) + 'recursive=true&includeItemTypes=Episode&isPlayed=true&enableImages=false&enableTotalRecordCount=false', 16 * 1048576)]).then(function (r) {
|
|
479
|
+
var map = r[0], list = map.__played.slice();
|
|
480
|
+
if (map.__err) { throw new Error('its titles couldn’t be read'); }
|
|
481
|
+
U.listOf(r[1] && r[1].Items, 100000, function (e) { return e.SeriesId && e.ParentIndexNumber >= 0 && e.IndexNumber >= 0 && (!e.UserData || e.UserData.Played !== false); }).forEach(function (e) {
|
|
482
|
+
list.push({ t: 'series', ids: titleIds(map, 'jfs.' + srv.id + '.', '' + e.SeriesId), s: +e.ParentIndexNumber, e: +e.IndexNumber, at: Date.parse((e.UserData && e.UserData.LastPlayedDate) || '') || 1 });
|
|
483
|
+
});
|
|
484
|
+
return marksFrom(list);
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
// Every server's, kept in the TV's database (U.store when it won't take them), read into
|
|
488
|
+
// memory at launch (watchedAt is synchronous; until then, none).
|
|
489
|
+
var MARKS_KEY = 'stremiok.media.watched', MARKS_FRESH_MS = 30 * 60000;
|
|
490
|
+
var _marks = null, _all = {}, _marksP = null, _marksSaved = null;
|
|
491
|
+
function merge() {
|
|
492
|
+
var all = {};
|
|
493
|
+
Object.keys(_marks || {}).forEach(function (id) {
|
|
494
|
+
var m = (_marks[id] && _marks[id].m) || {};
|
|
495
|
+
Object.keys(m).forEach(function (k) { if (!(all[k] >= m[k])) { all[k] = m[k]; } });
|
|
496
|
+
});
|
|
497
|
+
_all = all;
|
|
498
|
+
}
|
|
499
|
+
var _marksRead = (U.bigStore ? U.bigStore.get(MARKS_KEY) : Promise.resolve(null)).then(function (m) {
|
|
500
|
+
if (!m || typeof m !== 'object') { m = U.store.get(MARKS_KEY, null, true); }
|
|
501
|
+
if (m && typeof m === 'object' && !_marks) { _marks = m; _marksSaved = JSON.stringify(m); merge(); }
|
|
502
|
+
}, function () {});
|
|
503
|
+
function saveMarks() {
|
|
504
|
+
var text = JSON.stringify(_marks);
|
|
505
|
+
if (text === _marksSaved) { return; }
|
|
506
|
+
_marksSaved = text;
|
|
507
|
+
if (!U.bigStore) { U.store.set(MARKS_KEY, _marks); return; }
|
|
508
|
+
U.bigStore.set(MARKS_KEY, _marks).then(function (ok) {
|
|
509
|
+
if (ok) { return; }
|
|
510
|
+
U.bigStore.remove(MARKS_KEY, true);
|
|
511
|
+
U.store.set(MARKS_KEY, _marks);
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
function markSources() {
|
|
515
|
+
var l = servers().map(function (s) { return { id: s.id, name: s.name, read: function () { return jfMarks(s); } }; });
|
|
516
|
+
if (typeof Plex !== 'undefined' && Plex.servers && Plex.marksOf) {
|
|
517
|
+
Plex.servers().forEach(function (s) { l.push({ id: s.id, name: s.name, read: function () { return Plex.marksOf(s); } }); });
|
|
518
|
+
}
|
|
519
|
+
return l;
|
|
520
|
+
}
|
|
521
|
+
// Read again where older than MARKS_FRESH_MS (force: all), a removed server's dropped; a
|
|
522
|
+
// promise of whether they changed.
|
|
523
|
+
function refreshMarks(force) {
|
|
524
|
+
if (_marksP) { return _marksP; }
|
|
525
|
+
_marksP = _marksRead.then(function () {
|
|
526
|
+
var was = _marks || {}, list = markSources(), next = {}, changed = false;
|
|
527
|
+
if (!list.length && !Object.keys(was).length) { return false; } // (no servers, none kept: nothing saved)
|
|
528
|
+
Object.keys(was).forEach(function (id) { if (!list.some(function (x) { return x.id === id; })) { changed = true; } });
|
|
529
|
+
return Promise.all(list.map(function (x) {
|
|
530
|
+
var old = was[x.id];
|
|
531
|
+
if (old && !force && Date.now() - old.at < MARKS_FRESH_MS) { next[x.id] = old; return null; }
|
|
532
|
+
return x.read().then(function (m) {
|
|
533
|
+
if (!old || JSON.stringify(m) !== JSON.stringify(old.m)) { changed = true; }
|
|
534
|
+
next[x.id] = { at: Date.now(), m: m };
|
|
535
|
+
}, function (e) {
|
|
536
|
+
if (old) { next[x.id] = old; }
|
|
537
|
+
U.log('jellyfin', '“' + x.name + '”: its watched marks couldn’t be read (' + U.problem(e) + ')');
|
|
538
|
+
});
|
|
539
|
+
})).then(function () {
|
|
540
|
+
_marks = next;
|
|
541
|
+
merge();
|
|
542
|
+
saveMarks();
|
|
543
|
+
return changed;
|
|
544
|
+
});
|
|
545
|
+
}).then(function (ch) { _marksP = null; return ch; }, function () { _marksP = null; return false; });
|
|
546
|
+
return _marksP;
|
|
547
|
+
}
|
|
548
|
+
// When a server has it played (ms; 0: not, or not known): the latest of them.
|
|
549
|
+
function watchedAt(type, id) { return _all[type + ':' + id] || 0; }
|
|
550
|
+
|
|
426
551
|
// ---- Sources ----
|
|
427
552
|
var EXT = { mkv: 'mkv', matroska: 'mkv', webm: 'webm', mp4: 'mp4', mov: 'mp4', m4v: 'mp4', avi: 'avi', mpegts: 'ts', ts: 'ts', m2ts: 'm2ts', mpeg: 'mpg', mpg: 'mpg', flv: 'flv', wmv: 'wmv', asf: 'wmv', ogg: 'ogv' };
|
|
428
553
|
function extOf(c) { var f = ('' + (c || '')).toLowerCase().split(',')[0].trim(); return EXT[f] || (/^[a-z0-9]{2,5}$/.test(f) ? f : 'mkv'); }
|
|
@@ -444,7 +569,7 @@ var Jellyfin = (function () {
|
|
|
444
569
|
behaviorHints: { filename: file, videoSize: size || undefined, bingeGroup: 'stremiok-jellyfin-' + srv.id },
|
|
445
570
|
_jf: placeOf({ srv: srv.id, kind: kindOf(srv), item: '' + it.Id, ms: '' + ms.Id }, it.UserData)
|
|
446
571
|
};
|
|
447
|
-
var ch = chapterSegments(it), mk = markerSegments(it), named = namedChapters(it), tp = trickplayOf(srv, it, ms);
|
|
572
|
+
var ch = chapterSegments(it), mk = markerSegments(it), named = namedChapters(it), tp = trickplayOf(srv, it, ms) || bifOf(srv, it, ms, v);
|
|
448
573
|
if (ch) { st._jf.ch = ch; }
|
|
449
574
|
if (mk) { st._jf.mk = mk; }
|
|
450
575
|
if (named) { st._jf.chapters = named; }
|
|
@@ -529,10 +654,74 @@ var Jellyfin = (function () {
|
|
|
529
654
|
return { w: +best.Width, h: +best.Height, cols: +best.TileWidth, rows: +best.TileHeight, n: +best.ThumbnailCount, every: +best.Interval,
|
|
530
655
|
base: api(srv) + '/Videos/' + enc(it.Id) + '/Trickplay/' + (+best.Width) + '/', q: '.jpg?mediaSourceId=' + enc(ms.Id) + '&' + K(srv).key + '=' + enc(srv.token) };
|
|
531
656
|
}
|
|
657
|
+
// Emby's seek pictures: its BIF file (the Roku format: the JPEGs and when each is), 320 wide,
|
|
658
|
+
// read at the first ◀ ▶ (bifAt). Emby makes them where the library's thumbnail extraction is on.
|
|
659
|
+
function bifOf(srv, it, ms, v) {
|
|
660
|
+
if (kindOf(srv) !== 'emby' || !(+it.RunTimeTicks > 0)) { return null; }
|
|
661
|
+
var w = +(v && v.Width) || 0, h = +(v && v.Height) || 0;
|
|
662
|
+
return { bif: api(srv) + '/Videos/' + enc(it.Id) + '/index.bif?width=320&mediaSourceId=' + enc(ms.Id) + '&' + K(srv).key + '=' + enc(srv.token),
|
|
663
|
+
w: 320, h: w > 0 && h > 0 ? Math.round(320 * h / w) : 180, cols: 1, rows: 1, every: 10000, n: 1 };
|
|
664
|
+
}
|
|
665
|
+
// The file being played's (one at a time): { url, p } while it's read, then { url, frames:
|
|
666
|
+
// [{ t (ms), a, b (where its JPEG is) }], bytes, pics: the latest pictures' links }, or
|
|
667
|
+
// { url, failed }.
|
|
668
|
+
var BIF_MAX = 40 * 1048576, BIF_PICS = 12, BIF_MAGIC = [0x89, 0x42, 0x49, 0x46, 0x0d, 0x0a, 0x1a, 0x0a], _bif = null;
|
|
669
|
+
function parseBif(b) {
|
|
670
|
+
for (var i = 0; i < 8; i++) { if (b[i] !== BIF_MAGIC[i]) { return null; } }
|
|
671
|
+
function u32(o) { return (b[o] | (b[o + 1] << 8) | (b[o + 2] << 16) | (b[o + 3] << 24)) >>> 0; }
|
|
672
|
+
var n = u32(12), every = u32(16) || 1000, out = [];
|
|
673
|
+
for (var k = 0; k < n && 79 + k * 8 < b.length; k++) {
|
|
674
|
+
var t = u32(64 + k * 8), a = u32(68 + k * 8), z = u32(76 + k * 8);
|
|
675
|
+
if (t === 0xffffffff) { break; }
|
|
676
|
+
if (z > a && z <= b.length) { out.push({ t: t * every, a: a, b: z }); }
|
|
677
|
+
}
|
|
678
|
+
return out;
|
|
679
|
+
}
|
|
680
|
+
function dropBif() {
|
|
681
|
+
if (_bif && _bif.pics) { Object.keys(_bif.pics).forEach(function (k) { try { URL.revokeObjectURL(_bif.pics[k]); } catch (e) {} }); }
|
|
682
|
+
_bif = null;
|
|
683
|
+
}
|
|
684
|
+
function loadBif(tp) {
|
|
685
|
+
dropBif();
|
|
686
|
+
var b = { url: tp.bif };
|
|
687
|
+
_bif = b;
|
|
688
|
+
b.p = U.getBytes(tp.bif, 30000, BIF_MAX, true).then(function (bytes) {
|
|
689
|
+
var frames = parseBif(bytes);
|
|
690
|
+
if (_bif !== b) { return; }
|
|
691
|
+
if (!frames || !frames.length) { throw new Error('not a BIF file'); }
|
|
692
|
+
b.frames = frames; b.bytes = bytes; b.pics = {}; b.order = [];
|
|
693
|
+
if (frames.length > 1) { tp.every = Math.max(1000, Math.round((frames[frames.length - 1].t - frames[0].t) / (frames.length - 1))); }
|
|
694
|
+
tp.n = frames.length;
|
|
695
|
+
}).then(null, function (e) {
|
|
696
|
+
if (_bif !== b) { return; }
|
|
697
|
+
b.failed = true;
|
|
698
|
+
U.log('jellyfin', 'Emby has no seek pictures for this file (' + (/HTTP 404/.test(e && e.message) ? 'none made: the library’s thumbnail extraction' : U.problem(e)) + ')');
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
function bifPic(i) {
|
|
702
|
+
var b = _bif, f = b.frames[i];
|
|
703
|
+
if (b.pics[i]) { return b.pics[i]; }
|
|
704
|
+
var url = null;
|
|
705
|
+
try { url = URL.createObjectURL(new Blob([b.bytes.subarray(f.a, f.b)], { type: 'image/jpeg' })); } catch (e) { return null; }
|
|
706
|
+
b.pics[i] = url;
|
|
707
|
+
b.order.push(i);
|
|
708
|
+
if (b.order.length > BIF_PICS) { var old = b.order.shift(); try { URL.revokeObjectURL(b.pics[old]); } catch (e2) {} delete b.pics[old]; }
|
|
709
|
+
return url;
|
|
710
|
+
}
|
|
711
|
+
function bifAt(tp, sec) {
|
|
712
|
+
if (!_bif || _bif.url !== tp.bif) { loadBif(tp); return null; }
|
|
713
|
+
var f = _bif.frames;
|
|
714
|
+
if (!f) { return null; }
|
|
715
|
+
var ms = sec * 1000, lo = 0, hi = f.length - 1;
|
|
716
|
+
while (lo < hi) { var mid = (lo + hi + 1) >> 1; if (f[mid].t <= ms) { lo = mid; } else { hi = mid - 1; } }
|
|
717
|
+
var url = bifPic(lo);
|
|
718
|
+
return url ? { url: url, x: 0, y: 0, w: tp.w, h: tp.h, cols: 1, rows: 1 } : null;
|
|
719
|
+
}
|
|
532
720
|
// The seek picture for a moment (seconds): its tile's link and where in it, or null.
|
|
533
|
-
// (tp.one: a picture a link, base + its moment in ms, as Plex's are)
|
|
721
|
+
// (tp.one: a picture a link, base + its moment in ms, as Plex's are; tp.bif: Emby's file)
|
|
534
722
|
function trickplayAt(tp, sec) {
|
|
535
723
|
if (!tp || !(sec >= 0)) { return null; }
|
|
724
|
+
if (tp.bif) { return bifAt(tp, sec); }
|
|
536
725
|
var i = Math.min(tp.n - 1, Math.floor(sec * 1000 / tp.every)), per = tp.cols * tp.rows, at = i % per;
|
|
537
726
|
if (tp.one) { return { url: tp.base + (i * tp.every) + tp.q, x: 0, y: 0, w: tp.w, h: tp.h, cols: 1, rows: 1 }; }
|
|
538
727
|
return { url: tp.base + Math.floor(i / per) + tp.q, x: (at % tp.cols) * tp.w, y: Math.floor(at / tp.cols) * tp.h, w: tp.w, h: tp.h, cols: tp.cols, rows: tp.rows };
|
|
@@ -622,6 +811,7 @@ var Jellyfin = (function () {
|
|
|
622
811
|
if (srv) { post(srv, K(srv).played(uid(srv), enc(jf.item)), null).then(null, function (e) { U.log('jellyfin', '“' + srv.name + '”: not marked played (' + U.problem(e) + ')'); }); }
|
|
623
812
|
return;
|
|
624
813
|
}
|
|
814
|
+
if (ev === 'stop') { dropBif(); } // (Emby's seek pictures: given up with the playback)
|
|
625
815
|
if (_play && (!srv || _play.ctx !== ctx || _play.item !== jf.item || _play.ms !== jf.ms)) { stopNow(); } // (another playback, or another source)
|
|
626
816
|
if (!srv || ev === 'stop') { if (ev === 'stop') { stopNow(cur); } return; }
|
|
627
817
|
if (!_play) { _play = { ctx: ctx, srv: srv.id, item: jf.item, ms: jf.ms, sid: rand(32), started: false, sent: 0, paused: false, cur: 0 }; }
|
|
@@ -633,10 +823,10 @@ var Jellyfin = (function () {
|
|
|
633
823
|
}
|
|
634
824
|
|
|
635
825
|
return {
|
|
636
|
-
servers: servers, server: server, isEnabled: isEnabled, onChange: onChange, normAddress: normAddress, addressProblem: addressProblem, probe: probe,
|
|
826
|
+
servers: servers, allServers: allServers, server: server, setOn: setOn, isEnabled: isEnabled, onChange: onChange, normAddress: normAddress, addressProblem: addressProblem, probe: probe,
|
|
637
827
|
signIn: signIn, quickConnect: quickConnect, remove: remove, reload: reload, libraries: libsOf, synthAddon: synthAddon, synthAddons: synthAddons, kindsOn: kindsOn,
|
|
638
828
|
kindName: kindName, nameOfId: nameOfId, catalog: catalog, meta: meta, streams: streams, isJellyfinId: isJellyfinId, onPlayer: onPlayer, resumeFor: resumeFor,
|
|
639
|
-
segments: segments, trickplayAt: trickplayAt, sourceKind: sourceKind,
|
|
640
|
-
shared: { chapterSegments: chapterSegments, namedChapters: namedChapters } // (Plex's chapters read the same way)
|
|
829
|
+
segments: segments, trickplayAt: trickplayAt, waitMs: waitMs, sourceKind: sourceKind, refreshMarks: refreshMarks, watchedAt: watchedAt,
|
|
830
|
+
shared: { chapterSegments: chapterSegments, namedChapters: namedChapters, marksFrom: marksFrom } // (Plex's chapters and watched marks read the same way)
|
|
641
831
|
};
|
|
642
832
|
})();
|
package/js/player-audio.js
CHANGED
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
function settleMs() { return getAudioCfg().wait * 1000; }
|
|
39
39
|
var _reseek = null; // { at, mark: S.lastSeekAt when it was asked }
|
|
40
40
|
|
|
41
|
-
function resetAudio() { _audioIdx = null; _audioPending = false; _reseek = null; }
|
|
41
|
+
function resetAudio() { _audioIdx = null; _audioPending = false; _reseek = null; _held = null; }
|
|
42
42
|
// Playback is starting. The track is picked only once it's running (play-time ticks):
|
|
43
43
|
// selected before play(), the TV records the choice but keeps decoding the default
|
|
44
44
|
// track, and then ignores re-selecting it.
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
// TV's player. The menu still offers the others.)
|
|
48
48
|
function audioOnStart() { _audioPending = !(S.ctx && S.ctx.yt); _audioSteadySince = 0; }
|
|
49
49
|
function audioOnTick() {
|
|
50
|
+
if (_held && !busyWhy()) { selectAudio(_held.index, _held.message, _held.force); } // (a switch held: made now it plays)
|
|
50
51
|
if (_audioPending) { maybeApplyAudio(); }
|
|
51
52
|
if (_reseek && Date.now() >= _reseek.at) {
|
|
52
53
|
var r = _reseek; _reseek = null;
|
|
@@ -205,13 +206,21 @@
|
|
|
205
206
|
// it switch for real (the manual workaround, in one press).
|
|
206
207
|
function selectAudio(index, message, force) {
|
|
207
208
|
if (P.useAV) {
|
|
209
|
+
var why = busyWhy();
|
|
210
|
+
if (why) { hold(index, message, force, why); return; }
|
|
208
211
|
if (force) {
|
|
209
212
|
var tracks = getAudioTracks();
|
|
210
213
|
for (var k = 0; k < tracks.length; k++) {
|
|
211
214
|
if (tracks[k].index !== index) { setAudioTrack(tracks[k].index); break; }
|
|
212
215
|
}
|
|
213
216
|
}
|
|
214
|
-
|
|
217
|
+
var asked = Date.now();
|
|
218
|
+
U.log('player', 'Audio switch to track ' + index + (force ? ' (again)' : '') + '. The TV lists: ' + rawAudio() + '. Playing: ' + playingRaw());
|
|
219
|
+
if (!setAudioTrack(index)) { hold(index, message, false, 'refused'); return; }
|
|
220
|
+
_held = null;
|
|
221
|
+
setTimeout(function () { // (what the TV says it plays once it's had time: a switch it took without following shows here)
|
|
222
|
+
if (S.active && _audioIdx === index && Date.now() - asked < 10000) { U.log('player', 'Audio switch to track ' + index + ': the TV now plays ' + playingRaw()); }
|
|
223
|
+
}, SWITCH_CHECK_MS);
|
|
215
224
|
// A seek makes the player reload audio from the selected track instead of carrying
|
|
216
225
|
// on with what it had buffered (movies/episodes; live can't seek): now, or once
|
|
217
226
|
// SETTLE_MS have passed since the start / resume or a jump (see above).
|
|
@@ -241,9 +250,57 @@
|
|
|
241
250
|
doAVSeek(back, 0);
|
|
242
251
|
}
|
|
243
252
|
|
|
253
|
+
// true: the TV took it (asked as a number, else as text); false: it refused both.
|
|
244
254
|
function setAudioTrack(index) {
|
|
245
|
-
try { avplay.setSelectTrack('AUDIO', index); }
|
|
246
|
-
catch (e) {
|
|
255
|
+
try { avplay.setSelectTrack('AUDIO', index); return true; }
|
|
256
|
+
catch (e) {
|
|
257
|
+
try { avplay.setSelectTrack('AUDIO', '' + index); return true; }
|
|
258
|
+
catch (e2) { U.log('player', 'Audio track ' + index + ' refused by the TV: ' + trackError(e2) + ' (as a number: ' + trackError(e) + ')'); return false; }
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
// The TV refuses a switch while paused or while a jump is still going on (it says it plays
|
|
262
|
+
// meanwhile), PLAYER_ERROR_INVALID_OPERATION (2.3.0.2, issue 17: the menu ticked the track,
|
|
263
|
+
// the audio stayed). Such a switch is held (_held) and made at the first play-time report
|
|
264
|
+
// once it plays on, steadily; one it still refuses, held again, up to HOLD_TRIES times.
|
|
265
|
+
var _held = null; // { index, message, force, tries }
|
|
266
|
+
var SEEK_BUSY_MS = 1500, HOLD_TRIES = 4;
|
|
267
|
+
function busyWhy() {
|
|
268
|
+
if (P.isPaused()) { return 'paused'; }
|
|
269
|
+
if (S.buffering || S.pendingSeek != null) { return 'buffering'; }
|
|
270
|
+
if (Date.now() - (S.lastSeekAt || 0) < SEEK_BUSY_MS) { return 'jumping'; }
|
|
271
|
+
return '';
|
|
272
|
+
}
|
|
273
|
+
function hold(index, message, force, why) {
|
|
274
|
+
var tries = _held && _held.index === index ? _held.tries + 1 : 0;
|
|
275
|
+
if (tries >= HOLD_TRIES) {
|
|
276
|
+
_held = null;
|
|
277
|
+
U.log('player', 'Audio switch to track ' + index + ': still refused after ' + HOLD_TRIES + ' tries, left');
|
|
278
|
+
U.toast('The TV didn’t switch the audio: choose it again', 4000);
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
var first = !_held || _held.index !== index;
|
|
282
|
+
_held = { index: index, message: message, force: force, tries: tries };
|
|
283
|
+
_audioIdx = index; // (the menu ticks it meanwhile)
|
|
284
|
+
if (first) { U.log('player', 'Audio switch to track ' + index + ' held (' + why + '): made once it plays on'); }
|
|
285
|
+
if (first && why === 'paused') { U.toast((message || 'Audio track changed') + ': when you carry on', 3000); }
|
|
286
|
+
}
|
|
287
|
+
// ----- Diagnostics: what the TV said of its audio tracks around a switch -----
|
|
288
|
+
var SWITCH_CHECK_MS = 2500;
|
|
289
|
+
function trackError(e) { return ('' + ((e && (e.name || e.code)) || '') + ' ' + ((e && e.message) || '')).replace(/\s+/g, ' ').trim().slice(0, 120) || 'no reason given'; }
|
|
290
|
+
function rawOf(t) { return t.index + ' ' + ('' + (t.extra_info == null ? '' : t.extra_info)).replace(/\s+/g, ' ').slice(0, 160); }
|
|
291
|
+
// its audio tracks as it lists them (getTotalTrackInfo): index, then what it says of each
|
|
292
|
+
function rawAudio() {
|
|
293
|
+
try {
|
|
294
|
+
var l = (avplay.getTotalTrackInfo() || []).filter(function (t) { return t && ('' + t.type).toUpperCase() === 'AUDIO'; }).map(rawOf);
|
|
295
|
+
return l.length ? l.join(' | ') : 'none';
|
|
296
|
+
} catch (e) { return '(unreadable: ' + trackError(e) + ')'; }
|
|
297
|
+
}
|
|
298
|
+
// the audio track it says is playing (getCurrentStreamInfo)
|
|
299
|
+
function playingRaw() {
|
|
300
|
+
try {
|
|
301
|
+
var now = (avplay.getCurrentStreamInfo() || []).filter(function (t) { return t && ('' + t.type).toUpperCase() === 'AUDIO'; });
|
|
302
|
+
return now.length ? rawOf(now[0]) : 'none reported';
|
|
303
|
+
} catch (e) { return '(unreadable: ' + trackError(e) + ')'; }
|
|
247
304
|
}
|
|
248
305
|
|
|
249
306
|
// Tracks sorted by language (preferred languages first) and named in full, so the
|
package/js/player-store.js
CHANGED
|
@@ -11,10 +11,15 @@
|
|
|
11
11
|
var WATCHED_KEY = 'stremiok.watched';
|
|
12
12
|
function watchedAll() { return U.store.get(WATCHED_KEY, {}) || {}; }
|
|
13
13
|
// A mark made here: watched at (ms, > 0), or not watched at (−ms; false: an older "not
|
|
14
|
-
// watched", at 0). Trakt's history (when connected)
|
|
15
|
-
// watched here: watched; marked not watched here: watched only if
|
|
16
|
-
// since (on another device); no mark here: as
|
|
17
|
-
|
|
14
|
+
// watched", at 0). Trakt's history (when connected) and your media servers' marks are weighed
|
|
15
|
+
// against it by time: marked watched here: watched; marked not watched here: watched only if
|
|
16
|
+
// Trakt or a server has it watched since (on another device); no mark here: as they have it.
|
|
17
|
+
// null: none knows it.
|
|
18
|
+
function traktAt(type, id) {
|
|
19
|
+
var t = (typeof Trakt !== 'undefined' && Trakt.isConnected && Trakt.isConnected() && Trakt.watchedAt) ? Trakt.watchedAt(type, id) : 0;
|
|
20
|
+
var s = (typeof Jellyfin !== 'undefined' && Jellyfin.watchedAt) ? Jellyfin.watchedAt(type, id) : 0; // (Jellyfin, Emby and Plex: js/jellyfin.js)
|
|
21
|
+
return Math.max(t || 0, s || 0);
|
|
22
|
+
}
|
|
18
23
|
function watchedState(type, id) {
|
|
19
24
|
var v = watchedAll()[type + ':' + id], t = traktAt(type, id);
|
|
20
25
|
if (typeof v === 'number' && v > 0) { return true; }
|
package/js/plex.js
CHANGED
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
- Played as the file is (a part's own link: nothing converted), its SRT / VTT files with it;
|
|
14
14
|
what you play goes back to Plex (/:/timeline; watched: /:/scrobble), except during private
|
|
15
15
|
viewing. Sources carry _jf (kind 'plex'), as a Jellyfin one does: place, chapters, markers,
|
|
16
|
-
seek pictures.
|
|
16
|
+
seek pictures.
|
|
17
|
+
- Its watched marks (marksOf, kept with Jellyfin's and Emby's in js/jellyfin.js): films with a
|
|
18
|
+
viewCount, shows whose episodes are all watched, and each watched episode. */
|
|
17
19
|
var Plex = (function () {
|
|
18
20
|
'use strict';
|
|
19
21
|
|
|
@@ -32,11 +34,28 @@ var Plex = (function () {
|
|
|
32
34
|
function mc(r) { return (r && r.MediaContainer) || {}; } // (every Plex answer is in one)
|
|
33
35
|
|
|
34
36
|
// ---- Your servers ----
|
|
35
|
-
|
|
37
|
+
// (every one kept, on or off; servers: the ones on, as js/jellyfin.js)
|
|
38
|
+
function allServers() {
|
|
36
39
|
var l = U.store.get(KEY, []);
|
|
37
40
|
return Array.isArray(l) ? l.filter(function (s) { return s && s.id && s.url && s.token && s.machineId; }) : [];
|
|
38
41
|
}
|
|
42
|
+
function servers() { return allServers().filter(function (s) { return !s.off; }); }
|
|
39
43
|
function server(id) { return servers().filter(function (s) { return s.id === id; })[0] || null; }
|
|
44
|
+
function anyServer(id) { return allServers().filter(function (s) { return s.id === id; })[0] || null; }
|
|
45
|
+
function setOn(id, on) {
|
|
46
|
+
if (!anyServer(id)) { return; }
|
|
47
|
+
U.store.set(KEY, allServers().map(function (s) {
|
|
48
|
+
if (s.id !== id) { return s; }
|
|
49
|
+
var t = {};
|
|
50
|
+
Object.keys(s).forEach(function (k) { if (k !== 'off') { t[k] = s[k]; } });
|
|
51
|
+
if (!on) { t.off = true; }
|
|
52
|
+
return t;
|
|
53
|
+
}));
|
|
54
|
+
forget(id);
|
|
55
|
+
fillCatalogs();
|
|
56
|
+
if (on) { delete _libsAsked[id]; refreshLibs(true, id); }
|
|
57
|
+
changed();
|
|
58
|
+
}
|
|
40
59
|
function isEnabled() { return servers().length > 0; }
|
|
41
60
|
function deviceId() {
|
|
42
61
|
var d = U.store.get(DEV_KEY, '');
|
|
@@ -58,7 +77,7 @@ var Plex = (function () {
|
|
|
58
77
|
if (token) { h['X-Plex-Token'] = token; }
|
|
59
78
|
return h;
|
|
60
79
|
}
|
|
61
|
-
function get(srv, path, max) { return U.getJSON(srv.url + path, 20000, max || 4 * 1048576, null, headers(srv.token)); }
|
|
80
|
+
function get(srv, path, max) { return U.getJSON(srv.url + path, (typeof Jellyfin !== 'undefined' && Jellyfin.waitMs) ? Jellyfin.waitMs() : 20000, max || 4 * 1048576, null, headers(srv.token)); } // (Wait for a server)
|
|
62
81
|
function tell(srv, path) { return U.getText(srv.url + path, 15000, 65536, null, true, headers(srv.token)); }
|
|
63
82
|
function linkOf(srv, path) { return srv.url + path + (path.indexOf('?') === -1 ? '?' : '&') + 'X-Plex-Token=' + enc(srv.token); }
|
|
64
83
|
|
|
@@ -131,7 +150,7 @@ var Plex = (function () {
|
|
|
131
150
|
}).then(null, function (e) { tried.push(list[i]); U.log('plex', '“' + res.name + '” didn’t answer at ' + list[i] + ' (' + U.problem(e) + ')'); return next(i + 1); });
|
|
132
151
|
}
|
|
133
152
|
return next(0).then(function (url) {
|
|
134
|
-
var all =
|
|
153
|
+
var all = allServers(), old = all.filter(function (s) { return s.machineId === res.machineId; })[0];
|
|
135
154
|
var srv = { id: old ? old.id : 'p' + rand(8), kind: 'plex', url: url, machineId: res.machineId, name: res.name, version: res.version,
|
|
136
155
|
user: res.user, owned: res.owned, token: res.token, at: Date.now() };
|
|
137
156
|
all = all.filter(function (s) { return s !== old; });
|
|
@@ -143,8 +162,8 @@ var Plex = (function () {
|
|
|
143
162
|
});
|
|
144
163
|
}
|
|
145
164
|
function remove(id) {
|
|
146
|
-
if (!
|
|
147
|
-
U.store.set(KEY,
|
|
165
|
+
if (!anyServer(id)) { return; }
|
|
166
|
+
U.store.set(KEY, allServers().filter(function (s) { return s.id !== id; }));
|
|
148
167
|
var libs = libsAll();
|
|
149
168
|
delete libs[id];
|
|
150
169
|
U.store.set(LIBS_KEY, libs);
|
|
@@ -182,7 +201,7 @@ var Plex = (function () {
|
|
|
182
201
|
});
|
|
183
202
|
if (!server(srv.id)) { return; }
|
|
184
203
|
var all = libsAll(), keep = {}, before = JSON.stringify(all[srv.id] && all[srv.id].list);
|
|
185
|
-
|
|
204
|
+
allServers().forEach(function (s) { if (all[s.id]) { keep[s.id] = all[s.id]; } });
|
|
186
205
|
keep[srv.id] = { at: Date.now(), list: list };
|
|
187
206
|
_libs = keep;
|
|
188
207
|
U.store.set(LIBS_KEY, keep);
|
|
@@ -370,25 +389,55 @@ var Plex = (function () {
|
|
|
370
389
|
return U.listOf(mc(r).Metadata, 100000).map(function (it) { return { t: lib.type, it: it }; });
|
|
371
390
|
});
|
|
372
391
|
})).then(function (lists) {
|
|
373
|
-
var map = { __ids: {} };
|
|
392
|
+
var map = { __ids: {}, __tm: {}, __played: [] }; // (__played: its watched films and shows)
|
|
374
393
|
function add(k, v) { (map[k] = map[k] || []).push(v); }
|
|
375
394
|
flat(lists).forEach(function (e) {
|
|
376
|
-
var it = e.it, tt = imdbOf(it), tm = tmdbOf(it);
|
|
395
|
+
var it = e.it, tt = imdbOf(it), tm = tmdbOf(it), rk = '' + it.ratingKey;
|
|
377
396
|
if (it.ratingKey == null) { return; }
|
|
378
|
-
if (tt) { add(e.t + '|' + tt,
|
|
379
|
-
if (tm) { add(e.t + '|tmdb:' + tm,
|
|
397
|
+
if (tt) { add(e.t + '|' + tt, rk); map.__ids[rk] = tt; }
|
|
398
|
+
if (tm) { add(e.t + '|tmdb:' + tm, rk); map.__tm[rk] = tm; }
|
|
399
|
+
var played = e.t === 'movie' ? +it.viewCount > 0 : +it.leafCount > 0 && +it.viewedLeafCount >= +it.leafCount;
|
|
400
|
+
if (played) { map.__played.push({ t: e.t, ids: titleIds(map, (e.t === 'movie' ? 'pxm.' : 'pxs.') + srv.id + '.', rk), at: (+it.lastViewedAt || 0) * 1000 }); }
|
|
380
401
|
});
|
|
381
402
|
if (_index[srv.id] && _index[srv.id].p === p) { _index[srv.id] = { at: Date.now(), map: map }; }
|
|
382
403
|
return map;
|
|
383
404
|
}, function (e) {
|
|
384
405
|
U.log('plex', '“' + srv.name + '”: its titles couldn’t be read (' + U.problem(e) + ')');
|
|
385
|
-
var old = _index[srv.id], map = (old && old.map) || { __ids: {} };
|
|
406
|
+
var old = _index[srv.id], map = (old && old.map) || { __ids: {}, __tm: {}, __played: [], __err: true };
|
|
386
407
|
if (old && old.p === p) { _index[srv.id] = { at: Date.now() - INDEX_FRESH_MS + INDEX_RETRY_MS, map: map }; }
|
|
387
408
|
return map;
|
|
388
409
|
});
|
|
389
410
|
_index[srv.id] = { at: x ? x.at : 0, map: x ? x.map : null, p: p };
|
|
390
411
|
return x && x.map ? Promise.resolve(x.map) : p;
|
|
391
412
|
}
|
|
413
|
+
function indexFresh(srv) { var p = index(srv), x = _index[srv.id]; return x && x.p ? x.p : p; }
|
|
414
|
+
function titleIds(map, own, rk) {
|
|
415
|
+
var l = [own + rk];
|
|
416
|
+
if (map.__ids[rk]) { l.unshift(map.__ids[rk]); }
|
|
417
|
+
if (map.__tm[rk]) { l.push('tmdb:' + map.__tm[rk]); }
|
|
418
|
+
return l;
|
|
419
|
+
}
|
|
420
|
+
// ---- Watched marks ----
|
|
421
|
+
// Its watched films and shows (its list of titles), and the watched episodes of each Shows
|
|
422
|
+
// library (unwatched=0; a server that won't filter: all of them, the watched ones kept).
|
|
423
|
+
function watchedEpisodes(srv, lib) {
|
|
424
|
+
var path = '/library/sections/' + enc(lib.id) + '/all?type=4';
|
|
425
|
+
return get(srv, path + '&unwatched=0', 16 * 1048576).then(null, function () { return get(srv, path, 16 * 1048576); }).then(function (r) {
|
|
426
|
+
return U.listOf(mc(r).Metadata, 100000, function (e) { return +e.viewCount > 0 && e.grandparentRatingKey != null && e.parentIndex >= 0 && e.index >= 0; });
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
function marksOf(srv) {
|
|
430
|
+
var shows = libsOf(srv).filter(function (l) { return l.type === 'series'; });
|
|
431
|
+
if (!libsOf(srv).length) { return Promise.reject(new Error('its libraries aren’t read yet')); } // (not kept as "none": asked again)
|
|
432
|
+
return Promise.all([indexFresh(srv)].concat(shows.map(function (lib) { return watchedEpisodes(srv, lib); }))).then(function (r) {
|
|
433
|
+
var map = r[0], list = map.__played.slice(), sh = share();
|
|
434
|
+
if (map.__err || !sh || !sh.marksFrom) { throw new Error('its titles couldn’t be read'); }
|
|
435
|
+
flat(r.slice(1)).forEach(function (e) {
|
|
436
|
+
list.push({ t: 'series', ids: titleIds(map, 'pxs.' + srv.id + '.', '' + e.grandparentRatingKey), s: +e.parentIndex, e: +e.index, at: (+e.lastViewedAt || 0) * 1000 });
|
|
437
|
+
});
|
|
438
|
+
return sh.marksFrom(list);
|
|
439
|
+
});
|
|
440
|
+
}
|
|
392
441
|
function copies(type, id) {
|
|
393
442
|
var key = '', season = null, episode = null;
|
|
394
443
|
if (type === 'movie') { key = /^(tt\d+|tmdb:\d+)$/.test('' + id) ? '' + id : ''; }
|
|
@@ -523,8 +572,8 @@ var Plex = (function () {
|
|
|
523
572
|
}
|
|
524
573
|
|
|
525
574
|
return {
|
|
526
|
-
servers: servers, server: server, isEnabled: isEnabled, onChange: onChange, link: link, add: add, remove: remove, reload: reload,
|
|
575
|
+
servers: servers, allServers: allServers, server: server, setOn: setOn, isEnabled: isEnabled, onChange: onChange, link: link, add: add, remove: remove, reload: reload,
|
|
527
576
|
libraries: libsOf, synthAddon: synthAddon, synthAddons: synthAddons, catalog: catalog, meta: meta, streams: streams, isPlexId: isPlexId,
|
|
528
|
-
onPlayer: onPlayer, candidates: candidates
|
|
577
|
+
onPlayer: onPlayer, candidates: candidates, marksOf: marksOf
|
|
529
578
|
};
|
|
530
579
|
})();
|
package/js/stremio.js
CHANGED
|
@@ -169,6 +169,7 @@ var Stremio = (function () {
|
|
|
169
169
|
formatsAuto: p.formatsAuto !== false, // Settings > Formats: mark "Not working" on its own
|
|
170
170
|
allowLocal: p.allowLocal === true, // Settings > Addons: home-network links from internet addons
|
|
171
171
|
addonWait: ADDON_WAITS.indexOf(p.addonWait) !== -1 ? p.addonWait : 0, // Settings > Addons: seconds to wait for an addon (0: Normal)
|
|
172
|
+
serverWait: [45, 90, 180].indexOf(p.serverWait) !== -1 ? p.serverWait : 0, // Settings > Media servers: seconds to wait for one's answer (0: Normal, 20)
|
|
172
173
|
autoSkip: [5, 10, 15, 30].indexOf(p.autoSkip) !== -1 ? p.autoSkip : 0, // Settings > Skipping: intros / recaps after a countdown (0: ask)
|
|
173
174
|
autoNext: [5, 10, 15, 30].indexOf(p.autoNext) !== -1 ? p.autoNext : 0, // Settings > Skipping: the next episode at the credits after a countdown (0: ask)
|
|
174
175
|
spoilers: p.spoilers === 'pictures' || p.spoilers === 'all' ? p.spoilers : 'off', // Settings > Appearance: unwatched episodes' stills (and synopses) hidden
|
|
@@ -177,6 +178,7 @@ var Stremio = (function () {
|
|
|
177
178
|
nextOnFail: p.nextOnFail !== false, // Settings > Source ranking: a source that doesn't start gives way to the next
|
|
178
179
|
sizeLimits: { movie: sizeLimits(p.sizeLimits, 'movie'), series: sizeLimits(p.sizeLimits, 'series') }, // Settings > Source ranking (GB; 0: none)
|
|
179
180
|
posterRatings: p.posterRatings === true, // Settings > Appearance: IMDb rating on cards
|
|
181
|
+
watchedCards: p.watchedCards === 'dim' || p.watchedCards === 'hide' ? p.watchedCards : 'show', // Settings > Appearance: watched titles' cards ticked, dimmed too, or left out of rows
|
|
180
182
|
homePreview: p.homePreview !== false, // Settings > Home: Continue Watching on the TV's home bar (js/hubpreview.js)
|
|
181
183
|
homePreviewOrder: p.homePreviewOrder === 'watching' ? 'watching' : 'recent', // ...its tiles: the latest first, or as in Watching
|
|
182
184
|
hiddenTabs: wordList(p.hiddenTabs, 20, 20), // Settings > Home > Menu: tabs hidden
|
package/js/util.js
CHANGED
|
@@ -490,7 +490,8 @@ var U = (function () {
|
|
|
490
490
|
// the YouTube service's while it starts; the caller says so if it matters).
|
|
491
491
|
// headers (optional): { name: value } sent with it.
|
|
492
492
|
// body (optional): sent as a POST (text), else it's a GET.
|
|
493
|
-
|
|
493
|
+
// (bytes: the answer as a Uint8Array, not text: getBytes)
|
|
494
|
+
function getText(url, timeoutMs, maxBytes, cancel, quiet, headers, body, bytes) {
|
|
494
495
|
var priv = privateNow(); // (asked during a private playback: logged as one, however late it fails)
|
|
495
496
|
function logged(err) { return quiet ? err : noteNetwork(err, priv); }
|
|
496
497
|
maxBytes = maxBytes || TEXT_MAX;
|
|
@@ -510,12 +511,13 @@ var U = (function () {
|
|
|
510
511
|
}
|
|
511
512
|
try {
|
|
512
513
|
xhr.open(body == null ? 'GET' : 'POST', url, true);
|
|
514
|
+
if (bytes) { xhr.responseType = 'arraybuffer'; }
|
|
513
515
|
if (headers) { Object.keys(headers).forEach(function (h) { xhr.setRequestHeader(h, headers[h]); }); }
|
|
514
516
|
} catch (e) { reject(e); return; }
|
|
515
517
|
xhr.timeout = timeoutMs || 15000;
|
|
516
518
|
if (maxBytes) {
|
|
517
519
|
xhr.onprogress = function (ev) {
|
|
518
|
-
var got = (ev && ev.loaded) || ('' + (xhr.responseText || '')).length;
|
|
520
|
+
var got = (ev && ev.loaded) || (bytes ? 0 : ('' + (xhr.responseText || '')).length);
|
|
519
521
|
if (!done && got > maxBytes) {
|
|
520
522
|
done = true;
|
|
521
523
|
try { xhr.abort(); } catch (e2) {}
|
|
@@ -526,7 +528,7 @@ var U = (function () {
|
|
|
526
528
|
xhr.onreadystatechange = function () {
|
|
527
529
|
if (xhr.readyState !== 4 || done) { return; }
|
|
528
530
|
done = true;
|
|
529
|
-
var body = xhr.responseText;
|
|
531
|
+
var body = bytes ? (xhr.response ? new Uint8Array(xhr.response) : null) : xhr.responseText;
|
|
530
532
|
if (body && body.length > maxBytes) { reject(logged(new Error('Too large (over ' + mb(maxBytes) + '): ' + redactUrl(url)))); return; } // (no progress events)
|
|
531
533
|
var landed = xhr.responseURL; // where the redirects (if any) ended
|
|
532
534
|
if (landed && landed !== url && urlIsPrivate(landed) && !urlIsPrivate(url) && !_localOk()) {
|
|
@@ -541,7 +543,7 @@ var U = (function () {
|
|
|
541
543
|
if (xhr.status >= 200 && xhr.status < 300) { resolve(body); }
|
|
542
544
|
else {
|
|
543
545
|
var err = new Error('HTTP ' + xhr.status + ' for ' + redactUrl(url));
|
|
544
|
-
var said = serverMessage(body);
|
|
546
|
+
var said = bytes ? '' : serverMessage(body);
|
|
545
547
|
if (said) { err.serverMessage = said; err.message += ': ' + said; }
|
|
546
548
|
reject(logged(err));
|
|
547
549
|
}
|
|
@@ -552,6 +554,9 @@ var U = (function () {
|
|
|
552
554
|
});
|
|
553
555
|
}
|
|
554
556
|
|
|
557
|
+
// A file's bytes (a Uint8Array), up to maxBytes: Emby's seek pictures (js/jellyfin.js).
|
|
558
|
+
function getBytes(url, timeoutMs, maxBytes, quiet) { return getText(url, timeoutMs || 30000, maxBytes, null, quiet, null, null, true); }
|
|
559
|
+
|
|
555
560
|
// No answer at all: the connection refused or dropped, blocked, a certificate the TV doesn't
|
|
556
561
|
// trust (its browser says only "status 0").
|
|
557
562
|
function noAnswer(url) { return new Error('No answer (connection refused, blocked or certificate): ' + redactUrl(url)); }
|
|
@@ -704,7 +709,7 @@ var U = (function () {
|
|
|
704
709
|
var LEFTOVER_SHARE = 0.5, _busy = null, _refusalTidy = false;
|
|
705
710
|
// Use the TV's database (Settings › Diagnostics › Storage; on unless turned off):
|
|
706
711
|
// off, the big copies are kept in the settings storage (BIG_KEY: the ones that go here).
|
|
707
|
-
var USE_KEY = 'stremiok.bigdb', BIG_KEY = /^stremiok\.(homecache|local\.index|iptv\.cache\.|trakt\.watched)/;
|
|
712
|
+
var USE_KEY = 'stremiok.bigdb', BIG_KEY = /^stremiok\.(homecache|local\.index|iptv\.cache\.|trakt\.watched|media\.watched)/;
|
|
708
713
|
function enabled() { return store.get(USE_KEY, true) !== false; }
|
|
709
714
|
function lsBigKeys() {
|
|
710
715
|
var out = [];
|
|
@@ -1677,7 +1682,7 @@ var U = (function () {
|
|
|
1677
1682
|
}
|
|
1678
1683
|
|
|
1679
1684
|
return {
|
|
1680
|
-
byId: byId, el: el, clear: clear, moveIn: moveIn, getJSON: getJSON, getText: getText,
|
|
1685
|
+
byId: byId, el: el, clear: clear, moveIn: moveIn, getJSON: getJSON, getText: getText, getBytes: getBytes,
|
|
1681
1686
|
postJSON: postJSON, redactUrl: redactUrl, problem: problem, problemDetail: problemDetail, listOf: listOf, lru: lru, randomHex: randomHex, cachedJSON: cachedJSON,
|
|
1682
1687
|
parseUrl: parseUrl, urlProblem: urlProblem, isPlaylistUrl: isPlaylistUrl, isManifestUrl: isManifestUrl,
|
|
1683
1688
|
isPrivateHost: isPrivateHost, urlIsPrivate: urlIsPrivate, setLocalPolicy: setLocalPolicy, sanitizeHeaders: sanitizeHeaders, drawable: drawable,
|
package/js/view-core.js
CHANGED
|
@@ -645,7 +645,8 @@ var ViewParts = {};
|
|
|
645
645
|
c.appendChild(U.el('div', 'cap', meta.name || meta.title || ''));
|
|
646
646
|
c.__meta = meta; // shown above the rows on Home while focused
|
|
647
647
|
var kind = meta.type || fallbackType;
|
|
648
|
-
|
|
648
|
+
c.__kind = kind;
|
|
649
|
+
if ((kind === 'movie' || kind === 'series') && meta.id && Player.isWatched(kind, meta.id)) { markCard(c, true); }
|
|
649
650
|
var rating = parseFloat(meta.imdbRating); // (Ratings on posters: the catalog's own, nothing downloaded)
|
|
650
651
|
if (rating > 0 && rating <= 10 && Stremio.getPrefs().posterRatings) { c.appendChild(U.el('div', 'card-rating', '★ ' + rating.toFixed(1))); } // (a series: marked watched whole, see setTitleWatched / the title page)
|
|
651
652
|
if (kind === 'movie' || kind === 'series') { c.__onlongpress = function () { posterActions(meta, kind, c); }; }
|
|
@@ -871,12 +872,34 @@ var ViewParts = {};
|
|
|
871
872
|
function watchedTicks(id, on) {
|
|
872
873
|
var cards = document.querySelectorAll('.card');
|
|
873
874
|
for (var i = 0; i < cards.length; i++) {
|
|
874
|
-
if (cards[i].getAttribute('data-id')
|
|
875
|
-
var badge = cards[i].querySelector('.card-watched');
|
|
876
|
-
if (on && !badge) { cards[i].appendChild(U.el('div', 'card-watched', '✓')); }
|
|
877
|
-
if (!on && badge) { cards[i].removeChild(badge); }
|
|
875
|
+
if (cards[i].getAttribute('data-id') === id) { markCard(cards[i], on); }
|
|
878
876
|
}
|
|
879
877
|
}
|
|
878
|
+
// A card watched or not: its ✓, and dimmed too with Settings › Appearance › Watched titles: Dim.
|
|
879
|
+
function markCard(card, on) {
|
|
880
|
+
var badge = card.querySelector('.card-watched'), dim = on && Stremio.getPrefs().watchedCards === 'dim';
|
|
881
|
+
if (on && !badge) { card.appendChild(U.el('div', 'card-watched', '✓')); }
|
|
882
|
+
if (!on && badge) { card.removeChild(badge); }
|
|
883
|
+
var cls = ('' + card.className).replace(/\s*\bwatched-dim\b/g, '');
|
|
884
|
+
card.className = dim ? cls + ' watched-dim' : cls;
|
|
885
|
+
}
|
|
886
|
+
// Marks that came from elsewhere (your media servers): every movie or series card on screen
|
|
887
|
+
// as it now is; Home's other tabs rebuilt when next opened.
|
|
888
|
+
function watchedChanged() {
|
|
889
|
+
var cards = document.querySelectorAll('.card');
|
|
890
|
+
for (var i = 0; i < cards.length; i++) {
|
|
891
|
+
var m = cards[i].__meta, k = cards[i].__kind;
|
|
892
|
+
if (m && m.id && (k === 'movie' || k === 'series')) { markCard(cards[i], Player.isWatched(k, m.id)); }
|
|
893
|
+
}
|
|
894
|
+
markHomeDirty();
|
|
895
|
+
}
|
|
896
|
+
V.watchedChanged = watchedChanged;
|
|
897
|
+
// Left out of Home's and Discover's rows (Settings › Appearance › Watched titles: Hide).
|
|
898
|
+
function watchedHidden(meta, type) {
|
|
899
|
+
var k = (meta && meta.type) || type;
|
|
900
|
+
return Stremio.getPrefs().watchedCards === 'hide' && !!meta && !!meta.id && (k === 'movie' || k === 'series') && Player.isWatched(k, meta.id);
|
|
901
|
+
}
|
|
902
|
+
V.watchedHidden = watchedHidden;
|
|
880
903
|
|
|
881
904
|
// ----- Add to Continue Watching -----
|
|
882
905
|
// Lists a title in Continue Watching without playing it:
|
package/js/view-discover.js
CHANGED
|
@@ -309,7 +309,7 @@
|
|
|
309
309
|
function startLoad() {
|
|
310
310
|
leaveDiscover();
|
|
311
311
|
_dvCancel = U.cancelToken ? U.cancelToken() : null;
|
|
312
|
-
_dv.items = []; _dv.seen = {}; _dv.done = false; _dv.error = false; _dv.loading = false; _dv.offset = 0; _dv.page = 0; _dv.stale = false;
|
|
312
|
+
_dv.items = []; _dv.seen = {}; _dv.hidden = 0; _dv.done = false; _dv.error = false; _dv.loading = false; _dv.offset = 0; _dv.page = 0; _dv.stale = false;
|
|
313
313
|
_dv.gen++; _dv.focusFirst = true;
|
|
314
314
|
drawGrid();
|
|
315
315
|
loadMore();
|
|
@@ -472,6 +472,10 @@
|
|
|
472
472
|
});
|
|
473
473
|
}
|
|
474
474
|
function gotItems(fresh) {
|
|
475
|
+
var all = fresh.length;
|
|
476
|
+
fresh = fresh.filter(function (m) { return !V.watchedHidden(m, _dv.cat && _dv.cat.type); }); // (Settings › Appearance › Watched titles: Hide)
|
|
477
|
+
_dv.hidden = (_dv.hidden || 0) + all - fresh.length;
|
|
478
|
+
if (all && !fresh.length && !_dv.items.length && !_dv.done) { var g = _dv.gen; setTimeout(function () { if (g === _dv.gen) { loadMore(); } }, 0); return; } // (a first page all watched: the next one)
|
|
475
479
|
var reachesEnd = (_dv.offset + _dv.cardEls.length === _dv.items.length); // (else they join as you scroll down, extendDown)
|
|
476
480
|
_dv.items = _dv.items.concat(fresh);
|
|
477
481
|
if (reachesEnd) { appendCards(fresh); }
|
|
@@ -519,7 +523,7 @@
|
|
|
519
523
|
if (_dv.value && genre) { extra.genre = _dv.value; }
|
|
520
524
|
if (_dv.items.length || (cat.addon && cat.addon.__local)) {
|
|
521
525
|
if (_dv.items.length && !pages(cat)) { _dv.done = true; updateCount(); return; }
|
|
522
|
-
extra.skip = _dv.items.length;
|
|
526
|
+
extra.skip = _dv.items.length + (_dv.hidden || 0); // (the watched ones left out counted: Watched titles: Hide)
|
|
523
527
|
}
|
|
524
528
|
_dv.loading = true;
|
|
525
529
|
updateCount();
|
package/js/view-home.js
CHANGED
|
@@ -1680,6 +1680,10 @@
|
|
|
1680
1680
|
var built = [];
|
|
1681
1681
|
for (var i = from; i < to; i++) {
|
|
1682
1682
|
var c = cats[i];
|
|
1683
|
+
if (Stremio.getPrefs().watchedCards === 'hide' && !c.loading) { // (Settings › Appearance › Watched titles: Hide)
|
|
1684
|
+
c = copyCat(c, c.metas.filter(function (m) { return !V.watchedHidden(m, c.type); }));
|
|
1685
|
+
if (!c.metas.length) { continue; }
|
|
1686
|
+
}
|
|
1683
1687
|
var row = buildRow(c.name, c.metas.slice(0, ROW_FIRST).map(function (m) { return posterCard(m, c.type); }));
|
|
1684
1688
|
if (c.metas.length > ROW_FIRST) { lateCards(row, c); }
|
|
1685
1689
|
if (c.loading) { row.className += ' row-loading'; row.appendChild(U.el('div', 'row-empty', 'Loading…')); } // (its place kept: nothing to focus)
|
package/js/view-settings.js
CHANGED
|
@@ -234,6 +234,10 @@
|
|
|
234
234
|
get: function () { return { posterRatings: Stremio.getPrefs().posterRatings ? 'on' : 'off' }; },
|
|
235
235
|
set: function (cfg) { Stremio.setPref('posterRatings', cfg.posterRatings === 'on'); markHomeDirty(); }
|
|
236
236
|
}));
|
|
237
|
+
wrap.appendChild(subPickRow('Watched titles', [['show', 'Show'], ['dim', 'Dim'], ['hide', 'Hide']], 'watchedCards', {
|
|
238
|
+
get: function () { return { watchedCards: Stremio.getPrefs().watchedCards }; },
|
|
239
|
+
set: function (cfg) { Stremio.setPref('watchedCards', cfg.watchedCards); markHomeDirty(); } // (Home and Discover drawn again with it)
|
|
240
|
+
}));
|
|
237
241
|
wrap.appendChild(subPickRow('Hide spoilers', [['off', 'Off'], ['pictures', 'Pictures'], ['all', 'Pictures and synopses']], 'spoilers', {
|
|
238
242
|
get: function () { return { spoilers: Stremio.getPrefs().spoilers }; },
|
|
239
243
|
set: function (cfg) { Stremio.setPref('spoilers', cfg.spoilers); }
|
|
@@ -1629,16 +1633,24 @@
|
|
|
1629
1633
|
}
|
|
1630
1634
|
var focus = null;
|
|
1631
1635
|
// (each server with the module it's from: Jellyfin's for Jellyfin and Emby, Plex's)
|
|
1632
|
-
var all = (have ? Jellyfin.
|
|
1633
|
-
.concat(hasPlex ? Plex.
|
|
1636
|
+
var all = (have ? Jellyfin.allServers().map(function (s) { return { srv: s, mod: Jellyfin, kind: Jellyfin.kindName(s) }; }) : [])
|
|
1637
|
+
.concat(hasPlex ? Plex.allServers().map(function (s) { return { srv: s, mod: Plex, kind: 'Plex' }; }) : []);
|
|
1634
1638
|
all.forEach(function (x) {
|
|
1635
1639
|
var srv = x.srv, mod = x.mod;
|
|
1636
1640
|
var r = U.el('div', 'addon-item focusable cfg-row'), libs = mod.libraries(srv);
|
|
1637
|
-
r.appendChild(U.el('div', 'a-name', srv.name + ' · ' + x.kind + ' ' + srv.version));
|
|
1638
|
-
r.appendChild(U.el('div', 'a-url', srv.url + (srv.user ? ' · signed in as ' + srv.user : '') + (libs.length ? ' · ' + libs.map(function (l) { return l.name; }).join(', ') : '')));
|
|
1641
|
+
r.appendChild(U.el('div', 'a-name', srv.name + ' · ' + x.kind + ' ' + srv.version + (srv.off ? ' · Off' : '')));
|
|
1642
|
+
r.appendChild(U.el('div', 'a-url', srv.url + (srv.user ? ' · signed in as ' + srv.user : '') + (srv.off ? ' · its rows, sources and watched marks set aside' : libs.length ? ' · ' + libs.map(function (l) { return l.name; }).join(', ') : '')));
|
|
1639
1643
|
r.__onselect = function () {
|
|
1640
|
-
|
|
1641
|
-
|
|
1644
|
+
var opts = srv.off ? [['on', 'Turn on']] : [['off', 'Turn off'], ['reload', 'Reload']];
|
|
1645
|
+
pickList(srv.name, opts.concat([['remove', 'Sign out and remove']]), null, function (v) {
|
|
1646
|
+
if (v === 'on' || v === 'off') {
|
|
1647
|
+
mod.setOn(srv.id, v === 'on');
|
|
1648
|
+
markHomeDirty();
|
|
1649
|
+
U.toast('“' + srv.name + '” ' + (v === 'on' ? 'on' : 'off'));
|
|
1650
|
+
_focusChild = 'jf:' + srv.id;
|
|
1651
|
+
renderSettings();
|
|
1652
|
+
if (v === 'on') { setTimeout(function () { if (_settingsSection === 'mediaservers') { _focusChild = 'jf:' + srv.id; renderSettings(); } }, 1500); } // (its libraries, once read)
|
|
1653
|
+
} else if (v === 'reload') {
|
|
1642
1654
|
mod.reload(srv.id);
|
|
1643
1655
|
markHomeDirty();
|
|
1644
1656
|
U.toast('Reading “' + srv.name + '” again…');
|
|
@@ -1651,6 +1663,12 @@
|
|
|
1651
1663
|
if (_focusChild === 'jf:' + srv.id) { focus = r; }
|
|
1652
1664
|
wrap.appendChild(r);
|
|
1653
1665
|
});
|
|
1666
|
+
if (all.length) {
|
|
1667
|
+
wrap.appendChild(subPickRow('Wait for a server', SERVER_WAITS, 'serverWait', {
|
|
1668
|
+
get: function () { return { serverWait: '' + Stremio.getPrefs().serverWait }; },
|
|
1669
|
+
set: function (cfg) { Stremio.setPref('serverWait', +cfg.serverWait || 0); }
|
|
1670
|
+
}));
|
|
1671
|
+
}
|
|
1654
1672
|
wrap.appendChild(U.el('div', 'hint', 'Jellyfin 10.9 or newer, Emby 4.7 or newer, Plex. Their files play as they are (nothing converted), so the TV must play their format.'));
|
|
1655
1673
|
if (focus) { _focusChild = null; Focus.setScope(scr('settings'), focus); } else { focusSettings(); }
|
|
1656
1674
|
}
|
|
@@ -1819,6 +1837,7 @@
|
|
|
1819
1837
|
var SKIP_CHOICES = [['0', 'Ask (a Skip button)'], ['5', 'After 5 seconds'], ['10', 'After 10 seconds'], ['15', 'After 15 seconds'], ['30', 'After 30 seconds']];
|
|
1820
1838
|
// Settings › Addons: how long an addon's answer is waited for (an addon that sleeps when
|
|
1821
1839
|
// unused fails the first time while it wakes up).
|
|
1840
|
+
var SERVER_WAITS = [['0', 'Normal (20 s)'], ['45', '45 seconds'], ['90', '90 seconds'], ['180', '180 seconds']]; // (a media server's answer)
|
|
1822
1841
|
var ADDON_WAITS = [['0', 'Normal (12 s; sources 15, search 25)'], ['20', '20 seconds'], ['30', '30 seconds'], ['45', '45 seconds'], ['60', '60 seconds']];
|
|
1823
1842
|
var NEXT_CHOICES = [['0', 'Ask'], ['5', 'After 5 seconds'], ['10', 'After 10 seconds'], ['15', 'After 15 seconds'], ['30', 'After 30 seconds']];
|
|
1824
1843
|
// Seeking & buffering: how far LEFT / RIGHT jump; a bigger buffer for slow connections; how
|
|
@@ -2027,6 +2046,7 @@
|
|
|
2027
2046
|
var m;
|
|
2028
2047
|
if (key === 'stremiok.homecache') { return { name: 'Home’s saved rows' }; }
|
|
2029
2048
|
if (key === 'stremiok.trakt.watched') { return { name: 'Trakt watched history' }; }
|
|
2049
|
+
if (key === 'stremiok.media.watched') { return { name: 'Media servers’ watched marks' }; }
|
|
2030
2050
|
if ((m = key.match(/^stremiok\.iptv\.cache\.(.+)$/))) {
|
|
2031
2051
|
var p = (typeof IPTV !== 'undefined' ? IPTV.getPlaylists() : []).filter(function (x) { return x.id === m[1]; })[0];
|
|
2032
2052
|
return p ? { name: 'IPTV playlist copy: ' + (p.name || (('' + p.url).match(/^[a-z]+:\/\/(?:[^\/@]*@)?([^\/?#:]+)/i) || [])[1] || 'a playlist') }
|
package/js/views.js
CHANGED
|
@@ -13,7 +13,7 @@ var Views = (function (V) {
|
|
|
13
13
|
leaveScreen: function (name) { var f = { detail: V.leaveDetail, discover: V.leaveDiscover, search: V.leaveSearch }[name]; if (f) { f(); } }, backInLocal: V.backInLocal, setHomeTab: V.setHomeTab,
|
|
14
14
|
renderLive: V.renderLive,
|
|
15
15
|
renderSearch: V.renderSearch, searchFor: function (q) { V.searchFor(q); }, renderDiscover: V.renderDiscover, renderEntry: V.renderEntry, backInDetail: V.backInDetail,
|
|
16
|
-
homeDirty: V.homeDirty, refreshHomeIfStale: V.refreshHomeIfStale, alertNewEpisodes: V.alertNewEpisodes, previewTiles: V.previewTiles, withShowInfo: V.withShowInfo,
|
|
16
|
+
homeDirty: V.homeDirty, watchedChanged: V.watchedChanged, refreshHomeIfStale: V.refreshHomeIfStale, alertNewEpisodes: V.alertNewEpisodes, previewTiles: V.previewTiles, withShowInfo: V.withShowInfo,
|
|
17
17
|
isModalOpen: V.isModalOpen, closeModal: V.closeModal, confirm: V.confirm, moveKey: V.moveKey, playKey: V.playKey, availableTabs: V.availableTabs,
|
|
18
18
|
menuItems: V.menuItems, menuOrder: V.menuOrder, moveMenuItem: V.moveMenuItem
|
|
19
19
|
};
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stremiok",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2",
|
|
4
4
|
"description": "StremioK streaming client for Tizen 3.0+ Samsung TVs (TizenBrew app module).",
|
|
5
5
|
"packageType": "app",
|
|
6
6
|
"appName": "StremioK",
|
|
7
|
-
"appPath": "
|
|
7
|
+
"appPath": "tizenbrew.html",
|
|
8
8
|
"serviceFile": "service/index.js",
|
|
9
9
|
"files": [
|
|
10
10
|
"index.html",
|
|
11
|
+
"tizenbrew.html",
|
|
11
12
|
"css",
|
|
12
13
|
"js",
|
|
13
14
|
"service",
|
package/tizenbrew.html
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>StremioK</title>
|
|
6
|
+
<script>
|
|
7
|
+
// TizenBrew's start page (package.json's appPath). TizenBrew reads each file from jsDelivr at
|
|
8
|
+
// an address with no version, which jsDelivr keeps per file for hours after a release: an
|
|
9
|
+
// old file, or a mix of two versions. This page names no other file, so nothing is fetched
|
|
10
|
+
// from there: it opens this version's own copy (npm/stremiok@<version>/index.html), whose
|
|
11
|
+
// files all come from that address. build.sh stamps the ?v= below.
|
|
12
|
+
(function () {
|
|
13
|
+
var v = '?v=2.3.2'.slice(3), l = location, rest = (l.search || '') + (l.hash || '');
|
|
14
|
+
var m = /^(\/module\/npm%2F[^\/%@]+)\//i.exec(l.pathname || '');
|
|
15
|
+
l.replace(m ? m[1] + '%40' + v + '/index.html' + rest : 'index.html' + rest);
|
|
16
|
+
})();
|
|
17
|
+
</script>
|
|
18
|
+
</head>
|
|
19
|
+
<body style="background:#000"></body>
|
|
20
|
+
</html>
|