This commit is contained in:
4DBug
2026-08-27 16:11:56 -05:00
parent 82c6a96dbb
commit c8094b6734
13 changed files with 231 additions and 28 deletions
+44 -2
View File
@@ -9,13 +9,22 @@
Providers: until the user toggles anything in Settings, the server's own
enabled list is used. Once customized, a {name: bool} map is stored in
localStorage; names missing from the map default to enabled.
TMDB key: search/trending/details/images go straight to TMDB from the
browser (the server only serves providers, streams and the media proxy).
The key resolves from localStorage (Settings) or the built-in default.
*/
(function () {
'use strict';
const DEFAULT_BASE = 'https://api-tv.bug.tools';
const STORAGE_KEY = 'streamreverse.apiBase.v1';
const PROVIDER_KEY = 'streamreverse.providers.v1';
const STORAGE_KEY = 'bug-tv.apiBase.v1';
const PROVIDER_KEY = 'bug-tv.providers.v1';
// Search/details/images go straight to TMDB from the browser; this key
// only ever reaches api.themoviedb.org.
const DEFAULT_TMDB_KEY = 'ac014b130a8e6344c91dff4e68b18d47';
const TMDB_KEY_STORAGE_KEY = 'bug-tv.tmdbKey.v1';
function normalize(value) {
let v = String(value || '').trim();
@@ -54,6 +63,34 @@
}
}
function getTmdbKey() {
try {
const stored = localStorage.getItem(TMDB_KEY_STORAGE_KEY);
if (stored) return stored.trim();
} catch (e) {
/* private mode etc. */
}
return DEFAULT_TMDB_KEY;
}
function setTmdbKey(value) {
const v = String(value || '').trim();
try {
localStorage.setItem(TMDB_KEY_STORAGE_KEY, v);
} catch (e) {
/* ignore */
}
return v;
}
function clearTmdbKey() {
try {
localStorage.removeItem(TMDB_KEY_STORAGE_KEY);
} catch (e) {
/* ignore */
}
}
// null → user has not customized; caller should fall back to server defaults
function getProviders() {
try {
@@ -128,9 +165,14 @@
DEFAULT_BASE,
STORAGE_KEY,
PROVIDER_KEY,
DEFAULT_TMDB_KEY,
TMDB_KEY_STORAGE_KEY,
getBase,
setBase,
clearBase,
getTmdbKey,
setTmdbKey,
clearTmdbKey,
getProviders,
setProviders,
clearProviders,