nuvio-tizen 1.9.0 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/js/iptv.js +14 -2
- package/js/stremio.js +7 -2
- package/js/views.js +11 -0
- package/package.json +1 -1
package/js/iptv.js
CHANGED
|
@@ -13,6 +13,7 @@ var IPTV = (function () {
|
|
|
13
13
|
var URL_KEY = 'nuvio.iptv.url';
|
|
14
14
|
var CACHE_MS = 10 * 60 * 1000;
|
|
15
15
|
var _cache = null; // { ts, channels, groups, byId, catalogs }
|
|
16
|
+
var _status = { url: '', count: 0, groups: 0, error: '' }; // last load result, for Settings
|
|
16
17
|
|
|
17
18
|
function getUrl() { return U.store.get(URL_KEY, '') || ''; }
|
|
18
19
|
function isEnabled() { return !!getUrl(); }
|
|
@@ -86,16 +87,27 @@ var IPTV = (function () {
|
|
|
86
87
|
function load() {
|
|
87
88
|
if (_cache && (Date.now() - _cache.ts) < CACHE_MS) { return Promise.resolve(_cache); }
|
|
88
89
|
var url = getUrl();
|
|
90
|
+
_status = { url: url, count: 0, groups: 0, error: '' };
|
|
89
91
|
if (!url) { _cache = build([]); return Promise.resolve(_cache); }
|
|
90
92
|
return U.getText(url, 15000).then(function (text) {
|
|
91
93
|
_cache = build(parseM3U(text));
|
|
94
|
+
_status.count = _cache.channels.length;
|
|
95
|
+
_status.groups = _cache.groups.length;
|
|
96
|
+
if (!_cache.channels.length) {
|
|
97
|
+
// Fetched, but nothing parsed — usually the URL returned an error/HTML page
|
|
98
|
+
// (e.g. a "not found" body) rather than an M3U.
|
|
99
|
+
_status.error = 'Fetched, but no channels parsed (is the URL returning the .m3u file?)';
|
|
100
|
+
}
|
|
92
101
|
return _cache;
|
|
93
|
-
}, function () {
|
|
102
|
+
}, function (e) {
|
|
103
|
+
_status.error = (e && e.message) ? e.message : 'Could not fetch the playlist URL';
|
|
94
104
|
_cache = build([]); // keep the app usable if the playlist is unreachable
|
|
95
105
|
return _cache;
|
|
96
106
|
});
|
|
97
107
|
}
|
|
98
108
|
|
|
109
|
+
function status() { return _status; }
|
|
110
|
+
|
|
99
111
|
function toMeta(c) {
|
|
100
112
|
return {
|
|
101
113
|
id: c.id, type: 'tv', name: c.name,
|
|
@@ -154,7 +166,7 @@ var IPTV = (function () {
|
|
|
154
166
|
}
|
|
155
167
|
|
|
156
168
|
return {
|
|
157
|
-
getUrl: getUrl, setUrl: setUrl, isEnabled: isEnabled, reset: reset,
|
|
169
|
+
getUrl: getUrl, setUrl: setUrl, isEnabled: isEnabled, reset: reset, status: status,
|
|
158
170
|
load: load, catalog: catalog, meta: meta, streams: streams, synthAddon: synthAddon
|
|
159
171
|
};
|
|
160
172
|
})();
|
package/js/stremio.js
CHANGED
|
@@ -104,7 +104,9 @@ var Stremio = (function () {
|
|
|
104
104
|
}).then(function (results) {
|
|
105
105
|
var addons = [];
|
|
106
106
|
results.forEach(function (r) { if (r.ok && r.value.manifest) { addons.push(r.value); } });
|
|
107
|
-
|
|
107
|
+
// Prepend so the Live TV rows sort first on Home and are never cut by the
|
|
108
|
+
// home-page row cap (the user can still reorder them in Home Feeds).
|
|
109
|
+
if (_hasIptv && IPTV.isEnabled()) { addons.unshift(IPTV.synthAddon()); }
|
|
108
110
|
_loaded = addons;
|
|
109
111
|
return addons;
|
|
110
112
|
});
|
|
@@ -116,6 +118,8 @@ var Stremio = (function () {
|
|
|
116
118
|
_loaded = null;
|
|
117
119
|
}
|
|
118
120
|
function iptvGetUrl() { return _hasIptv ? IPTV.getUrl() : ''; }
|
|
121
|
+
function iptvLoad() { return _hasIptv ? IPTV.load() : Promise.resolve(null); }
|
|
122
|
+
function iptvStatus() { return _hasIptv ? IPTV.status() : { error: 'IPTV unavailable' }; }
|
|
119
123
|
|
|
120
124
|
// ---- Resource matching ----
|
|
121
125
|
function resourceEntries(addon) {
|
|
@@ -542,6 +546,7 @@ var Stremio = (function () {
|
|
|
542
546
|
getSearchCatalogs: getSearchCatalogs, search: search,
|
|
543
547
|
isPlayable: isPlayable, streamLabel: streamLabel, streamName: streamName,
|
|
544
548
|
streamSize: streamSize, streamDescription: streamDescription,
|
|
545
|
-
iptvSetUrl: iptvSetUrl, iptvGetUrl: iptvGetUrl
|
|
549
|
+
iptvSetUrl: iptvSetUrl, iptvGetUrl: iptvGetUrl,
|
|
550
|
+
iptvLoad: iptvLoad, iptvStatus: iptvStatus
|
|
546
551
|
};
|
|
547
552
|
})();
|
package/js/views.js
CHANGED
|
@@ -851,6 +851,17 @@ var Views = (function () {
|
|
|
851
851
|
wrap.appendChild(U.el('h2', null, 'Live TV (IPTV)'));
|
|
852
852
|
var url = Stremio.iptvGetUrl ? Stremio.iptvGetUrl() : '';
|
|
853
853
|
|
|
854
|
+
// Live load status — turns a silent fetch failure into a visible message.
|
|
855
|
+
if (url && Stremio.iptvLoad) {
|
|
856
|
+
var statusEl = U.el('div', 'hint', 'Checking playlist…');
|
|
857
|
+
wrap.appendChild(statusEl);
|
|
858
|
+
Stremio.iptvLoad().then(function () {
|
|
859
|
+
var st = Stremio.iptvStatus();
|
|
860
|
+
if (st.error) { statusEl.textContent = '⚠ ' + st.error; }
|
|
861
|
+
else { statusEl.textContent = '✓ Loaded ' + st.count + ' channels in ' + st.groups + ' group(s).'; }
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
|
|
854
865
|
var set = U.el('div', 'addon-item focusable');
|
|
855
866
|
set.appendChild(U.el('div', 'a-name', url ? 'M3U playlist' : '+ Set M3U playlist URL'));
|
|
856
867
|
set.appendChild(U.el('div', 'a-url', url || 'Not set — press OK to enter an M3U URL'));
|