@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
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.1.19] - 2026-12-05
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Search shows titles missing from the library, with Open in buttons for the streaming services you subscribe to (Netflix, Amazon Prime Video and Disney Plus open their own search, others share a Where to watch button); new Where to watch settings: region and services, needs the TMDB token
|
|
15
|
+
|
|
10
16
|
## [0.1.18] - 2026-12-04
|
|
11
17
|
|
|
12
18
|
### Changed
|
|
@@ -8952,6 +8952,30 @@ var MediaScanStatusSchema = /* @__PURE__ */ object({
|
|
|
8952
8952
|
reused: /* @__PURE__ */ number().int().nonnegative(),
|
|
8953
8953
|
skipped: /* @__PURE__ */ number().int().nonnegative()
|
|
8954
8954
|
});
|
|
8955
|
+
/** One streaming service a title is offered on, in the operator's region. */
|
|
8956
|
+
var StreamingProviderSchema = /* @__PURE__ */ object({
|
|
8957
|
+
/** The TMDB watch-provider id. */
|
|
8958
|
+
id: /* @__PURE__ */ number().int(),
|
|
8959
|
+
name: /* @__PURE__ */ string(),
|
|
8960
|
+
logoUrl: /* @__PURE__ */ string().nullable(),
|
|
8961
|
+
/** The service's own search page for this title (opens the installed app); `null` when the service is not known. */
|
|
8962
|
+
searchUrl: /* @__PURE__ */ string().nullable()
|
|
8963
|
+
});
|
|
8964
|
+
/** A title that is NOT in the library, with where the operator can watch it. */
|
|
8965
|
+
var StreamingTitleSchema = /* @__PURE__ */ object({
|
|
8966
|
+
kind: /* @__PURE__ */ _enum(["series", "movie"]),
|
|
8967
|
+
tmdbId: /* @__PURE__ */ number().int(),
|
|
8968
|
+
title: /* @__PURE__ */ string(),
|
|
8969
|
+
year: /* @__PURE__ */ number().int().nullable(),
|
|
8970
|
+
posterUrl: /* @__PURE__ */ string().nullable(),
|
|
8971
|
+
/**
|
|
8972
|
+
* Subscribed services that stream it (flatrate, in the configured region); empty when none does,
|
|
8973
|
+
* `null` when the offers could not be read (unknown, never "none").
|
|
8974
|
+
*/
|
|
8975
|
+
providers: /* @__PURE__ */ array(StreamingProviderSchema).readonly().nullable(),
|
|
8976
|
+
/** The region's page listing every offer for the title; `null` when TMDB gave none. */
|
|
8977
|
+
watchLink: /* @__PURE__ */ string().nullable()
|
|
8978
|
+
});
|
|
8955
8979
|
/**
|
|
8956
8980
|
* The language the caller wants item text in (`title`, `overview`): a locale tag such as `it`; a
|
|
8957
8981
|
* regional form (`it-IT`) reads as its language. Absent means the server's default language. A language
|
|
@@ -9005,6 +9029,15 @@ var mediaLibraryCapability = {
|
|
|
9005
9029
|
limit: /* @__PURE__ */ number().int().positive().max(100).optional(),
|
|
9006
9030
|
language: LanguageInputSchema
|
|
9007
9031
|
}), /* @__PURE__ */ array(MediaItemSummarySchema).readonly(), { caller: "required" }),
|
|
9032
|
+
/**
|
|
9033
|
+
* Titles that are NOT in the library, found online, with the subscribed streaming services that
|
|
9034
|
+
* offer them. Empty when no TMDB token or no service is configured.
|
|
9035
|
+
*/
|
|
9036
|
+
searchElsewhere: /* @__PURE__ */ method(/* @__PURE__ */ object({
|
|
9037
|
+
query: /* @__PURE__ */ string().min(1),
|
|
9038
|
+
limit: /* @__PURE__ */ number().int().positive().max(20).optional(),
|
|
9039
|
+
language: LanguageInputSchema
|
|
9040
|
+
}), /* @__PURE__ */ array(StreamingTitleSchema).readonly(), { caller: "required" }),
|
|
9008
9041
|
/** The series and movies added most recently. */
|
|
9009
9042
|
listRecentlyAdded: /* @__PURE__ */ method(/* @__PURE__ */ object({
|
|
9010
9043
|
limit: /* @__PURE__ */ number().int().positive().max(100).optional(),
|
|
@@ -11327,6 +11360,21 @@ var LibraryStore = class {
|
|
|
11327
11360
|
});
|
|
11328
11361
|
return this.summaries(rows, userId, language);
|
|
11329
11362
|
}
|
|
11363
|
+
/** The TMDB ids the library holds, per kind: what "not in your library" is measured against. */
|
|
11364
|
+
async tmdbIds() {
|
|
11365
|
+
const rows = await this.queryAllItems({ where: { topLevel: true } });
|
|
11366
|
+
const series = /* @__PURE__ */ new Set();
|
|
11367
|
+
const movie = /* @__PURE__ */ new Set();
|
|
11368
|
+
for (const row of rows) {
|
|
11369
|
+
if (row.tmdbId === null) continue;
|
|
11370
|
+
if (row.kind === "series") series.add(row.tmdbId);
|
|
11371
|
+
else if (row.kind === "movie") movie.add(row.tmdbId);
|
|
11372
|
+
}
|
|
11373
|
+
return {
|
|
11374
|
+
series,
|
|
11375
|
+
movie
|
|
11376
|
+
};
|
|
11377
|
+
}
|
|
11330
11378
|
async search(userId, query, limit, language) {
|
|
11331
11379
|
const needle = foldTitle(query);
|
|
11332
11380
|
if (needle === "") return [];
|
|
@@ -13301,6 +13349,9 @@ function tmdbLanguageOf(language) {
|
|
|
13301
13349
|
if (language === "zh") return "zh-CN";
|
|
13302
13350
|
return language;
|
|
13303
13351
|
}
|
|
13352
|
+
function tmdbYearOf(date) {
|
|
13353
|
+
return yearOf$1(date);
|
|
13354
|
+
}
|
|
13304
13355
|
function yearOf$1(date) {
|
|
13305
13356
|
const match = /^(\d{4})/.exec(date ?? "");
|
|
13306
13357
|
return match?.[1] === void 0 ? null : Number(match[1]);
|
|
@@ -13309,6 +13360,10 @@ function text(value) {
|
|
|
13309
13360
|
const trimmed = value?.trim() ?? "";
|
|
13310
13361
|
return trimmed === "" ? null : trimmed;
|
|
13311
13362
|
}
|
|
13363
|
+
/** A TMDB picture URL for a path in a size, `null` for no path. */
|
|
13364
|
+
function tmdbImage(size, path) {
|
|
13365
|
+
return image(size, path);
|
|
13366
|
+
}
|
|
13312
13367
|
function image(size, path) {
|
|
13313
13368
|
return path === null || path === void 0 || !path.startsWith("/") ? null : `${IMAGES}/${size}${path}`;
|
|
13314
13369
|
}
|
|
@@ -13414,15 +13469,12 @@ function itemDetailsOf(details, language, region) {
|
|
|
13414
13469
|
}
|
|
13415
13470
|
var nameOf = (entry) => entry.title ?? entry.name ?? "";
|
|
13416
13471
|
var yearIn = (entry) => yearOf$1(entry.release_date ?? entry.first_air_date);
|
|
13417
|
-
/** TMDB:
|
|
13418
|
-
function
|
|
13419
|
-
const language = deps.language ?? DEFAULT_LANGUAGE;
|
|
13420
|
-
const region = tmdbRegionOf(language);
|
|
13472
|
+
/** The TMDB caller: 20 requests a second at most, one bounded wait on a 429, a 401 named once. */
|
|
13473
|
+
function createTmdbClient(deps) {
|
|
13421
13474
|
const headers = {
|
|
13422
13475
|
Authorization: `Bearer ${deps.token}`,
|
|
13423
13476
|
Accept: "application/json"
|
|
13424
13477
|
};
|
|
13425
|
-
const segment = (kind) => kind === "movie" ? "movie" : "tv";
|
|
13426
13478
|
const sleep = deps.sleep ?? ((ms) => new Promise((done) => setTimeout(done, ms)));
|
|
13427
13479
|
const clock = deps.now ?? Date.now;
|
|
13428
13480
|
let nextSlot = 0;
|
|
@@ -13446,19 +13498,30 @@ function createTmdbProvider(deps) {
|
|
|
13446
13498
|
return deps.fetch(url, { headers });
|
|
13447
13499
|
}
|
|
13448
13500
|
};
|
|
13449
|
-
const
|
|
13450
|
-
|
|
13451
|
-
|
|
13452
|
-
|
|
13453
|
-
|
|
13454
|
-
|
|
13455
|
-
|
|
13456
|
-
|
|
13457
|
-
|
|
13458
|
-
|
|
13459
|
-
|
|
13501
|
+
const view = (language) => ({
|
|
13502
|
+
language,
|
|
13503
|
+
withLanguage: view,
|
|
13504
|
+
call: async (path, query = {}) => {
|
|
13505
|
+
const params = new URLSearchParams({
|
|
13506
|
+
...query,
|
|
13507
|
+
language
|
|
13508
|
+
});
|
|
13509
|
+
try {
|
|
13510
|
+
const bytes = await get(`${API$2}${path}?${params.toString()}`);
|
|
13511
|
+
return JSON.parse(bytes.toString("utf8"));
|
|
13512
|
+
} catch (error) {
|
|
13513
|
+
if (error instanceof Error && /\b401\b/.test(error.message)) throw new ProviderAuthError(TMDB_REJECTED);
|
|
13514
|
+
throw error;
|
|
13515
|
+
}
|
|
13460
13516
|
}
|
|
13461
|
-
};
|
|
13517
|
+
});
|
|
13518
|
+
return view(deps.language ?? DEFAULT_LANGUAGE);
|
|
13519
|
+
}
|
|
13520
|
+
/** TMDB: movies and series, with the installation's own read token. All calls go through the shared remote fetch. */
|
|
13521
|
+
function createTmdbProvider(deps) {
|
|
13522
|
+
const { language, call } = (deps.client ?? createTmdbClient(deps)).withLanguage(deps.language ?? DEFAULT_LANGUAGE);
|
|
13523
|
+
const region = tmdbRegionOf(language);
|
|
13524
|
+
const segment = (kind) => kind === "movie" ? "movie" : "tv";
|
|
13462
13525
|
const matchOf = (details) => ({
|
|
13463
13526
|
providerId: TMDB_ID,
|
|
13464
13527
|
remoteId: String(details.id),
|
|
@@ -14176,7 +14239,7 @@ function createFfmpegProber(binaryPath) {
|
|
|
14176
14239
|
//#endregion
|
|
14177
14240
|
//#region src/provider.ts
|
|
14178
14241
|
/** The `media-library` capability over the store. A caller reads and writes only their own progress. */
|
|
14179
|
-
function createMediaLibraryProvider(store, scans) {
|
|
14242
|
+
function createMediaLibraryProvider(store, scans, streaming) {
|
|
14180
14243
|
return {
|
|
14181
14244
|
listSeries: ({ limit, offset, language, caller }) => store.listSeries(caller.userId, limit, offset, language),
|
|
14182
14245
|
listMovies: ({ limit, offset, language, caller }) => store.listMovies(caller.userId, limit, offset, language),
|
|
@@ -14184,6 +14247,7 @@ function createMediaLibraryProvider(store, scans) {
|
|
|
14184
14247
|
listEpisodes: ({ seriesId, seasonNumber, language, caller }) => store.listEpisodes(caller.userId, seriesId, seasonNumber, language),
|
|
14185
14248
|
getItem: ({ itemId, language, caller }) => store.getItem(caller.userId, itemId, language),
|
|
14186
14249
|
search: ({ query, limit, language, caller }) => store.search(caller.userId, query, limit, language),
|
|
14250
|
+
searchElsewhere: ({ query, limit, language }) => streaming.search(query, limit, language),
|
|
14187
14251
|
listRecentlyAdded: ({ limit, language, caller }) => store.listRecentlyAdded(caller.userId, limit, language),
|
|
14188
14252
|
listWatchlist: ({ limit, offset, language, caller }) => store.listWatchlist(caller.userId, limit, offset, language),
|
|
14189
14253
|
setWatchlisted: ({ itemId, on, caller }) => store.setWatchlisted(caller.userId, itemId, on),
|
|
@@ -14196,6 +14260,173 @@ function createMediaLibraryProvider(store, scans) {
|
|
|
14196
14260
|
getScanStatus: async () => scans.status()
|
|
14197
14261
|
};
|
|
14198
14262
|
}
|
|
14263
|
+
/**
|
|
14264
|
+
* The search page of the services whose address is known, by TMDB provider id. An https address of
|
|
14265
|
+
* these services opens the installed app on a phone. A service not listed gets no button of its own.
|
|
14266
|
+
*/
|
|
14267
|
+
var SEARCH_URLS = {
|
|
14268
|
+
8: "https://www.netflix.com/search?q=",
|
|
14269
|
+
9: "https://www.primevideo.com/search?phrase=",
|
|
14270
|
+
119: "https://www.primevideo.com/search?phrase=",
|
|
14271
|
+
337: "https://www.disneyplus.com/search?q="
|
|
14272
|
+
};
|
|
14273
|
+
/** The service's own search page for a title, `null` when the service is not known. */
|
|
14274
|
+
function serviceSearchUrl(providerId, title) {
|
|
14275
|
+
const base = SEARCH_URLS[providerId];
|
|
14276
|
+
return base === void 0 ? null : `${base}${encodeURIComponent(title)}`;
|
|
14277
|
+
}
|
|
14278
|
+
var DEFAULT_LIMIT = 10;
|
|
14279
|
+
var SearchAnswerSchema = object({ results: array(object({
|
|
14280
|
+
id: number().int(),
|
|
14281
|
+
title: string().nullish(),
|
|
14282
|
+
name: string().nullish(),
|
|
14283
|
+
release_date: string().nullish(),
|
|
14284
|
+
first_air_date: string().nullish(),
|
|
14285
|
+
poster_path: string().nullish()
|
|
14286
|
+
})) });
|
|
14287
|
+
var OfferSchema = object({
|
|
14288
|
+
provider_id: number().int(),
|
|
14289
|
+
provider_name: string(),
|
|
14290
|
+
logo_path: string().nullish()
|
|
14291
|
+
});
|
|
14292
|
+
var RegionOffersSchema = object({
|
|
14293
|
+
link: string().nullish(),
|
|
14294
|
+
flatrate: array(OfferSchema).optional()
|
|
14295
|
+
});
|
|
14296
|
+
var WatchProvidersAnswerSchema = object({ results: record(string(), RegionOffersSchema).default({}) });
|
|
14297
|
+
var segmentOf = (kind) => kind === "movie" ? "movie" : "tv";
|
|
14298
|
+
/** An ISO 3166-1 alpha-2 code, upper-cased; `null` for anything else. */
|
|
14299
|
+
function regionCode(raw) {
|
|
14300
|
+
const code = raw.trim().toUpperCase();
|
|
14301
|
+
return /^[A-Z]{2}$/.test(code) ? code : null;
|
|
14302
|
+
}
|
|
14303
|
+
/** Alternate the two kinds in the order TMDB ranked them, so neither buries the other. */
|
|
14304
|
+
function interleave(series, movies) {
|
|
14305
|
+
const out = [];
|
|
14306
|
+
for (let i = 0; i < Math.max(series.length, movies.length); i++) {
|
|
14307
|
+
const s = series[i];
|
|
14308
|
+
const m = movies[i];
|
|
14309
|
+
if (s !== void 0) out.push(s);
|
|
14310
|
+
if (m !== void 0) out.push(m);
|
|
14311
|
+
}
|
|
14312
|
+
return out;
|
|
14313
|
+
}
|
|
14314
|
+
var StreamingSearch = class {
|
|
14315
|
+
deps;
|
|
14316
|
+
cache = /* @__PURE__ */ new Map();
|
|
14317
|
+
inFlight = /* @__PURE__ */ new Map();
|
|
14318
|
+
warnedUnconfigured = false;
|
|
14319
|
+
constructor(deps) {
|
|
14320
|
+
this.deps = deps;
|
|
14321
|
+
}
|
|
14322
|
+
/** Identical searches asked while one is running share its answer. */
|
|
14323
|
+
async search(query, limit, language) {
|
|
14324
|
+
const config = await this.deps.config();
|
|
14325
|
+
if (config.token.trim() === "" || config.services.length === 0) {
|
|
14326
|
+
this.warnUnconfigured(config);
|
|
14327
|
+
return [];
|
|
14328
|
+
}
|
|
14329
|
+
const key = JSON.stringify([
|
|
14330
|
+
query,
|
|
14331
|
+
limit ?? null,
|
|
14332
|
+
language ?? null,
|
|
14333
|
+
config.region,
|
|
14334
|
+
config.services
|
|
14335
|
+
]);
|
|
14336
|
+
const running = this.inFlight.get(key);
|
|
14337
|
+
if (running !== void 0) return running;
|
|
14338
|
+
const started = this.run(query, config, limit, language).finally(() => {
|
|
14339
|
+
this.inFlight.delete(key);
|
|
14340
|
+
});
|
|
14341
|
+
this.inFlight.set(key, started);
|
|
14342
|
+
return started;
|
|
14343
|
+
}
|
|
14344
|
+
async run(query, config, limit, language) {
|
|
14345
|
+
const shown = language ?? this.deps.defaultLanguage();
|
|
14346
|
+
const region = regionCode(config.region) ?? tmdbRegionOf(shown);
|
|
14347
|
+
const client = this.deps.client(config.token, tmdbLanguageOf(shown));
|
|
14348
|
+
let candidates;
|
|
14349
|
+
try {
|
|
14350
|
+
const [found, inLibrary] = await Promise.all([this.find(client, query), this.deps.library()]);
|
|
14351
|
+
candidates = interleave(found.series, found.movie).filter(({ kind, hit }) => !(kind === "movie" ? inLibrary.movie : inLibrary.series).has(hit.id)).slice(0, limit ?? DEFAULT_LIMIT);
|
|
14352
|
+
} catch (error) {
|
|
14353
|
+
this.deps.logger.warn("streaming search failed", { meta: { error: error instanceof Error ? error.message : String(error) } });
|
|
14354
|
+
return [];
|
|
14355
|
+
}
|
|
14356
|
+
return Promise.all(candidates.map((candidate) => this.titleOf(client, candidate, region, config)));
|
|
14357
|
+
}
|
|
14358
|
+
warnUnconfigured(config) {
|
|
14359
|
+
if (this.warnedUnconfigured) return;
|
|
14360
|
+
this.warnedUnconfigured = true;
|
|
14361
|
+
this.deps.logger.info(config.token.trim() === "" ? "streaming search is off: no TMDB token configured" : "streaming search is off: no streaming service selected");
|
|
14362
|
+
}
|
|
14363
|
+
async find(client, query) {
|
|
14364
|
+
const ask = async (kind) => {
|
|
14365
|
+
return SearchAnswerSchema.parse(await client.call(`/search/${segmentOf(kind)}`, {
|
|
14366
|
+
query,
|
|
14367
|
+
include_adult: "false"
|
|
14368
|
+
})).results.map((hit) => ({
|
|
14369
|
+
kind,
|
|
14370
|
+
hit
|
|
14371
|
+
}));
|
|
14372
|
+
};
|
|
14373
|
+
const [series, movie] = await Promise.all([ask("series"), ask("movie")]);
|
|
14374
|
+
return {
|
|
14375
|
+
series,
|
|
14376
|
+
movie
|
|
14377
|
+
};
|
|
14378
|
+
}
|
|
14379
|
+
async titleOf(client, { kind, hit }, region, config) {
|
|
14380
|
+
const offers = await this.offersOf(client, kind, hit.id, region);
|
|
14381
|
+
const title = hit.title ?? hit.name ?? "";
|
|
14382
|
+
const subscribed = offers === void 0 ? null : (offers?.flatrate ?? []).filter((offer) => config.services.includes(offer.provider_id)).map((offer) => ({
|
|
14383
|
+
id: offer.provider_id,
|
|
14384
|
+
name: offer.provider_name,
|
|
14385
|
+
logoUrl: tmdbImage("w92", offer.logo_path),
|
|
14386
|
+
searchUrl: serviceSearchUrl(offer.provider_id, title)
|
|
14387
|
+
}));
|
|
14388
|
+
return {
|
|
14389
|
+
kind,
|
|
14390
|
+
tmdbId: hit.id,
|
|
14391
|
+
title,
|
|
14392
|
+
year: tmdbYearOf(hit.release_date ?? hit.first_air_date),
|
|
14393
|
+
posterUrl: tmdbImage("w185", hit.poster_path),
|
|
14394
|
+
providers: subscribed,
|
|
14395
|
+
watchLink: offers?.link ?? null
|
|
14396
|
+
};
|
|
14397
|
+
}
|
|
14398
|
+
/**
|
|
14399
|
+
* The region's offers for a title, cached: `null` when TMDB lists none for the region, `undefined`
|
|
14400
|
+
* when the read failed (unknown, and not cached).
|
|
14401
|
+
*/
|
|
14402
|
+
async offersOf(client, kind, id, region) {
|
|
14403
|
+
const key = `${kind}:${id}:${region}`;
|
|
14404
|
+
const cached = this.cache.get(key);
|
|
14405
|
+
if (cached !== void 0 && this.deps.now() - cached.at < 432e5) {
|
|
14406
|
+
this.cache.delete(key);
|
|
14407
|
+
this.cache.set(key, cached);
|
|
14408
|
+
return cached.offers;
|
|
14409
|
+
}
|
|
14410
|
+
try {
|
|
14411
|
+
const offers = WatchProvidersAnswerSchema.parse(await client.call(`/${segmentOf(kind)}/${id}/watch/providers`)).results[region] ?? null;
|
|
14412
|
+
this.cache.delete(key);
|
|
14413
|
+
this.cache.set(key, {
|
|
14414
|
+
at: this.deps.now(),
|
|
14415
|
+
offers
|
|
14416
|
+
});
|
|
14417
|
+
const oldest = this.cache.keys().next();
|
|
14418
|
+
if (this.cache.size > 2e3 && oldest.done !== true) this.cache.delete(oldest.value);
|
|
14419
|
+
return offers;
|
|
14420
|
+
} catch (error) {
|
|
14421
|
+
this.deps.logger.warn("watch providers unreadable", { meta: {
|
|
14422
|
+
kind,
|
|
14423
|
+
tmdbId: id,
|
|
14424
|
+
error: error instanceof Error ? error.message : String(error)
|
|
14425
|
+
} });
|
|
14426
|
+
return;
|
|
14427
|
+
}
|
|
14428
|
+
}
|
|
14429
|
+
};
|
|
14199
14430
|
//#endregion
|
|
14200
14431
|
//#region src/settings.ts
|
|
14201
14432
|
/** The capability that owns the cluster-scoped settings (D986). */
|
|
@@ -14326,7 +14557,11 @@ var MediaLibrarySettingsSchema = object({
|
|
|
14326
14557
|
plexToken: string().meta({ secret: true }).default(""),
|
|
14327
14558
|
plexPathFrom: string().default(""),
|
|
14328
14559
|
plexPathTo: string().default(""),
|
|
14329
|
-
plexUserMap: string().default("")
|
|
14560
|
+
plexUserMap: string().default(""),
|
|
14561
|
+
/** The region "where to watch" asks for (ISO 3166-1 alpha-2); empty derives it from the language. */
|
|
14562
|
+
streamingRegion: string().default(""),
|
|
14563
|
+
/** The TMDB watch-provider ids of the services the operator subscribes to, as text. */
|
|
14564
|
+
streamingServices: array(string()).default([])
|
|
14330
14565
|
});
|
|
14331
14566
|
/** A source is on only when both its URL and key are set; a half-filled one is off, not guessed. */
|
|
14332
14567
|
function resolveSources(settings) {
|
|
@@ -14358,6 +14593,57 @@ function resolvePlex(settings) {
|
|
|
14358
14593
|
userMap: settings.plexUserMap
|
|
14359
14594
|
};
|
|
14360
14595
|
}
|
|
14596
|
+
/** The services offered in the picker: TMDB's own provider ids. Any other id can be typed in. */
|
|
14597
|
+
var STREAMING_SERVICE_OPTIONS = [
|
|
14598
|
+
{
|
|
14599
|
+
value: "8",
|
|
14600
|
+
label: "Netflix"
|
|
14601
|
+
},
|
|
14602
|
+
{
|
|
14603
|
+
value: "9",
|
|
14604
|
+
label: "Amazon Prime Video"
|
|
14605
|
+
},
|
|
14606
|
+
{
|
|
14607
|
+
value: "337",
|
|
14608
|
+
label: "Disney Plus"
|
|
14609
|
+
},
|
|
14610
|
+
{
|
|
14611
|
+
value: "350",
|
|
14612
|
+
label: "Apple TV Plus"
|
|
14613
|
+
},
|
|
14614
|
+
{
|
|
14615
|
+
value: "1899",
|
|
14616
|
+
label: "Max"
|
|
14617
|
+
},
|
|
14618
|
+
{
|
|
14619
|
+
value: "531",
|
|
14620
|
+
label: "Paramount Plus"
|
|
14621
|
+
},
|
|
14622
|
+
{
|
|
14623
|
+
value: "15",
|
|
14624
|
+
label: "Hulu"
|
|
14625
|
+
},
|
|
14626
|
+
{
|
|
14627
|
+
value: "386",
|
|
14628
|
+
label: "Peacock"
|
|
14629
|
+
},
|
|
14630
|
+
{
|
|
14631
|
+
value: "283",
|
|
14632
|
+
label: "Crunchyroll"
|
|
14633
|
+
}
|
|
14634
|
+
];
|
|
14635
|
+
/** The configured services as TMDB ids; an entry that is not a positive integer is dropped. */
|
|
14636
|
+
function resolveStreaming(settings) {
|
|
14637
|
+
const services = [];
|
|
14638
|
+
for (const raw of settings.streamingServices) {
|
|
14639
|
+
const id = Number(raw.trim());
|
|
14640
|
+
if (Number.isInteger(id) && id > 0 && !services.includes(id)) services.push(id);
|
|
14641
|
+
}
|
|
14642
|
+
return {
|
|
14643
|
+
region: settings.streamingRegion.trim(),
|
|
14644
|
+
services
|
|
14645
|
+
};
|
|
14646
|
+
}
|
|
14361
14647
|
var MEDIA_LIBRARY_CLUSTER_SCHEMA = { sections: [
|
|
14362
14648
|
{
|
|
14363
14649
|
id: "series",
|
|
@@ -14531,6 +14817,28 @@ var MEDIA_LIBRARY_CLUSTER_SCHEMA = { sections: [
|
|
|
14531
14817
|
]
|
|
14532
14818
|
}]
|
|
14533
14819
|
},
|
|
14820
|
+
{
|
|
14821
|
+
id: "streaming",
|
|
14822
|
+
title: "Where to watch",
|
|
14823
|
+
titleKey: "media-library:mediaLibraryAddon.clusterSettings.s_streaming.title",
|
|
14824
|
+
fields: [{
|
|
14825
|
+
type: "text",
|
|
14826
|
+
key: "streamingRegion",
|
|
14827
|
+
label: "Region",
|
|
14828
|
+
labelKey: "media-library:mediaLibraryAddon.clusterSettings.s_streaming.streamingRegion.label",
|
|
14829
|
+
description: "Two-letter country code, for example DE. Empty uses the region of the server language. Needs the TMDB token.",
|
|
14830
|
+
descriptionKey: "media-library:mediaLibraryAddon.clusterSettings.s_streaming.streamingRegion.description"
|
|
14831
|
+
}, {
|
|
14832
|
+
type: "multiselect",
|
|
14833
|
+
key: "streamingServices",
|
|
14834
|
+
label: "Streaming services",
|
|
14835
|
+
labelKey: "media-library:mediaLibraryAddon.clusterSettings.s_streaming.streamingServices.label",
|
|
14836
|
+
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.",
|
|
14837
|
+
descriptionKey: "media-library:mediaLibraryAddon.clusterSettings.s_streaming.streamingServices.description",
|
|
14838
|
+
options: STREAMING_SERVICE_OPTIONS,
|
|
14839
|
+
creatable: true
|
|
14840
|
+
}]
|
|
14841
|
+
},
|
|
14534
14842
|
{
|
|
14535
14843
|
id: "plex",
|
|
14536
14844
|
title: "Import from Plex",
|
|
@@ -15605,6 +15913,17 @@ var MediaLibraryAddon = class extends BaseAddon {
|
|
|
15605
15913
|
});
|
|
15606
15914
|
const store = new LibraryStore(db, logger, () => serverLanguage.current(), void 0, void 0, trickplay);
|
|
15607
15915
|
await store.init();
|
|
15916
|
+
const tmdbClients = /* @__PURE__ */ new Map();
|
|
15917
|
+
const tmdbFor = (token) => {
|
|
15918
|
+
const known = tmdbClients.get(token);
|
|
15919
|
+
if (known !== void 0) return known;
|
|
15920
|
+
const made = createTmdbClient({
|
|
15921
|
+
fetch: httpRemoteFetch,
|
|
15922
|
+
token
|
|
15923
|
+
});
|
|
15924
|
+
tmdbClients.set(token, made);
|
|
15925
|
+
return made;
|
|
15926
|
+
};
|
|
15608
15927
|
const scans = new ScanController({
|
|
15609
15928
|
db,
|
|
15610
15929
|
logger,
|
|
@@ -15629,6 +15948,7 @@ var MediaLibraryAddon = class extends BaseAddon {
|
|
|
15629
15948
|
},
|
|
15630
15949
|
createTmdb: (token, language) => createTmdbProvider({
|
|
15631
15950
|
fetch: httpRemoteFetch,
|
|
15951
|
+
client: tmdbFor(token),
|
|
15632
15952
|
token,
|
|
15633
15953
|
language: tmdbLanguageOf(language)
|
|
15634
15954
|
}),
|
|
@@ -15651,6 +15971,20 @@ var MediaLibraryAddon = class extends BaseAddon {
|
|
|
15651
15971
|
for (const source of await store.trickplaySources()) await trickplay.request(source, trickplayBaseOf(source.itemId));
|
|
15652
15972
|
});
|
|
15653
15973
|
this.scans = scans;
|
|
15974
|
+
const streaming = new StreamingSearch({
|
|
15975
|
+
config: async () => {
|
|
15976
|
+
const settings = await this.readSettings();
|
|
15977
|
+
return {
|
|
15978
|
+
token: resolveSources(settings).tmdbToken ?? "",
|
|
15979
|
+
...resolveStreaming(settings)
|
|
15980
|
+
};
|
|
15981
|
+
},
|
|
15982
|
+
client: (token, language) => tmdbFor(token).withLanguage(language),
|
|
15983
|
+
library: () => store.tmdbIds(),
|
|
15984
|
+
defaultLanguage: () => serverLanguage.current(),
|
|
15985
|
+
logger,
|
|
15986
|
+
now: () => Date.now()
|
|
15987
|
+
});
|
|
15654
15988
|
const plexImports = new PlexImportController(logger, () => Date.now());
|
|
15655
15989
|
const startPlex = async (mode) => {
|
|
15656
15990
|
const plex = resolvePlex(await this.readSettings());
|
|
@@ -15734,7 +16068,7 @@ var MediaLibraryAddon = class extends BaseAddon {
|
|
|
15734
16068
|
providers: [
|
|
15735
16069
|
{
|
|
15736
16070
|
capability: mediaLibraryCapability,
|
|
15737
|
-
provider: createMediaLibraryProvider(store, scans)
|
|
16071
|
+
provider: createMediaLibraryProvider(store, scans, streaming)
|
|
15738
16072
|
},
|
|
15739
16073
|
{
|
|
15740
16074
|
capability: appSourceCapability,
|