@dominevo/addon-media-library 0.1.18 → 0.1.19
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 +6 -0
- package/dist/media-library.addon.js +354 -20
- package/dist/media-library.addon.mjs +354 -20
- package/dist/rn-app/index.native.js +439 -170
- package/dist/rn-app/index.web.js +439 -170
- package/i18n/en.json +6 -1
- package/i18n/it.json +6 -1
- package/package.json +2 -2
|
@@ -8948,6 +8948,30 @@ var MediaScanStatusSchema = /* @__PURE__ */ object({
|
|
|
8948
8948
|
reused: /* @__PURE__ */ number().int().nonnegative(),
|
|
8949
8949
|
skipped: /* @__PURE__ */ number().int().nonnegative()
|
|
8950
8950
|
});
|
|
8951
|
+
/** One streaming service a title is offered on, in the operator's region. */
|
|
8952
|
+
var StreamingProviderSchema = /* @__PURE__ */ object({
|
|
8953
|
+
/** The TMDB watch-provider id. */
|
|
8954
|
+
id: /* @__PURE__ */ number().int(),
|
|
8955
|
+
name: /* @__PURE__ */ string(),
|
|
8956
|
+
logoUrl: /* @__PURE__ */ string().nullable(),
|
|
8957
|
+
/** The service's own search page for this title (opens the installed app); `null` when the service is not known. */
|
|
8958
|
+
searchUrl: /* @__PURE__ */ string().nullable()
|
|
8959
|
+
});
|
|
8960
|
+
/** A title that is NOT in the library, with where the operator can watch it. */
|
|
8961
|
+
var StreamingTitleSchema = /* @__PURE__ */ object({
|
|
8962
|
+
kind: /* @__PURE__ */ _enum(["series", "movie"]),
|
|
8963
|
+
tmdbId: /* @__PURE__ */ number().int(),
|
|
8964
|
+
title: /* @__PURE__ */ string(),
|
|
8965
|
+
year: /* @__PURE__ */ number().int().nullable(),
|
|
8966
|
+
posterUrl: /* @__PURE__ */ string().nullable(),
|
|
8967
|
+
/**
|
|
8968
|
+
* Subscribed services that stream it (flatrate, in the configured region); empty when none does,
|
|
8969
|
+
* `null` when the offers could not be read (unknown, never "none").
|
|
8970
|
+
*/
|
|
8971
|
+
providers: /* @__PURE__ */ array(StreamingProviderSchema).readonly().nullable(),
|
|
8972
|
+
/** The region's page listing every offer for the title; `null` when TMDB gave none. */
|
|
8973
|
+
watchLink: /* @__PURE__ */ string().nullable()
|
|
8974
|
+
});
|
|
8951
8975
|
/**
|
|
8952
8976
|
* The language the caller wants item text in (`title`, `overview`): a locale tag such as `it`; a
|
|
8953
8977
|
* regional form (`it-IT`) reads as its language. Absent means the server's default language. A language
|
|
@@ -9001,6 +9025,15 @@ var mediaLibraryCapability = {
|
|
|
9001
9025
|
limit: /* @__PURE__ */ number().int().positive().max(100).optional(),
|
|
9002
9026
|
language: LanguageInputSchema
|
|
9003
9027
|
}), /* @__PURE__ */ array(MediaItemSummarySchema).readonly(), { caller: "required" }),
|
|
9028
|
+
/**
|
|
9029
|
+
* Titles that are NOT in the library, found online, with the subscribed streaming services that
|
|
9030
|
+
* offer them. Empty when no TMDB token or no service is configured.
|
|
9031
|
+
*/
|
|
9032
|
+
searchElsewhere: /* @__PURE__ */ method(/* @__PURE__ */ object({
|
|
9033
|
+
query: /* @__PURE__ */ string().min(1),
|
|
9034
|
+
limit: /* @__PURE__ */ number().int().positive().max(20).optional(),
|
|
9035
|
+
language: LanguageInputSchema
|
|
9036
|
+
}), /* @__PURE__ */ array(StreamingTitleSchema).readonly(), { caller: "required" }),
|
|
9004
9037
|
/** The series and movies added most recently. */
|
|
9005
9038
|
listRecentlyAdded: /* @__PURE__ */ method(/* @__PURE__ */ object({
|
|
9006
9039
|
limit: /* @__PURE__ */ number().int().positive().max(100).optional(),
|
|
@@ -11323,6 +11356,21 @@ var LibraryStore = class {
|
|
|
11323
11356
|
});
|
|
11324
11357
|
return this.summaries(rows, userId, language);
|
|
11325
11358
|
}
|
|
11359
|
+
/** The TMDB ids the library holds, per kind: what "not in your library" is measured against. */
|
|
11360
|
+
async tmdbIds() {
|
|
11361
|
+
const rows = await this.queryAllItems({ where: { topLevel: true } });
|
|
11362
|
+
const series = /* @__PURE__ */ new Set();
|
|
11363
|
+
const movie = /* @__PURE__ */ new Set();
|
|
11364
|
+
for (const row of rows) {
|
|
11365
|
+
if (row.tmdbId === null) continue;
|
|
11366
|
+
if (row.kind === "series") series.add(row.tmdbId);
|
|
11367
|
+
else if (row.kind === "movie") movie.add(row.tmdbId);
|
|
11368
|
+
}
|
|
11369
|
+
return {
|
|
11370
|
+
series,
|
|
11371
|
+
movie
|
|
11372
|
+
};
|
|
11373
|
+
}
|
|
11326
11374
|
async search(userId, query, limit, language) {
|
|
11327
11375
|
const needle = foldTitle(query);
|
|
11328
11376
|
if (needle === "") return [];
|
|
@@ -13297,6 +13345,9 @@ function tmdbLanguageOf(language) {
|
|
|
13297
13345
|
if (language === "zh") return "zh-CN";
|
|
13298
13346
|
return language;
|
|
13299
13347
|
}
|
|
13348
|
+
function tmdbYearOf(date) {
|
|
13349
|
+
return yearOf$1(date);
|
|
13350
|
+
}
|
|
13300
13351
|
function yearOf$1(date) {
|
|
13301
13352
|
const match = /^(\d{4})/.exec(date ?? "");
|
|
13302
13353
|
return match?.[1] === void 0 ? null : Number(match[1]);
|
|
@@ -13305,6 +13356,10 @@ function text(value) {
|
|
|
13305
13356
|
const trimmed = value?.trim() ?? "";
|
|
13306
13357
|
return trimmed === "" ? null : trimmed;
|
|
13307
13358
|
}
|
|
13359
|
+
/** A TMDB picture URL for a path in a size, `null` for no path. */
|
|
13360
|
+
function tmdbImage(size, path) {
|
|
13361
|
+
return image(size, path);
|
|
13362
|
+
}
|
|
13308
13363
|
function image(size, path) {
|
|
13309
13364
|
return path === null || path === void 0 || !path.startsWith("/") ? null : `${IMAGES}/${size}${path}`;
|
|
13310
13365
|
}
|
|
@@ -13410,15 +13465,12 @@ function itemDetailsOf(details, language, region) {
|
|
|
13410
13465
|
}
|
|
13411
13466
|
var nameOf = (entry) => entry.title ?? entry.name ?? "";
|
|
13412
13467
|
var yearIn = (entry) => yearOf$1(entry.release_date ?? entry.first_air_date);
|
|
13413
|
-
/** TMDB:
|
|
13414
|
-
function
|
|
13415
|
-
const language = deps.language ?? DEFAULT_LANGUAGE;
|
|
13416
|
-
const region = tmdbRegionOf(language);
|
|
13468
|
+
/** The TMDB caller: 20 requests a second at most, one bounded wait on a 429, a 401 named once. */
|
|
13469
|
+
function createTmdbClient(deps) {
|
|
13417
13470
|
const headers = {
|
|
13418
13471
|
Authorization: `Bearer ${deps.token}`,
|
|
13419
13472
|
Accept: "application/json"
|
|
13420
13473
|
};
|
|
13421
|
-
const segment = (kind) => kind === "movie" ? "movie" : "tv";
|
|
13422
13474
|
const sleep = deps.sleep ?? ((ms) => new Promise((done) => setTimeout(done, ms)));
|
|
13423
13475
|
const clock = deps.now ?? Date.now;
|
|
13424
13476
|
let nextSlot = 0;
|
|
@@ -13442,19 +13494,30 @@ function createTmdbProvider(deps) {
|
|
|
13442
13494
|
return deps.fetch(url, { headers });
|
|
13443
13495
|
}
|
|
13444
13496
|
};
|
|
13445
|
-
const
|
|
13446
|
-
|
|
13447
|
-
|
|
13448
|
-
|
|
13449
|
-
|
|
13450
|
-
|
|
13451
|
-
|
|
13452
|
-
|
|
13453
|
-
|
|
13454
|
-
|
|
13455
|
-
|
|
13497
|
+
const view = (language) => ({
|
|
13498
|
+
language,
|
|
13499
|
+
withLanguage: view,
|
|
13500
|
+
call: async (path, query = {}) => {
|
|
13501
|
+
const params = new URLSearchParams({
|
|
13502
|
+
...query,
|
|
13503
|
+
language
|
|
13504
|
+
});
|
|
13505
|
+
try {
|
|
13506
|
+
const bytes = await get(`${API$2}${path}?${params.toString()}`);
|
|
13507
|
+
return JSON.parse(bytes.toString("utf8"));
|
|
13508
|
+
} catch (error) {
|
|
13509
|
+
if (error instanceof Error && /\b401\b/.test(error.message)) throw new ProviderAuthError(TMDB_REJECTED);
|
|
13510
|
+
throw error;
|
|
13511
|
+
}
|
|
13456
13512
|
}
|
|
13457
|
-
};
|
|
13513
|
+
});
|
|
13514
|
+
return view(deps.language ?? DEFAULT_LANGUAGE);
|
|
13515
|
+
}
|
|
13516
|
+
/** TMDB: movies and series, with the installation's own read token. All calls go through the shared remote fetch. */
|
|
13517
|
+
function createTmdbProvider(deps) {
|
|
13518
|
+
const { language, call } = (deps.client ?? createTmdbClient(deps)).withLanguage(deps.language ?? DEFAULT_LANGUAGE);
|
|
13519
|
+
const region = tmdbRegionOf(language);
|
|
13520
|
+
const segment = (kind) => kind === "movie" ? "movie" : "tv";
|
|
13458
13521
|
const matchOf = (details) => ({
|
|
13459
13522
|
providerId: TMDB_ID,
|
|
13460
13523
|
remoteId: String(details.id),
|
|
@@ -14172,7 +14235,7 @@ function createFfmpegProber(binaryPath) {
|
|
|
14172
14235
|
//#endregion
|
|
14173
14236
|
//#region src/provider.ts
|
|
14174
14237
|
/** The `media-library` capability over the store. A caller reads and writes only their own progress. */
|
|
14175
|
-
function createMediaLibraryProvider(store, scans) {
|
|
14238
|
+
function createMediaLibraryProvider(store, scans, streaming) {
|
|
14176
14239
|
return {
|
|
14177
14240
|
listSeries: ({ limit, offset, language, caller }) => store.listSeries(caller.userId, limit, offset, language),
|
|
14178
14241
|
listMovies: ({ limit, offset, language, caller }) => store.listMovies(caller.userId, limit, offset, language),
|
|
@@ -14180,6 +14243,7 @@ function createMediaLibraryProvider(store, scans) {
|
|
|
14180
14243
|
listEpisodes: ({ seriesId, seasonNumber, language, caller }) => store.listEpisodes(caller.userId, seriesId, seasonNumber, language),
|
|
14181
14244
|
getItem: ({ itemId, language, caller }) => store.getItem(caller.userId, itemId, language),
|
|
14182
14245
|
search: ({ query, limit, language, caller }) => store.search(caller.userId, query, limit, language),
|
|
14246
|
+
searchElsewhere: ({ query, limit, language }) => streaming.search(query, limit, language),
|
|
14183
14247
|
listRecentlyAdded: ({ limit, language, caller }) => store.listRecentlyAdded(caller.userId, limit, language),
|
|
14184
14248
|
listWatchlist: ({ limit, offset, language, caller }) => store.listWatchlist(caller.userId, limit, offset, language),
|
|
14185
14249
|
setWatchlisted: ({ itemId, on, caller }) => store.setWatchlisted(caller.userId, itemId, on),
|
|
@@ -14192,6 +14256,173 @@ function createMediaLibraryProvider(store, scans) {
|
|
|
14192
14256
|
getScanStatus: async () => scans.status()
|
|
14193
14257
|
};
|
|
14194
14258
|
}
|
|
14259
|
+
/**
|
|
14260
|
+
* The search page of the services whose address is known, by TMDB provider id. An https address of
|
|
14261
|
+
* these services opens the installed app on a phone. A service not listed gets no button of its own.
|
|
14262
|
+
*/
|
|
14263
|
+
var SEARCH_URLS = {
|
|
14264
|
+
8: "https://www.netflix.com/search?q=",
|
|
14265
|
+
9: "https://www.primevideo.com/search?phrase=",
|
|
14266
|
+
119: "https://www.primevideo.com/search?phrase=",
|
|
14267
|
+
337: "https://www.disneyplus.com/search?q="
|
|
14268
|
+
};
|
|
14269
|
+
/** The service's own search page for a title, `null` when the service is not known. */
|
|
14270
|
+
function serviceSearchUrl(providerId, title) {
|
|
14271
|
+
const base = SEARCH_URLS[providerId];
|
|
14272
|
+
return base === void 0 ? null : `${base}${encodeURIComponent(title)}`;
|
|
14273
|
+
}
|
|
14274
|
+
var DEFAULT_LIMIT = 10;
|
|
14275
|
+
var SearchAnswerSchema = object({ results: array(object({
|
|
14276
|
+
id: number().int(),
|
|
14277
|
+
title: string().nullish(),
|
|
14278
|
+
name: string().nullish(),
|
|
14279
|
+
release_date: string().nullish(),
|
|
14280
|
+
first_air_date: string().nullish(),
|
|
14281
|
+
poster_path: string().nullish()
|
|
14282
|
+
})) });
|
|
14283
|
+
var OfferSchema = object({
|
|
14284
|
+
provider_id: number().int(),
|
|
14285
|
+
provider_name: string(),
|
|
14286
|
+
logo_path: string().nullish()
|
|
14287
|
+
});
|
|
14288
|
+
var RegionOffersSchema = object({
|
|
14289
|
+
link: string().nullish(),
|
|
14290
|
+
flatrate: array(OfferSchema).optional()
|
|
14291
|
+
});
|
|
14292
|
+
var WatchProvidersAnswerSchema = object({ results: record(string(), RegionOffersSchema).default({}) });
|
|
14293
|
+
var segmentOf = (kind) => kind === "movie" ? "movie" : "tv";
|
|
14294
|
+
/** An ISO 3166-1 alpha-2 code, upper-cased; `null` for anything else. */
|
|
14295
|
+
function regionCode(raw) {
|
|
14296
|
+
const code = raw.trim().toUpperCase();
|
|
14297
|
+
return /^[A-Z]{2}$/.test(code) ? code : null;
|
|
14298
|
+
}
|
|
14299
|
+
/** Alternate the two kinds in the order TMDB ranked them, so neither buries the other. */
|
|
14300
|
+
function interleave(series, movies) {
|
|
14301
|
+
const out = [];
|
|
14302
|
+
for (let i = 0; i < Math.max(series.length, movies.length); i++) {
|
|
14303
|
+
const s = series[i];
|
|
14304
|
+
const m = movies[i];
|
|
14305
|
+
if (s !== void 0) out.push(s);
|
|
14306
|
+
if (m !== void 0) out.push(m);
|
|
14307
|
+
}
|
|
14308
|
+
return out;
|
|
14309
|
+
}
|
|
14310
|
+
var StreamingSearch = class {
|
|
14311
|
+
deps;
|
|
14312
|
+
cache = /* @__PURE__ */ new Map();
|
|
14313
|
+
inFlight = /* @__PURE__ */ new Map();
|
|
14314
|
+
warnedUnconfigured = false;
|
|
14315
|
+
constructor(deps) {
|
|
14316
|
+
this.deps = deps;
|
|
14317
|
+
}
|
|
14318
|
+
/** Identical searches asked while one is running share its answer. */
|
|
14319
|
+
async search(query, limit, language) {
|
|
14320
|
+
const config = await this.deps.config();
|
|
14321
|
+
if (config.token.trim() === "" || config.services.length === 0) {
|
|
14322
|
+
this.warnUnconfigured(config);
|
|
14323
|
+
return [];
|
|
14324
|
+
}
|
|
14325
|
+
const key = JSON.stringify([
|
|
14326
|
+
query,
|
|
14327
|
+
limit ?? null,
|
|
14328
|
+
language ?? null,
|
|
14329
|
+
config.region,
|
|
14330
|
+
config.services
|
|
14331
|
+
]);
|
|
14332
|
+
const running = this.inFlight.get(key);
|
|
14333
|
+
if (running !== void 0) return running;
|
|
14334
|
+
const started = this.run(query, config, limit, language).finally(() => {
|
|
14335
|
+
this.inFlight.delete(key);
|
|
14336
|
+
});
|
|
14337
|
+
this.inFlight.set(key, started);
|
|
14338
|
+
return started;
|
|
14339
|
+
}
|
|
14340
|
+
async run(query, config, limit, language) {
|
|
14341
|
+
const shown = language ?? this.deps.defaultLanguage();
|
|
14342
|
+
const region = regionCode(config.region) ?? tmdbRegionOf(shown);
|
|
14343
|
+
const client = this.deps.client(config.token, tmdbLanguageOf(shown));
|
|
14344
|
+
let candidates;
|
|
14345
|
+
try {
|
|
14346
|
+
const [found, inLibrary] = await Promise.all([this.find(client, query), this.deps.library()]);
|
|
14347
|
+
candidates = interleave(found.series, found.movie).filter(({ kind, hit }) => !(kind === "movie" ? inLibrary.movie : inLibrary.series).has(hit.id)).slice(0, limit ?? DEFAULT_LIMIT);
|
|
14348
|
+
} catch (error) {
|
|
14349
|
+
this.deps.logger.warn("streaming search failed", { meta: { error: error instanceof Error ? error.message : String(error) } });
|
|
14350
|
+
return [];
|
|
14351
|
+
}
|
|
14352
|
+
return Promise.all(candidates.map((candidate) => this.titleOf(client, candidate, region, config)));
|
|
14353
|
+
}
|
|
14354
|
+
warnUnconfigured(config) {
|
|
14355
|
+
if (this.warnedUnconfigured) return;
|
|
14356
|
+
this.warnedUnconfigured = true;
|
|
14357
|
+
this.deps.logger.info(config.token.trim() === "" ? "streaming search is off: no TMDB token configured" : "streaming search is off: no streaming service selected");
|
|
14358
|
+
}
|
|
14359
|
+
async find(client, query) {
|
|
14360
|
+
const ask = async (kind) => {
|
|
14361
|
+
return SearchAnswerSchema.parse(await client.call(`/search/${segmentOf(kind)}`, {
|
|
14362
|
+
query,
|
|
14363
|
+
include_adult: "false"
|
|
14364
|
+
})).results.map((hit) => ({
|
|
14365
|
+
kind,
|
|
14366
|
+
hit
|
|
14367
|
+
}));
|
|
14368
|
+
};
|
|
14369
|
+
const [series, movie] = await Promise.all([ask("series"), ask("movie")]);
|
|
14370
|
+
return {
|
|
14371
|
+
series,
|
|
14372
|
+
movie
|
|
14373
|
+
};
|
|
14374
|
+
}
|
|
14375
|
+
async titleOf(client, { kind, hit }, region, config) {
|
|
14376
|
+
const offers = await this.offersOf(client, kind, hit.id, region);
|
|
14377
|
+
const title = hit.title ?? hit.name ?? "";
|
|
14378
|
+
const subscribed = offers === void 0 ? null : (offers?.flatrate ?? []).filter((offer) => config.services.includes(offer.provider_id)).map((offer) => ({
|
|
14379
|
+
id: offer.provider_id,
|
|
14380
|
+
name: offer.provider_name,
|
|
14381
|
+
logoUrl: tmdbImage("w92", offer.logo_path),
|
|
14382
|
+
searchUrl: serviceSearchUrl(offer.provider_id, title)
|
|
14383
|
+
}));
|
|
14384
|
+
return {
|
|
14385
|
+
kind,
|
|
14386
|
+
tmdbId: hit.id,
|
|
14387
|
+
title,
|
|
14388
|
+
year: tmdbYearOf(hit.release_date ?? hit.first_air_date),
|
|
14389
|
+
posterUrl: tmdbImage("w185", hit.poster_path),
|
|
14390
|
+
providers: subscribed,
|
|
14391
|
+
watchLink: offers?.link ?? null
|
|
14392
|
+
};
|
|
14393
|
+
}
|
|
14394
|
+
/**
|
|
14395
|
+
* The region's offers for a title, cached: `null` when TMDB lists none for the region, `undefined`
|
|
14396
|
+
* when the read failed (unknown, and not cached).
|
|
14397
|
+
*/
|
|
14398
|
+
async offersOf(client, kind, id, region) {
|
|
14399
|
+
const key = `${kind}:${id}:${region}`;
|
|
14400
|
+
const cached = this.cache.get(key);
|
|
14401
|
+
if (cached !== void 0 && this.deps.now() - cached.at < 432e5) {
|
|
14402
|
+
this.cache.delete(key);
|
|
14403
|
+
this.cache.set(key, cached);
|
|
14404
|
+
return cached.offers;
|
|
14405
|
+
}
|
|
14406
|
+
try {
|
|
14407
|
+
const offers = WatchProvidersAnswerSchema.parse(await client.call(`/${segmentOf(kind)}/${id}/watch/providers`)).results[region] ?? null;
|
|
14408
|
+
this.cache.delete(key);
|
|
14409
|
+
this.cache.set(key, {
|
|
14410
|
+
at: this.deps.now(),
|
|
14411
|
+
offers
|
|
14412
|
+
});
|
|
14413
|
+
const oldest = this.cache.keys().next();
|
|
14414
|
+
if (this.cache.size > 2e3 && oldest.done !== true) this.cache.delete(oldest.value);
|
|
14415
|
+
return offers;
|
|
14416
|
+
} catch (error) {
|
|
14417
|
+
this.deps.logger.warn("watch providers unreadable", { meta: {
|
|
14418
|
+
kind,
|
|
14419
|
+
tmdbId: id,
|
|
14420
|
+
error: error instanceof Error ? error.message : String(error)
|
|
14421
|
+
} });
|
|
14422
|
+
return;
|
|
14423
|
+
}
|
|
14424
|
+
}
|
|
14425
|
+
};
|
|
14195
14426
|
//#endregion
|
|
14196
14427
|
//#region src/settings.ts
|
|
14197
14428
|
/** The capability that owns the cluster-scoped settings (D986). */
|
|
@@ -14322,7 +14553,11 @@ var MediaLibrarySettingsSchema = object({
|
|
|
14322
14553
|
plexToken: string().meta({ secret: true }).default(""),
|
|
14323
14554
|
plexPathFrom: string().default(""),
|
|
14324
14555
|
plexPathTo: string().default(""),
|
|
14325
|
-
plexUserMap: string().default("")
|
|
14556
|
+
plexUserMap: string().default(""),
|
|
14557
|
+
/** The region "where to watch" asks for (ISO 3166-1 alpha-2); empty derives it from the language. */
|
|
14558
|
+
streamingRegion: string().default(""),
|
|
14559
|
+
/** The TMDB watch-provider ids of the services the operator subscribes to, as text. */
|
|
14560
|
+
streamingServices: array(string()).default([])
|
|
14326
14561
|
});
|
|
14327
14562
|
/** A source is on only when both its URL and key are set; a half-filled one is off, not guessed. */
|
|
14328
14563
|
function resolveSources(settings) {
|
|
@@ -14354,6 +14589,57 @@ function resolvePlex(settings) {
|
|
|
14354
14589
|
userMap: settings.plexUserMap
|
|
14355
14590
|
};
|
|
14356
14591
|
}
|
|
14592
|
+
/** The services offered in the picker: TMDB's own provider ids. Any other id can be typed in. */
|
|
14593
|
+
var STREAMING_SERVICE_OPTIONS = [
|
|
14594
|
+
{
|
|
14595
|
+
value: "8",
|
|
14596
|
+
label: "Netflix"
|
|
14597
|
+
},
|
|
14598
|
+
{
|
|
14599
|
+
value: "9",
|
|
14600
|
+
label: "Amazon Prime Video"
|
|
14601
|
+
},
|
|
14602
|
+
{
|
|
14603
|
+
value: "337",
|
|
14604
|
+
label: "Disney Plus"
|
|
14605
|
+
},
|
|
14606
|
+
{
|
|
14607
|
+
value: "350",
|
|
14608
|
+
label: "Apple TV Plus"
|
|
14609
|
+
},
|
|
14610
|
+
{
|
|
14611
|
+
value: "1899",
|
|
14612
|
+
label: "Max"
|
|
14613
|
+
},
|
|
14614
|
+
{
|
|
14615
|
+
value: "531",
|
|
14616
|
+
label: "Paramount Plus"
|
|
14617
|
+
},
|
|
14618
|
+
{
|
|
14619
|
+
value: "15",
|
|
14620
|
+
label: "Hulu"
|
|
14621
|
+
},
|
|
14622
|
+
{
|
|
14623
|
+
value: "386",
|
|
14624
|
+
label: "Peacock"
|
|
14625
|
+
},
|
|
14626
|
+
{
|
|
14627
|
+
value: "283",
|
|
14628
|
+
label: "Crunchyroll"
|
|
14629
|
+
}
|
|
14630
|
+
];
|
|
14631
|
+
/** The configured services as TMDB ids; an entry that is not a positive integer is dropped. */
|
|
14632
|
+
function resolveStreaming(settings) {
|
|
14633
|
+
const services = [];
|
|
14634
|
+
for (const raw of settings.streamingServices) {
|
|
14635
|
+
const id = Number(raw.trim());
|
|
14636
|
+
if (Number.isInteger(id) && id > 0 && !services.includes(id)) services.push(id);
|
|
14637
|
+
}
|
|
14638
|
+
return {
|
|
14639
|
+
region: settings.streamingRegion.trim(),
|
|
14640
|
+
services
|
|
14641
|
+
};
|
|
14642
|
+
}
|
|
14357
14643
|
var MEDIA_LIBRARY_CLUSTER_SCHEMA = { sections: [
|
|
14358
14644
|
{
|
|
14359
14645
|
id: "series",
|
|
@@ -14527,6 +14813,28 @@ var MEDIA_LIBRARY_CLUSTER_SCHEMA = { sections: [
|
|
|
14527
14813
|
]
|
|
14528
14814
|
}]
|
|
14529
14815
|
},
|
|
14816
|
+
{
|
|
14817
|
+
id: "streaming",
|
|
14818
|
+
title: "Where to watch",
|
|
14819
|
+
titleKey: "media-library:mediaLibraryAddon.clusterSettings.s_streaming.title",
|
|
14820
|
+
fields: [{
|
|
14821
|
+
type: "text",
|
|
14822
|
+
key: "streamingRegion",
|
|
14823
|
+
label: "Region",
|
|
14824
|
+
labelKey: "media-library:mediaLibraryAddon.clusterSettings.s_streaming.streamingRegion.label",
|
|
14825
|
+
description: "Two-letter country code, for example DE. Empty uses the region of the server language. Needs the TMDB token.",
|
|
14826
|
+
descriptionKey: "media-library:mediaLibraryAddon.clusterSettings.s_streaming.streamingRegion.description"
|
|
14827
|
+
}, {
|
|
14828
|
+
type: "multiselect",
|
|
14829
|
+
key: "streamingServices",
|
|
14830
|
+
label: "Streaming services",
|
|
14831
|
+
labelKey: "media-library:mediaLibraryAddon.clusterSettings.s_streaming.streamingServices.label",
|
|
14832
|
+
description: "Search shows titles missing from the library. Netflix, Amazon Prime Video and Disney Plus get an \"Open in\" button that opens their own search; any other service shares one \"Where to watch\" button. Another service: type its TMDB watch-provider id. Empty turns it off.",
|
|
14833
|
+
descriptionKey: "media-library:mediaLibraryAddon.clusterSettings.s_streaming.streamingServices.description",
|
|
14834
|
+
options: STREAMING_SERVICE_OPTIONS,
|
|
14835
|
+
creatable: true
|
|
14836
|
+
}]
|
|
14837
|
+
},
|
|
14530
14838
|
{
|
|
14531
14839
|
id: "plex",
|
|
14532
14840
|
title: "Import from Plex",
|
|
@@ -15601,6 +15909,17 @@ var MediaLibraryAddon = class extends BaseAddon {
|
|
|
15601
15909
|
});
|
|
15602
15910
|
const store = new LibraryStore(db, logger, () => serverLanguage.current(), void 0, void 0, trickplay);
|
|
15603
15911
|
await store.init();
|
|
15912
|
+
const tmdbClients = /* @__PURE__ */ new Map();
|
|
15913
|
+
const tmdbFor = (token) => {
|
|
15914
|
+
const known = tmdbClients.get(token);
|
|
15915
|
+
if (known !== void 0) return known;
|
|
15916
|
+
const made = createTmdbClient({
|
|
15917
|
+
fetch: httpRemoteFetch,
|
|
15918
|
+
token
|
|
15919
|
+
});
|
|
15920
|
+
tmdbClients.set(token, made);
|
|
15921
|
+
return made;
|
|
15922
|
+
};
|
|
15604
15923
|
const scans = new ScanController({
|
|
15605
15924
|
db,
|
|
15606
15925
|
logger,
|
|
@@ -15625,6 +15944,7 @@ var MediaLibraryAddon = class extends BaseAddon {
|
|
|
15625
15944
|
},
|
|
15626
15945
|
createTmdb: (token, language) => createTmdbProvider({
|
|
15627
15946
|
fetch: httpRemoteFetch,
|
|
15947
|
+
client: tmdbFor(token),
|
|
15628
15948
|
token,
|
|
15629
15949
|
language: tmdbLanguageOf(language)
|
|
15630
15950
|
}),
|
|
@@ -15647,6 +15967,20 @@ var MediaLibraryAddon = class extends BaseAddon {
|
|
|
15647
15967
|
for (const source of await store.trickplaySources()) await trickplay.request(source, trickplayBaseOf(source.itemId));
|
|
15648
15968
|
});
|
|
15649
15969
|
this.scans = scans;
|
|
15970
|
+
const streaming = new StreamingSearch({
|
|
15971
|
+
config: async () => {
|
|
15972
|
+
const settings = await this.readSettings();
|
|
15973
|
+
return {
|
|
15974
|
+
token: resolveSources(settings).tmdbToken ?? "",
|
|
15975
|
+
...resolveStreaming(settings)
|
|
15976
|
+
};
|
|
15977
|
+
},
|
|
15978
|
+
client: (token, language) => tmdbFor(token).withLanguage(language),
|
|
15979
|
+
library: () => store.tmdbIds(),
|
|
15980
|
+
defaultLanguage: () => serverLanguage.current(),
|
|
15981
|
+
logger,
|
|
15982
|
+
now: () => Date.now()
|
|
15983
|
+
});
|
|
15650
15984
|
const plexImports = new PlexImportController(logger, () => Date.now());
|
|
15651
15985
|
const startPlex = async (mode) => {
|
|
15652
15986
|
const plex = resolvePlex(await this.readSettings());
|
|
@@ -15730,7 +16064,7 @@ var MediaLibraryAddon = class extends BaseAddon {
|
|
|
15730
16064
|
providers: [
|
|
15731
16065
|
{
|
|
15732
16066
|
capability: mediaLibraryCapability,
|
|
15733
|
-
provider: createMediaLibraryProvider(store, scans)
|
|
16067
|
+
provider: createMediaLibraryProvider(store, scans, streaming)
|
|
15734
16068
|
},
|
|
15735
16069
|
{
|
|
15736
16070
|
capability: appSourceCapability,
|