@dominevo/addon-media-library 0.1.5 → 0.1.6

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 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.6] - 2026-12-03
11
+
12
+ ### Changed
13
+
14
+ - Library titles and descriptions are shown in each viewer's language (from TMDB translations), falling back to the server default language, then to the stored text
15
+
10
16
  ## [0.1.5] - 2026-12-03
11
17
 
12
18
  ### Changed
@@ -8863,7 +8863,14 @@ var MediaScanStatusSchema = /* @__PURE__ */ object({
8863
8863
  reused: /* @__PURE__ */ number().int().nonnegative(),
8864
8864
  skipped: /* @__PURE__ */ number().int().nonnegative()
8865
8865
  });
8866
+ /**
8867
+ * The language the caller wants item text in (`title`, `overview`): a locale tag such as `it`; a
8868
+ * regional form (`it-IT`) reads as its language. Absent means the server's default language. A language
8869
+ * the item has no text in falls back to the server default, then to the text stored with the item.
8870
+ */
8871
+ var LanguageInputSchema = /* @__PURE__ */ string().min(2).max(35).optional();
8866
8872
  var PageInputSchema = /* @__PURE__ */ object({
8873
+ language: LanguageInputSchema,
8867
8874
  limit: /* @__PURE__ */ number().int().positive().max(500).optional(),
8868
8875
  offset: /* @__PURE__ */ number().int().nonnegative().optional()
8869
8876
  });
@@ -8882,17 +8889,25 @@ var mediaLibraryCapability = {
8882
8889
  /** The episodes of one season in order, each with the caller's progress. */
8883
8890
  listEpisodes: /* @__PURE__ */ method(/* @__PURE__ */ object({
8884
8891
  seriesId: /* @__PURE__ */ string().min(1),
8885
- seasonNumber: /* @__PURE__ */ number().int()
8892
+ seasonNumber: /* @__PURE__ */ number().int(),
8893
+ language: LanguageInputSchema
8886
8894
  }), /* @__PURE__ */ array(MediaEpisodeSummarySchema).readonly(), { caller: "required" }),
8887
8895
  /** One item with its streams and direct-play path; `null` when the id is unknown. */
8888
- getItem: /* @__PURE__ */ method(/* @__PURE__ */ object({ itemId: /* @__PURE__ */ string().min(1) }), /* @__PURE__ */ MediaItemDetailSchema.nullable(), { caller: "required" }),
8896
+ getItem: /* @__PURE__ */ method(/* @__PURE__ */ object({
8897
+ itemId: /* @__PURE__ */ string().min(1),
8898
+ language: LanguageInputSchema
8899
+ }), /* @__PURE__ */ MediaItemDetailSchema.nullable(), { caller: "required" }),
8889
8900
  /** Series and movies whose title contains the query, case and accents ignored. */
8890
8901
  search: /* @__PURE__ */ method(/* @__PURE__ */ object({
8891
8902
  query: /* @__PURE__ */ string().min(1),
8892
- limit: /* @__PURE__ */ number().int().positive().max(100).optional()
8903
+ limit: /* @__PURE__ */ number().int().positive().max(100).optional(),
8904
+ language: LanguageInputSchema
8893
8905
  }), /* @__PURE__ */ array(MediaItemSummarySchema).readonly(), { caller: "required" }),
8894
8906
  /** The series and movies added most recently. */
8895
- listRecentlyAdded: /* @__PURE__ */ method(/* @__PURE__ */ object({ limit: /* @__PURE__ */ number().int().positive().max(100).optional() }), /* @__PURE__ */ array(MediaItemSummarySchema).readonly(), { caller: "required" }),
8907
+ listRecentlyAdded: /* @__PURE__ */ method(/* @__PURE__ */ object({
8908
+ limit: /* @__PURE__ */ number().int().positive().max(100).optional(),
8909
+ language: LanguageInputSchema
8910
+ }), /* @__PURE__ */ array(MediaItemSummarySchema).readonly(), { caller: "required" }),
8896
8911
  /** The caller's progress in one item; `null` when they have none. */
8897
8912
  getProgress: /* @__PURE__ */ method(/* @__PURE__ */ object({ itemId: /* @__PURE__ */ string().min(1) }), /* @__PURE__ */ MediaProgressSchema.nullable(), { caller: "required" }),
8898
8913
  /**
@@ -8919,7 +8934,10 @@ var mediaLibraryCapability = {
8919
8934
  caller: "required"
8920
8935
  }),
8921
8936
  /** What the caller started and did not finish, the latest first. */
8922
- listContinue: /* @__PURE__ */ method(/* @__PURE__ */ object({ limit: /* @__PURE__ */ number().int().positive().max(100).optional() }), /* @__PURE__ */ array(MediaContinueEntrySchema).readonly(), { caller: "required" }),
8937
+ listContinue: /* @__PURE__ */ method(/* @__PURE__ */ object({
8938
+ limit: /* @__PURE__ */ number().int().positive().max(100).optional(),
8939
+ language: LanguageInputSchema
8940
+ }), /* @__PURE__ */ array(MediaContinueEntrySchema).readonly(), { caller: "required" }),
8923
8941
  /** Start a scan of every source now; answers at once, the scan runs in the background. */
8924
8942
  rescan: /* @__PURE__ */ method(/* @__PURE__ */ object({}), /* @__PURE__ */ object({ started: /* @__PURE__ */ boolean() }), {
8925
8943
  kind: "mutation",
@@ -10033,6 +10051,16 @@ function parseRows(schema, rows, onInvalid) {
10033
10051
  }
10034
10052
  //#endregion
10035
10053
  //#region src/metadata.ts
10054
+ /**
10055
+ * One language's text of an item: either field may be absent (a provider can translate the title and
10056
+ * not the overview, or the reverse). The language is the provider's own tag, lower-cased (`it`, `pt`).
10057
+ */
10058
+ var TextTranslationSchema = object({
10059
+ title: string().nullable(),
10060
+ overview: string().nullable()
10061
+ });
10062
+ /** Translations by language tag. Absent means "never asked"; `{}` means "asked, none held". */
10063
+ var TranslationMapSchema = record(string(), TextTranslationSchema);
10036
10064
  var ProviderMatchSchema = object({
10037
10065
  providerId: string(),
10038
10066
  /** The provider's own id of the match, used to ask for its episodes. */
@@ -10044,7 +10072,9 @@ var ProviderMatchSchema = object({
10044
10072
  tmdbId: number().int().nullable(),
10045
10073
  imdbId: string().nullable(),
10046
10074
  poster: string().nullable(),
10047
- fanart: string().nullable()
10075
+ fanart: string().nullable(),
10076
+ /** The title and overview in other languages, when the provider answered them with the match. */
10077
+ translations: TranslationMapSchema.optional()
10048
10078
  });
10049
10079
  var ProviderEpisodeSchema = object({
10050
10080
  season: number().int(),
@@ -10185,6 +10215,8 @@ var ItemRowSchema = object({
10185
10215
  seasonNumber: number().int().nullable(),
10186
10216
  episodeNumber: number().int().nullable(),
10187
10217
  overview: string().nullable(),
10218
+ /** The title and overview in other languages; absent on a row written before they were kept. */
10219
+ translations: TranslationMapSchema.nullish(),
10188
10220
  tvdbId: number().int().nullable(),
10189
10221
  tmdbId: number().int().nullable(),
10190
10222
  imdbId: string().nullable(),
@@ -10255,6 +10287,10 @@ var COLLECTIONS = [
10255
10287
  int("seasonNumber"),
10256
10288
  int("episodeNumber"),
10257
10289
  text$3("overview"),
10290
+ {
10291
+ name: "translations",
10292
+ type: "JSON"
10293
+ },
10258
10294
  int("tvdbId"),
10259
10295
  int("tmdbId"),
10260
10296
  text$3("imdbId"),
@@ -10620,6 +10656,7 @@ var NO_LOCAL = {
10620
10656
  title: null,
10621
10657
  year: null,
10622
10658
  overview: null,
10659
+ translations: null,
10623
10660
  tvdbId: null,
10624
10661
  tmdbId: null,
10625
10662
  imdbId: null,
@@ -10659,6 +10696,7 @@ function merge(first, second) {
10659
10696
  title: pick$1(first.title, second.title),
10660
10697
  year: pick$1(first.year, second.year),
10661
10698
  overview: pick$1(first.overview, second.overview),
10699
+ translations: pick$1(first.translations, second.translations),
10662
10700
  tvdbId: pick$1(first.tvdbId, second.tvdbId),
10663
10701
  tmdbId: pick$1(first.tmdbId, second.tmdbId),
10664
10702
  imdbId: pick$1(first.imdbId, second.imdbId),
@@ -10715,6 +10753,34 @@ async function localMovie(reader, filePath) {
10715
10753
  fanart: firstImage(dir, listing, [`${base}-fanart`, ...solo ? ["fanart"] : []])
10716
10754
  };
10717
10755
  }
10756
+ //#endregion
10757
+ //#region src/item-text.ts
10758
+ /**
10759
+ * A language tag as the translations are keyed: lower-case, region dropped (`it-IT` is `it`).
10760
+ * `undefined` for an absent or empty tag.
10761
+ */
10762
+ function languageKey(tag) {
10763
+ const primary = tag?.trim().toLowerCase().split(/[-_]/)[0] ?? "";
10764
+ return primary === "" ? void 0 : primary;
10765
+ }
10766
+ /**
10767
+ * The text of `row` for a reader: the language they asked for, else the server's default language,
10768
+ * else the base text stored with the item. Each field falls through on its own, so a language that
10769
+ * translated the title and not the overview still gives the title.
10770
+ */
10771
+ function resolveItemText(row, requested, serverDefault) {
10772
+ let title = null;
10773
+ let overview = null;
10774
+ for (const key of [languageKey(requested), languageKey(serverDefault)]) {
10775
+ const entry = key === void 0 ? void 0 : row.translations?.[key];
10776
+ title ??= entry?.title ?? null;
10777
+ overview ??= entry?.overview ?? null;
10778
+ }
10779
+ return {
10780
+ title: title ?? row.title,
10781
+ overview: overview ?? row.overview
10782
+ };
10783
+ }
10718
10784
  var FILE_PLANE_PREFIX = "file";
10719
10785
  var HUB_PLANE_BASE = "/addon/media-library";
10720
10786
  var SEARCH_DEFAULT_LIMIT = 50;
@@ -10735,10 +10801,12 @@ var idList = (rows) => rows.map((row) => row.id);
10735
10801
  var LibraryStore = class {
10736
10802
  db;
10737
10803
  logger;
10804
+ serverLanguage;
10738
10805
  locks = /* @__PURE__ */ new Map();
10739
- constructor(db, logger) {
10806
+ constructor(db, logger, serverLanguage = () => "en") {
10740
10807
  this.db = db;
10741
10808
  this.logger = logger;
10809
+ this.serverLanguage = serverLanguage;
10742
10810
  }
10743
10811
  async init() {
10744
10812
  for (const declaration of COLLECTIONS) await this.db.declare(declaration);
@@ -10763,7 +10831,7 @@ var LibraryStore = class {
10763
10831
  return parseRows(ProgressRowSchema, await this.db.query(PROGRESS, filter), this.invalid(PROGRESS));
10764
10832
  }
10765
10833
  /** Build the wire summaries of `rows` for one caller: file facts and the caller's progress, two reads. */
10766
- async summaries(rows, userId) {
10834
+ async summaries(rows, userId, language) {
10767
10835
  const paths = rows.flatMap((row) => row.filePath === null ? [] : [row.filePath]);
10768
10836
  const files = /* @__PURE__ */ new Map();
10769
10837
  if (paths.length > 0) for (const file of await this.queryFiles({ whereIn: { path: paths } })) files.set(file.path, file);
@@ -10773,11 +10841,12 @@ var LibraryStore = class {
10773
10841
  where: { userId },
10774
10842
  whereIn: { itemId: playableIds }
10775
10843
  })) progress.set(entry.itemId, entry);
10844
+ const fallback = this.serverLanguage();
10776
10845
  return rows.map((row) => {
10777
- return toSummary(row, row.filePath === null ? void 0 : files.get(row.filePath), progress.get(row.id));
10846
+ return toSummary(row, row.filePath === null ? void 0 : files.get(row.filePath), progress.get(row.id), resolveItemText(row, language, fallback).title);
10778
10847
  });
10779
10848
  }
10780
- pageOf = async (kind, userId, limit, offset) => {
10849
+ pageOf = async (kind, userId, limit, offset, language) => {
10781
10850
  const rows = await this.queryItems({
10782
10851
  where: {
10783
10852
  kind,
@@ -10795,17 +10864,17 @@ var LibraryStore = class {
10795
10864
  topLevel: true
10796
10865
  } });
10797
10866
  return {
10798
- items: await this.summaries(rows, userId),
10867
+ items: await this.summaries(rows, userId, language),
10799
10868
  total
10800
10869
  };
10801
10870
  };
10802
- listSeries(userId, limit, offset) {
10803
- return this.pageOf("series", userId, limit, offset);
10871
+ listSeries(userId, limit, offset, language) {
10872
+ return this.pageOf("series", userId, limit, offset, language);
10804
10873
  }
10805
- listMovies(userId, limit, offset) {
10806
- return this.pageOf("movie", userId, limit, offset);
10874
+ listMovies(userId, limit, offset, language) {
10875
+ return this.pageOf("movie", userId, limit, offset, language);
10807
10876
  }
10808
- async listRecentlyAdded(userId, limit) {
10877
+ async listRecentlyAdded(userId, limit, language) {
10809
10878
  const rows = await this.queryItems({
10810
10879
  where: { topLevel: true },
10811
10880
  orderBy: {
@@ -10814,19 +10883,21 @@ var LibraryStore = class {
10814
10883
  },
10815
10884
  limit: limit ?? RECENT_DEFAULT_LIMIT
10816
10885
  });
10817
- return this.summaries(rows, userId);
10886
+ return this.summaries(rows, userId, language);
10818
10887
  }
10819
- async search(userId, query, limit) {
10888
+ async search(userId, query, limit, language) {
10820
10889
  const needle = foldTitle(query);
10821
10890
  if (needle === "") return [];
10822
- const hits = (await this.queryItems({
10891
+ const rows = await this.queryItems({
10823
10892
  where: { topLevel: true },
10824
10893
  orderBy: {
10825
10894
  field: "sortTitle",
10826
10895
  direction: "asc"
10827
10896
  }
10828
- })).filter((row) => row.titleFold.includes(needle)).slice(0, limit ?? SEARCH_DEFAULT_LIMIT);
10829
- return this.summaries(hits, userId);
10897
+ });
10898
+ const fallback = this.serverLanguage();
10899
+ const hits = rows.filter((row) => row.titleFold.includes(needle) || foldTitle(resolveItemText(row, language, fallback).title).includes(needle)).slice(0, limit ?? SEARCH_DEFAULT_LIMIT);
10900
+ return this.summaries(hits, userId, language);
10830
10901
  }
10831
10902
  episodesOf(seriesId) {
10832
10903
  return this.queryItems({
@@ -10864,7 +10935,7 @@ var LibraryStore = class {
10864
10935
  watchedCount: entry.watched
10865
10936
  }));
10866
10937
  }
10867
- async listEpisodes(userId, seriesId, seasonNumber) {
10938
+ async listEpisodes(userId, seriesId, seasonNumber, language) {
10868
10939
  const rows = await this.queryItems({
10869
10940
  where: {
10870
10941
  parentId: seriesId,
@@ -10875,18 +10946,23 @@ var LibraryStore = class {
10875
10946
  direction: "asc"
10876
10947
  }
10877
10948
  });
10878
- return (await this.summaries(rows, userId)).map((summary, index) => ({
10879
- ...summary,
10880
- overview: rows[index]?.overview ?? null
10881
- }));
10949
+ const summaries = await this.summaries(rows, userId, language);
10950
+ const fallback = this.serverLanguage();
10951
+ return summaries.map((summary, index) => {
10952
+ const row = rows[index];
10953
+ return {
10954
+ ...summary,
10955
+ overview: row === void 0 ? null : resolveItemText(row, language, fallback).overview
10956
+ };
10957
+ });
10882
10958
  }
10883
- async getItem(userId, itemId) {
10959
+ async getItem(userId, itemId, language) {
10884
10960
  const [row] = await this.queryItems({
10885
10961
  where: { id: itemId },
10886
10962
  limit: 1
10887
10963
  });
10888
10964
  if (row === void 0) return null;
10889
- const [summary] = await this.summaries([row], userId);
10965
+ const [summary] = await this.summaries([row], userId, language);
10890
10966
  if (summary === void 0) return null;
10891
10967
  const [file] = row.filePath === null ? [] : await this.queryFiles({
10892
10968
  where: { path: row.filePath },
@@ -10894,7 +10970,7 @@ var LibraryStore = class {
10894
10970
  });
10895
10971
  return {
10896
10972
  ...summary,
10897
- overview: row.overview,
10973
+ overview: resolveItemText(row, language, this.serverLanguage()).overview,
10898
10974
  ids: {
10899
10975
  tvdb: row.tvdbId,
10900
10976
  tmdb: row.tmdbId,
@@ -11084,7 +11160,7 @@ var LibraryStore = class {
11084
11160
  watched
11085
11161
  };
11086
11162
  }
11087
- async listContinue(userId, limit) {
11163
+ async listContinue(userId, limit, language) {
11088
11164
  const wanted = limit ?? CONTINUE_DEFAULT_LIMIT;
11089
11165
  const rows = (await this.queryProgress({
11090
11166
  where: {
@@ -11099,7 +11175,7 @@ var LibraryStore = class {
11099
11175
  })).filter((row) => row.positionMs > 0);
11100
11176
  if (rows.length === 0) return [];
11101
11177
  const items = await this.queryItems({ whereIn: { id: rows.map((row) => row.itemId) } });
11102
- const summaries = new Map((await this.summaries(items, userId)).map((summary) => [summary.id, summary]));
11178
+ const summaries = new Map((await this.summaries(items, userId, language)).map((summary) => [summary.id, summary]));
11103
11179
  const entries = [];
11104
11180
  for (const row of rows) {
11105
11181
  const item = summaries.get(row.itemId);
@@ -11130,11 +11206,11 @@ function toFileInfo(file) {
11130
11206
  probed: file.probeOk
11131
11207
  };
11132
11208
  }
11133
- function toSummary(row, file, progress) {
11209
+ function toSummary(row, file, progress, title) {
11134
11210
  return {
11135
11211
  id: row.id,
11136
11212
  kind: row.kind,
11137
- title: row.title,
11213
+ title,
11138
11214
  year: row.year,
11139
11215
  seriesId: row.kind === "episode" ? row.parentId : null,
11140
11216
  seasonNumber: row.seasonNumber,
@@ -12384,6 +12460,51 @@ function createOmdbProvider(deps) {
12384
12460
  }
12385
12461
  };
12386
12462
  }
12463
+ /**
12464
+ * The server's default language, kept in memory so no catalogue read waits on the system call.
12465
+ * A read answers what is held; one that finds it older than {@link SERVER_LANGUAGE_REFRESH_MS}
12466
+ * starts a refresh and does not wait for it. A refresh that fails changes nothing (the last answer
12467
+ * stays, English when there never was one) and says so in the log.
12468
+ */
12469
+ var ServerLanguage = class {
12470
+ read;
12471
+ now;
12472
+ logger;
12473
+ value = "en";
12474
+ attemptedAt = null;
12475
+ inFlight = null;
12476
+ constructor(read, now, logger) {
12477
+ this.read = read;
12478
+ this.now = now;
12479
+ this.logger = logger;
12480
+ }
12481
+ /** Ask now and wait; used at boot and at the start of a scan, never on a read. */
12482
+ refresh() {
12483
+ if (this.inFlight !== null) return this.inFlight;
12484
+ const run = (async () => {
12485
+ try {
12486
+ const read = await this.read();
12487
+ if (read === null) this.logger.warn("server default language unreadable: keeping the last one", { meta: { kept: this.value } });
12488
+ else this.value = read;
12489
+ } catch (error) {
12490
+ this.logger.warn("server default language not read: keeping the last one", { meta: {
12491
+ error: errMsg(error),
12492
+ kept: this.value
12493
+ } });
12494
+ } finally {
12495
+ this.attemptedAt = this.now();
12496
+ this.inFlight = null;
12497
+ }
12498
+ })();
12499
+ this.inFlight = run;
12500
+ return run;
12501
+ }
12502
+ /** The held language; starts a background refresh when it is stale. Never throws, never waits. */
12503
+ current() {
12504
+ if (this.attemptedAt === null || this.now() - this.attemptedAt >= 6e4) this.refresh();
12505
+ return this.value;
12506
+ }
12507
+ };
12387
12508
  //#endregion
12388
12509
  //#region src/tmdb.ts
12389
12510
  var TMDB_ID = "tmdb";
@@ -12399,6 +12520,15 @@ var SearchSchema$2 = object({ results: array(object({
12399
12520
  release_date: string().nullish(),
12400
12521
  first_air_date: string().nullish()
12401
12522
  })) });
12523
+ /** `append_to_response=translations`: one entry per language TMDB holds, `data` carries the text. */
12524
+ var TranslationsSchema = object({ translations: array(object({
12525
+ iso_639_1: string(),
12526
+ data: object({
12527
+ title: string().nullish(),
12528
+ name: string().nullish(),
12529
+ overview: string().nullish()
12530
+ }).nullish()
12531
+ })) });
12402
12532
  var DetailsSchema = object({
12403
12533
  id: number().int(),
12404
12534
  title: string().nullish(),
@@ -12413,7 +12543,8 @@ var DetailsSchema = object({
12413
12543
  imdb_id: string().nullish(),
12414
12544
  tvdb_id: number().int().nullish()
12415
12545
  }).nullish(),
12416
- seasons: array(object({ season_number: number().int() })).nullish()
12546
+ seasons: array(object({ season_number: number().int() })).nullish(),
12547
+ translations: TranslationsSchema.nullish()
12417
12548
  });
12418
12549
  var FindSchema = object({
12419
12550
  movie_results: array(object({ id: number().int() })).default([]),
@@ -12426,6 +12557,10 @@ var SeasonSchema = object({ episodes: array(object({
12426
12557
  overview: string().nullish(),
12427
12558
  still_path: string().nullish()
12428
12559
  })) });
12560
+ /** TMDB's tag for a locale: English keeps the region it was always asked in, others are sent bare. */
12561
+ function tmdbLanguageOf(locale) {
12562
+ return locale === "en" ? DEFAULT_LANGUAGE : locale;
12563
+ }
12429
12564
  function yearOf$1(date) {
12430
12565
  const match = /^(\d{4})/.exec(date ?? "");
12431
12566
  return match?.[1] === void 0 ? null : Number(match[1]);
@@ -12437,6 +12572,25 @@ function text(value) {
12437
12572
  function image(size, path) {
12438
12573
  return path === null || path === void 0 || !path.startsWith("/") ? null : `${IMAGES}/${size}${path}`;
12439
12574
  }
12575
+ /**
12576
+ * The per-language text of a details answer, keyed by TMDB's language tag (`iso_639_1`, lower-cased).
12577
+ * A language that holds neither a title nor an overview is left out; a regional variant of a language
12578
+ * already seen (`pt-BR` after `pt-PT`) never replaces the first.
12579
+ */
12580
+ function translationsOf(details) {
12581
+ const out = {};
12582
+ for (const entry of details.translations?.translations ?? []) {
12583
+ const tag = entry.iso_639_1.trim().toLowerCase();
12584
+ const title = text(entry.data?.title ?? entry.data?.name);
12585
+ const overview = text(entry.data?.overview);
12586
+ if (tag === "" || out[tag] !== void 0 || title === null && overview === null) continue;
12587
+ out[tag] = {
12588
+ title,
12589
+ overview
12590
+ };
12591
+ }
12592
+ return out;
12593
+ }
12440
12594
  var nameOf = (entry) => entry.title ?? entry.name ?? "";
12441
12595
  var yearIn = (entry) => yearOf$1(entry.release_date ?? entry.first_air_date);
12442
12596
  /** TMDB: movies and series, with the installation's own read token. All calls go through the shared remote fetch. */
@@ -12470,11 +12624,12 @@ function createTmdbProvider(deps) {
12470
12624
  tmdbId: details.id,
12471
12625
  imdbId: text(details.external_ids?.imdb_id) ?? text(details.imdb_id),
12472
12626
  poster: image("w500", details.poster_path),
12473
- fanart: image("w1280", details.backdrop_path)
12627
+ fanart: image("w1280", details.backdrop_path),
12628
+ translations: translationsOf(details)
12474
12629
  });
12475
12630
  const detailsOf = async (kind, id) => {
12476
12631
  try {
12477
- return matchOf(DetailsSchema.parse(await call(`/${segment(kind)}/${id}`, { append_to_response: "external_ids" })));
12632
+ return matchOf(DetailsSchema.parse(await call(`/${segment(kind)}/${id}`, { append_to_response: "external_ids,translations" })));
12478
12633
  } catch (error) {
12479
12634
  if (error instanceof Error && /\b404\b/.test(error.message)) return null;
12480
12635
  throw error;
@@ -12482,6 +12637,7 @@ function createTmdbProvider(deps) {
12482
12637
  };
12483
12638
  return {
12484
12639
  id: TMDB_ID,
12640
+ translates: true,
12485
12641
  kinds: ["movie", "series"],
12486
12642
  lookupBy: [
12487
12643
  "tmdbId",
@@ -13209,17 +13365,17 @@ function createFfmpegProber(binaryPath) {
13209
13365
  /** The `media-library` capability over the store. A caller reads and writes only their own progress. */
13210
13366
  function createMediaLibraryProvider(store, scans) {
13211
13367
  return {
13212
- listSeries: ({ limit, offset, caller }) => store.listSeries(caller.userId, limit, offset),
13213
- listMovies: ({ limit, offset, caller }) => store.listMovies(caller.userId, limit, offset),
13368
+ listSeries: ({ limit, offset, language, caller }) => store.listSeries(caller.userId, limit, offset, language),
13369
+ listMovies: ({ limit, offset, language, caller }) => store.listMovies(caller.userId, limit, offset, language),
13214
13370
  listSeasons: ({ seriesId, caller }) => store.listSeasons(caller.userId, seriesId),
13215
- listEpisodes: ({ seriesId, seasonNumber, caller }) => store.listEpisodes(caller.userId, seriesId, seasonNumber),
13216
- getItem: ({ itemId, caller }) => store.getItem(caller.userId, itemId),
13217
- search: ({ query, limit, caller }) => store.search(caller.userId, query, limit),
13218
- listRecentlyAdded: ({ limit, caller }) => store.listRecentlyAdded(caller.userId, limit),
13371
+ listEpisodes: ({ seriesId, seasonNumber, language, caller }) => store.listEpisodes(caller.userId, seriesId, seasonNumber, language),
13372
+ getItem: ({ itemId, language, caller }) => store.getItem(caller.userId, itemId, language),
13373
+ search: ({ query, limit, language, caller }) => store.search(caller.userId, query, limit, language),
13374
+ listRecentlyAdded: ({ limit, language, caller }) => store.listRecentlyAdded(caller.userId, limit, language),
13219
13375
  getProgress: ({ itemId, caller }) => store.getProgress(caller.userId, itemId),
13220
13376
  setProgress: ({ caller, ...input }) => store.setProgress(caller.userId, input),
13221
13377
  markWatched: ({ caller, ...input }) => store.markWatched(caller.userId, input),
13222
- listContinue: ({ limit, caller }) => store.listContinue(caller.userId, limit),
13378
+ listContinue: ({ limit, language, caller }) => store.listContinue(caller.userId, limit, language),
13223
13379
  rescan: async () => ({ started: scans.start("manual") }),
13224
13380
  getScanStatus: async () => scans.status()
13225
13381
  };
@@ -13235,6 +13391,7 @@ function fill(into, from) {
13235
13391
  title: into.title ?? from.title,
13236
13392
  year: into.year ?? from.year,
13237
13393
  overview: into.overview ?? from.overview,
13394
+ translations: into.translations ?? from.translations,
13238
13395
  tvdbId: into.tvdbId ?? from.tvdbId,
13239
13396
  tmdbId: into.tmdbId ?? from.tmdbId,
13240
13397
  imdbId: into.imdbId ?? from.imdbId,
@@ -13307,6 +13464,14 @@ var Enricher = class {
13307
13464
  if ((this.failures.get(id) ?? 0) >= PROVIDER_FAILURE_LIMIT) return null;
13308
13465
  return this.deps.providers.find((entry) => entry.id === id) ?? null;
13309
13466
  }
13467
+ /**
13468
+ * The cache namespace of a provider. A translating one answers its base text in the server's
13469
+ * language, so that language is part of the key: changing it asks again instead of serving the old
13470
+ * language for the cache lifetime.
13471
+ */
13472
+ keyOf(provider) {
13473
+ return provider.translates === true && this.deps.language !== void 0 ? `${provider.id}@${this.deps.language}` : provider.id;
13474
+ }
13310
13475
  imageProvider(id) {
13311
13476
  if ((this.failures.get(id) ?? 0) >= PROVIDER_FAILURE_LIMIT) return null;
13312
13477
  return this.deps.images?.find((entry) => entry.id === id) ?? null;
@@ -13381,10 +13546,19 @@ var Enricher = class {
13381
13546
  }
13382
13547
  });
13383
13548
  }
13549
+ /**
13550
+ * The cached answer for `key`, unless it predates translations: a match a translating provider
13551
+ * cached before it carried them is asked again, so a rollout does not wait out the cache lifetime.
13552
+ */
13553
+ cachedMatch(provider, key) {
13554
+ const known = this.deps.cache.getMatch(key);
13555
+ if (known === null) return null;
13556
+ return known.found && provider.translates === true && known.match.translations === void 0 ? null : known;
13557
+ }
13384
13558
  /** A pinned id is asked for directly: an answer of "nothing" is final, never turned into a title guess. */
13385
13559
  async lookup(provider, ask, item, kind, pin) {
13386
- const key = `${provider.id}:lookup:${kind}:${pin.tvdbId ?? ""}:${pin.imdbId ?? ""}:${pin.tmdbId ?? ""}`;
13387
- const known = this.deps.cache.getMatch(key);
13560
+ const key = `${this.keyOf(provider)}:lookup:${kind}:${pin.tvdbId ?? ""}:${pin.imdbId ?? ""}:${pin.tmdbId ?? ""}`;
13561
+ const known = this.cachedMatch(provider, key);
13388
13562
  if (known !== null) return known.found ? known.match : null;
13389
13563
  const pending = this.matches.get(key);
13390
13564
  if (pending !== void 0) return pending;
@@ -13435,8 +13609,8 @@ var Enricher = class {
13435
13609
  const found = await this.lookup(provider, provider.lookup.bind(provider), item, kind, ask.ids);
13436
13610
  if (found !== null || ask.fromPin) return found;
13437
13611
  }
13438
- const key = `${provider.id}:id:${kind}:${foldTitle(title)}:${year ?? 0}`;
13439
- const known = this.deps.cache.getMatch(key);
13612
+ const key = `${this.keyOf(provider)}:id:${kind}:${foldTitle(title)}:${year ?? 0}`;
13613
+ const known = this.cachedMatch(provider, key);
13440
13614
  if (known !== null) return known.found ? known.match : null;
13441
13615
  const pending = this.matches.get(key);
13442
13616
  if (pending !== void 0) return pending;
@@ -13457,7 +13631,7 @@ var Enricher = class {
13457
13631
  return run;
13458
13632
  }
13459
13633
  async episodesOf(provider, item, match) {
13460
- const key = `${provider.id}:eps:${match.remoteId}`;
13634
+ const key = `${this.keyOf(provider)}:eps:${match.remoteId}`;
13461
13635
  const known = this.deps.cache.getEpisodes(key);
13462
13636
  if (known !== null) return known.episodes;
13463
13637
  try {
@@ -13479,6 +13653,7 @@ var Enricher = class {
13479
13653
  title: match.title,
13480
13654
  year: match.year,
13481
13655
  overview: match.overview,
13656
+ translations: match.translations ?? null,
13482
13657
  tvdbId: match.tvdbId,
13483
13658
  tmdbId: match.tmdbId,
13484
13659
  imdbId: match.imdbId,
@@ -13507,9 +13682,9 @@ var Enricher = class {
13507
13682
  canAsk(provider, item) {
13508
13683
  return provider.kinds.includes(item.kind === "movie" ? "movie" : "series");
13509
13684
  }
13510
- needsOnline(item, acc) {
13685
+ needsOnline(provider, item, acc) {
13511
13686
  if (item.kind === "episode") return acc.overview === null || acc.poster === null || item.titlePlaceholder && acc.title === null;
13512
- return acc.overview === null || acc.poster === null;
13687
+ return acc.overview === null || acc.poster === null || provider.translates === true && acc.translations === null;
13513
13688
  }
13514
13689
  async localLayer(item, firstEpisodeFile) {
13515
13690
  const { reader } = this.deps;
@@ -13545,7 +13720,7 @@ var Enricher = class {
13545
13720
  const images = this.imageProvider(step);
13546
13721
  const provider = this.provider(step);
13547
13722
  if (images !== null && item.kind !== "episode" && images.kinds.includes(item.kind === "movie" ? "movie" : "series") && (acc.poster === null || acc.fanart === null)) acc = fill(acc, await this.imageLayer(images, item, acc));
13548
- else if (provider !== null && this.canAsk(provider, item) && this.needsOnline(item, acc)) acc = fill(acc, await this.onlineLayer(provider, item, acc, resolved, held));
13723
+ else if (provider !== null && this.canAsk(provider, item) && this.needsOnline(provider, item, acc)) acc = fill(acc, await this.onlineLayer(provider, item, acc, resolved, held));
13549
13724
  }
13550
13725
  applyPin();
13551
13726
  acc = fill(acc, fileLayer(item));
@@ -13557,6 +13732,7 @@ var Enricher = class {
13557
13732
  titleFold: foldTitle(title),
13558
13733
  year: acc.year,
13559
13734
  overview: acc.overview,
13735
+ translations: acc.translations,
13560
13736
  tvdbId: acc.tvdbId,
13561
13737
  tmdbId: acc.tmdbId,
13562
13738
  imdbId: acc.imdbId,
@@ -13597,6 +13773,7 @@ function newItem(base) {
13597
13773
  seasonNumber: null,
13598
13774
  episodeNumber: null,
13599
13775
  overview: null,
13776
+ translations: null,
13600
13777
  tvdbId: null,
13601
13778
  tmdbId: null,
13602
13779
  imdbId: null,
@@ -13753,13 +13930,13 @@ async function folderItems(root, paths, reader) {
13753
13930
  //#endregion
13754
13931
  //#region src/scanner.ts
13755
13932
  /** The online providers this scan may ask: the fixed ones, plus each keyed one whose key is set. */
13756
- function onlineProviders(deps, sources) {
13933
+ function onlineProviders(deps, sources, language = "en") {
13757
13934
  const keyed = (make, key) => make !== void 0 && (key ?? "") !== "" ? [make(key ?? "")] : [];
13758
13935
  const fanartKey = sources.fanartApiKey ?? "";
13759
13936
  return {
13760
13937
  providers: [
13761
13938
  ...deps.providers ?? [],
13762
- ...keyed(deps.createTmdb, sources.tmdbToken),
13939
+ ...deps.createTmdb !== void 0 && (sources.tmdbToken ?? "") !== "" ? [deps.createTmdb(sources.tmdbToken ?? "", language)] : [],
13763
13940
  ...keyed(deps.createTvdb, sources.tvdbApiKey),
13764
13941
  ...keyed(deps.createOmdb, sources.omdbApiKey),
13765
13942
  ...deps.createAnilist !== void 0 && (sources.metadataSteps ?? []).includes("anilist") ? [deps.createAnilist()] : []
@@ -13907,12 +14084,14 @@ async function scanLibrary(deps, sources) {
13907
14084
  logger.warn("metadata matches could not be saved: they are asked for again next scan", { meta: { error: error instanceof Error ? error.message : String(error) } });
13908
14085
  }
13909
14086
  };
14087
+ const language = await deps.language?.() ?? "en";
13910
14088
  for (const [index, entry] of harvests.entries()) {
13911
14089
  try {
13912
- const online = onlineProviders(deps, sources);
14090
+ const online = onlineProviders(deps, sources, language);
13913
14091
  const items = await enrichItems(entry.items, sources.metadataSteps ?? DEFAULT_STEPS, {
13914
14092
  reader,
13915
14093
  providers: online.providers,
14094
+ language,
13916
14095
  images: online.images,
13917
14096
  cache,
13918
14097
  logger,
@@ -14186,7 +14365,9 @@ var MediaLibraryAddon = class extends BaseAddon {
14186
14365
  const { ctx } = this;
14187
14366
  const logger = ctx.logger;
14188
14367
  const db = settingsStoreDb(ctx.api.settingsStore);
14189
- const store = new LibraryStore(db, logger);
14368
+ const serverLanguage = new ServerLanguage(async () => (await ctx.api.system.info.query()).defaultLanguage, () => Date.now(), logger);
14369
+ await serverLanguage.refresh();
14370
+ const store = new LibraryStore(db, logger, () => serverLanguage.current());
14190
14371
  await store.init();
14191
14372
  const ffmpeg = await ctx.deps.ensureFfmpeg();
14192
14373
  const scans = new ScanController({
@@ -14207,9 +14388,14 @@ var MediaLibraryAddon = class extends BaseAddon {
14207
14388
  },
14208
14389
  probe: createFfmpegProber(ffmpeg),
14209
14390
  providers: [createTvmazeProvider({ fetch: httpRemoteFetch })],
14210
- createTmdb: (token) => createTmdbProvider({
14391
+ language: async () => {
14392
+ await serverLanguage.refresh();
14393
+ return serverLanguage.current();
14394
+ },
14395
+ createTmdb: (token, language) => createTmdbProvider({
14211
14396
  fetch: httpRemoteFetch,
14212
- token
14397
+ token,
14398
+ language: tmdbLanguageOf(language)
14213
14399
  }),
14214
14400
  createTvdb: (apiKey) => createTvdbProvider({
14215
14401
  fetch: httpRemoteFetch,
@@ -8859,7 +8859,14 @@ var MediaScanStatusSchema = /* @__PURE__ */ object({
8859
8859
  reused: /* @__PURE__ */ number().int().nonnegative(),
8860
8860
  skipped: /* @__PURE__ */ number().int().nonnegative()
8861
8861
  });
8862
+ /**
8863
+ * The language the caller wants item text in (`title`, `overview`): a locale tag such as `it`; a
8864
+ * regional form (`it-IT`) reads as its language. Absent means the server's default language. A language
8865
+ * the item has no text in falls back to the server default, then to the text stored with the item.
8866
+ */
8867
+ var LanguageInputSchema = /* @__PURE__ */ string().min(2).max(35).optional();
8862
8868
  var PageInputSchema = /* @__PURE__ */ object({
8869
+ language: LanguageInputSchema,
8863
8870
  limit: /* @__PURE__ */ number().int().positive().max(500).optional(),
8864
8871
  offset: /* @__PURE__ */ number().int().nonnegative().optional()
8865
8872
  });
@@ -8878,17 +8885,25 @@ var mediaLibraryCapability = {
8878
8885
  /** The episodes of one season in order, each with the caller's progress. */
8879
8886
  listEpisodes: /* @__PURE__ */ method(/* @__PURE__ */ object({
8880
8887
  seriesId: /* @__PURE__ */ string().min(1),
8881
- seasonNumber: /* @__PURE__ */ number().int()
8888
+ seasonNumber: /* @__PURE__ */ number().int(),
8889
+ language: LanguageInputSchema
8882
8890
  }), /* @__PURE__ */ array(MediaEpisodeSummarySchema).readonly(), { caller: "required" }),
8883
8891
  /** One item with its streams and direct-play path; `null` when the id is unknown. */
8884
- getItem: /* @__PURE__ */ method(/* @__PURE__ */ object({ itemId: /* @__PURE__ */ string().min(1) }), /* @__PURE__ */ MediaItemDetailSchema.nullable(), { caller: "required" }),
8892
+ getItem: /* @__PURE__ */ method(/* @__PURE__ */ object({
8893
+ itemId: /* @__PURE__ */ string().min(1),
8894
+ language: LanguageInputSchema
8895
+ }), /* @__PURE__ */ MediaItemDetailSchema.nullable(), { caller: "required" }),
8885
8896
  /** Series and movies whose title contains the query, case and accents ignored. */
8886
8897
  search: /* @__PURE__ */ method(/* @__PURE__ */ object({
8887
8898
  query: /* @__PURE__ */ string().min(1),
8888
- limit: /* @__PURE__ */ number().int().positive().max(100).optional()
8899
+ limit: /* @__PURE__ */ number().int().positive().max(100).optional(),
8900
+ language: LanguageInputSchema
8889
8901
  }), /* @__PURE__ */ array(MediaItemSummarySchema).readonly(), { caller: "required" }),
8890
8902
  /** The series and movies added most recently. */
8891
- listRecentlyAdded: /* @__PURE__ */ method(/* @__PURE__ */ object({ limit: /* @__PURE__ */ number().int().positive().max(100).optional() }), /* @__PURE__ */ array(MediaItemSummarySchema).readonly(), { caller: "required" }),
8903
+ listRecentlyAdded: /* @__PURE__ */ method(/* @__PURE__ */ object({
8904
+ limit: /* @__PURE__ */ number().int().positive().max(100).optional(),
8905
+ language: LanguageInputSchema
8906
+ }), /* @__PURE__ */ array(MediaItemSummarySchema).readonly(), { caller: "required" }),
8892
8907
  /** The caller's progress in one item; `null` when they have none. */
8893
8908
  getProgress: /* @__PURE__ */ method(/* @__PURE__ */ object({ itemId: /* @__PURE__ */ string().min(1) }), /* @__PURE__ */ MediaProgressSchema.nullable(), { caller: "required" }),
8894
8909
  /**
@@ -8915,7 +8930,10 @@ var mediaLibraryCapability = {
8915
8930
  caller: "required"
8916
8931
  }),
8917
8932
  /** What the caller started and did not finish, the latest first. */
8918
- listContinue: /* @__PURE__ */ method(/* @__PURE__ */ object({ limit: /* @__PURE__ */ number().int().positive().max(100).optional() }), /* @__PURE__ */ array(MediaContinueEntrySchema).readonly(), { caller: "required" }),
8933
+ listContinue: /* @__PURE__ */ method(/* @__PURE__ */ object({
8934
+ limit: /* @__PURE__ */ number().int().positive().max(100).optional(),
8935
+ language: LanguageInputSchema
8936
+ }), /* @__PURE__ */ array(MediaContinueEntrySchema).readonly(), { caller: "required" }),
8919
8937
  /** Start a scan of every source now; answers at once, the scan runs in the background. */
8920
8938
  rescan: /* @__PURE__ */ method(/* @__PURE__ */ object({}), /* @__PURE__ */ object({ started: /* @__PURE__ */ boolean() }), {
8921
8939
  kind: "mutation",
@@ -10029,6 +10047,16 @@ function parseRows(schema, rows, onInvalid) {
10029
10047
  }
10030
10048
  //#endregion
10031
10049
  //#region src/metadata.ts
10050
+ /**
10051
+ * One language's text of an item: either field may be absent (a provider can translate the title and
10052
+ * not the overview, or the reverse). The language is the provider's own tag, lower-cased (`it`, `pt`).
10053
+ */
10054
+ var TextTranslationSchema = object({
10055
+ title: string().nullable(),
10056
+ overview: string().nullable()
10057
+ });
10058
+ /** Translations by language tag. Absent means "never asked"; `{}` means "asked, none held". */
10059
+ var TranslationMapSchema = record(string(), TextTranslationSchema);
10032
10060
  var ProviderMatchSchema = object({
10033
10061
  providerId: string(),
10034
10062
  /** The provider's own id of the match, used to ask for its episodes. */
@@ -10040,7 +10068,9 @@ var ProviderMatchSchema = object({
10040
10068
  tmdbId: number().int().nullable(),
10041
10069
  imdbId: string().nullable(),
10042
10070
  poster: string().nullable(),
10043
- fanart: string().nullable()
10071
+ fanart: string().nullable(),
10072
+ /** The title and overview in other languages, when the provider answered them with the match. */
10073
+ translations: TranslationMapSchema.optional()
10044
10074
  });
10045
10075
  var ProviderEpisodeSchema = object({
10046
10076
  season: number().int(),
@@ -10181,6 +10211,8 @@ var ItemRowSchema = object({
10181
10211
  seasonNumber: number().int().nullable(),
10182
10212
  episodeNumber: number().int().nullable(),
10183
10213
  overview: string().nullable(),
10214
+ /** The title and overview in other languages; absent on a row written before they were kept. */
10215
+ translations: TranslationMapSchema.nullish(),
10184
10216
  tvdbId: number().int().nullable(),
10185
10217
  tmdbId: number().int().nullable(),
10186
10218
  imdbId: string().nullable(),
@@ -10251,6 +10283,10 @@ var COLLECTIONS = [
10251
10283
  int("seasonNumber"),
10252
10284
  int("episodeNumber"),
10253
10285
  text$3("overview"),
10286
+ {
10287
+ name: "translations",
10288
+ type: "JSON"
10289
+ },
10254
10290
  int("tvdbId"),
10255
10291
  int("tmdbId"),
10256
10292
  text$3("imdbId"),
@@ -10616,6 +10652,7 @@ var NO_LOCAL = {
10616
10652
  title: null,
10617
10653
  year: null,
10618
10654
  overview: null,
10655
+ translations: null,
10619
10656
  tvdbId: null,
10620
10657
  tmdbId: null,
10621
10658
  imdbId: null,
@@ -10655,6 +10692,7 @@ function merge(first, second) {
10655
10692
  title: pick$1(first.title, second.title),
10656
10693
  year: pick$1(first.year, second.year),
10657
10694
  overview: pick$1(first.overview, second.overview),
10695
+ translations: pick$1(first.translations, second.translations),
10658
10696
  tvdbId: pick$1(first.tvdbId, second.tvdbId),
10659
10697
  tmdbId: pick$1(first.tmdbId, second.tmdbId),
10660
10698
  imdbId: pick$1(first.imdbId, second.imdbId),
@@ -10711,6 +10749,34 @@ async function localMovie(reader, filePath) {
10711
10749
  fanart: firstImage(dir, listing, [`${base}-fanart`, ...solo ? ["fanart"] : []])
10712
10750
  };
10713
10751
  }
10752
+ //#endregion
10753
+ //#region src/item-text.ts
10754
+ /**
10755
+ * A language tag as the translations are keyed: lower-case, region dropped (`it-IT` is `it`).
10756
+ * `undefined` for an absent or empty tag.
10757
+ */
10758
+ function languageKey(tag) {
10759
+ const primary = tag?.trim().toLowerCase().split(/[-_]/)[0] ?? "";
10760
+ return primary === "" ? void 0 : primary;
10761
+ }
10762
+ /**
10763
+ * The text of `row` for a reader: the language they asked for, else the server's default language,
10764
+ * else the base text stored with the item. Each field falls through on its own, so a language that
10765
+ * translated the title and not the overview still gives the title.
10766
+ */
10767
+ function resolveItemText(row, requested, serverDefault) {
10768
+ let title = null;
10769
+ let overview = null;
10770
+ for (const key of [languageKey(requested), languageKey(serverDefault)]) {
10771
+ const entry = key === void 0 ? void 0 : row.translations?.[key];
10772
+ title ??= entry?.title ?? null;
10773
+ overview ??= entry?.overview ?? null;
10774
+ }
10775
+ return {
10776
+ title: title ?? row.title,
10777
+ overview: overview ?? row.overview
10778
+ };
10779
+ }
10714
10780
  var FILE_PLANE_PREFIX = "file";
10715
10781
  var HUB_PLANE_BASE = "/addon/media-library";
10716
10782
  var SEARCH_DEFAULT_LIMIT = 50;
@@ -10731,10 +10797,12 @@ var idList = (rows) => rows.map((row) => row.id);
10731
10797
  var LibraryStore = class {
10732
10798
  db;
10733
10799
  logger;
10800
+ serverLanguage;
10734
10801
  locks = /* @__PURE__ */ new Map();
10735
- constructor(db, logger) {
10802
+ constructor(db, logger, serverLanguage = () => "en") {
10736
10803
  this.db = db;
10737
10804
  this.logger = logger;
10805
+ this.serverLanguage = serverLanguage;
10738
10806
  }
10739
10807
  async init() {
10740
10808
  for (const declaration of COLLECTIONS) await this.db.declare(declaration);
@@ -10759,7 +10827,7 @@ var LibraryStore = class {
10759
10827
  return parseRows(ProgressRowSchema, await this.db.query(PROGRESS, filter), this.invalid(PROGRESS));
10760
10828
  }
10761
10829
  /** Build the wire summaries of `rows` for one caller: file facts and the caller's progress, two reads. */
10762
- async summaries(rows, userId) {
10830
+ async summaries(rows, userId, language) {
10763
10831
  const paths = rows.flatMap((row) => row.filePath === null ? [] : [row.filePath]);
10764
10832
  const files = /* @__PURE__ */ new Map();
10765
10833
  if (paths.length > 0) for (const file of await this.queryFiles({ whereIn: { path: paths } })) files.set(file.path, file);
@@ -10769,11 +10837,12 @@ var LibraryStore = class {
10769
10837
  where: { userId },
10770
10838
  whereIn: { itemId: playableIds }
10771
10839
  })) progress.set(entry.itemId, entry);
10840
+ const fallback = this.serverLanguage();
10772
10841
  return rows.map((row) => {
10773
- return toSummary(row, row.filePath === null ? void 0 : files.get(row.filePath), progress.get(row.id));
10842
+ return toSummary(row, row.filePath === null ? void 0 : files.get(row.filePath), progress.get(row.id), resolveItemText(row, language, fallback).title);
10774
10843
  });
10775
10844
  }
10776
- pageOf = async (kind, userId, limit, offset) => {
10845
+ pageOf = async (kind, userId, limit, offset, language) => {
10777
10846
  const rows = await this.queryItems({
10778
10847
  where: {
10779
10848
  kind,
@@ -10791,17 +10860,17 @@ var LibraryStore = class {
10791
10860
  topLevel: true
10792
10861
  } });
10793
10862
  return {
10794
- items: await this.summaries(rows, userId),
10863
+ items: await this.summaries(rows, userId, language),
10795
10864
  total
10796
10865
  };
10797
10866
  };
10798
- listSeries(userId, limit, offset) {
10799
- return this.pageOf("series", userId, limit, offset);
10867
+ listSeries(userId, limit, offset, language) {
10868
+ return this.pageOf("series", userId, limit, offset, language);
10800
10869
  }
10801
- listMovies(userId, limit, offset) {
10802
- return this.pageOf("movie", userId, limit, offset);
10870
+ listMovies(userId, limit, offset, language) {
10871
+ return this.pageOf("movie", userId, limit, offset, language);
10803
10872
  }
10804
- async listRecentlyAdded(userId, limit) {
10873
+ async listRecentlyAdded(userId, limit, language) {
10805
10874
  const rows = await this.queryItems({
10806
10875
  where: { topLevel: true },
10807
10876
  orderBy: {
@@ -10810,19 +10879,21 @@ var LibraryStore = class {
10810
10879
  },
10811
10880
  limit: limit ?? RECENT_DEFAULT_LIMIT
10812
10881
  });
10813
- return this.summaries(rows, userId);
10882
+ return this.summaries(rows, userId, language);
10814
10883
  }
10815
- async search(userId, query, limit) {
10884
+ async search(userId, query, limit, language) {
10816
10885
  const needle = foldTitle(query);
10817
10886
  if (needle === "") return [];
10818
- const hits = (await this.queryItems({
10887
+ const rows = await this.queryItems({
10819
10888
  where: { topLevel: true },
10820
10889
  orderBy: {
10821
10890
  field: "sortTitle",
10822
10891
  direction: "asc"
10823
10892
  }
10824
- })).filter((row) => row.titleFold.includes(needle)).slice(0, limit ?? SEARCH_DEFAULT_LIMIT);
10825
- return this.summaries(hits, userId);
10893
+ });
10894
+ const fallback = this.serverLanguage();
10895
+ const hits = rows.filter((row) => row.titleFold.includes(needle) || foldTitle(resolveItemText(row, language, fallback).title).includes(needle)).slice(0, limit ?? SEARCH_DEFAULT_LIMIT);
10896
+ return this.summaries(hits, userId, language);
10826
10897
  }
10827
10898
  episodesOf(seriesId) {
10828
10899
  return this.queryItems({
@@ -10860,7 +10931,7 @@ var LibraryStore = class {
10860
10931
  watchedCount: entry.watched
10861
10932
  }));
10862
10933
  }
10863
- async listEpisodes(userId, seriesId, seasonNumber) {
10934
+ async listEpisodes(userId, seriesId, seasonNumber, language) {
10864
10935
  const rows = await this.queryItems({
10865
10936
  where: {
10866
10937
  parentId: seriesId,
@@ -10871,18 +10942,23 @@ var LibraryStore = class {
10871
10942
  direction: "asc"
10872
10943
  }
10873
10944
  });
10874
- return (await this.summaries(rows, userId)).map((summary, index) => ({
10875
- ...summary,
10876
- overview: rows[index]?.overview ?? null
10877
- }));
10945
+ const summaries = await this.summaries(rows, userId, language);
10946
+ const fallback = this.serverLanguage();
10947
+ return summaries.map((summary, index) => {
10948
+ const row = rows[index];
10949
+ return {
10950
+ ...summary,
10951
+ overview: row === void 0 ? null : resolveItemText(row, language, fallback).overview
10952
+ };
10953
+ });
10878
10954
  }
10879
- async getItem(userId, itemId) {
10955
+ async getItem(userId, itemId, language) {
10880
10956
  const [row] = await this.queryItems({
10881
10957
  where: { id: itemId },
10882
10958
  limit: 1
10883
10959
  });
10884
10960
  if (row === void 0) return null;
10885
- const [summary] = await this.summaries([row], userId);
10961
+ const [summary] = await this.summaries([row], userId, language);
10886
10962
  if (summary === void 0) return null;
10887
10963
  const [file] = row.filePath === null ? [] : await this.queryFiles({
10888
10964
  where: { path: row.filePath },
@@ -10890,7 +10966,7 @@ var LibraryStore = class {
10890
10966
  });
10891
10967
  return {
10892
10968
  ...summary,
10893
- overview: row.overview,
10969
+ overview: resolveItemText(row, language, this.serverLanguage()).overview,
10894
10970
  ids: {
10895
10971
  tvdb: row.tvdbId,
10896
10972
  tmdb: row.tmdbId,
@@ -11080,7 +11156,7 @@ var LibraryStore = class {
11080
11156
  watched
11081
11157
  };
11082
11158
  }
11083
- async listContinue(userId, limit) {
11159
+ async listContinue(userId, limit, language) {
11084
11160
  const wanted = limit ?? CONTINUE_DEFAULT_LIMIT;
11085
11161
  const rows = (await this.queryProgress({
11086
11162
  where: {
@@ -11095,7 +11171,7 @@ var LibraryStore = class {
11095
11171
  })).filter((row) => row.positionMs > 0);
11096
11172
  if (rows.length === 0) return [];
11097
11173
  const items = await this.queryItems({ whereIn: { id: rows.map((row) => row.itemId) } });
11098
- const summaries = new Map((await this.summaries(items, userId)).map((summary) => [summary.id, summary]));
11174
+ const summaries = new Map((await this.summaries(items, userId, language)).map((summary) => [summary.id, summary]));
11099
11175
  const entries = [];
11100
11176
  for (const row of rows) {
11101
11177
  const item = summaries.get(row.itemId);
@@ -11126,11 +11202,11 @@ function toFileInfo(file) {
11126
11202
  probed: file.probeOk
11127
11203
  };
11128
11204
  }
11129
- function toSummary(row, file, progress) {
11205
+ function toSummary(row, file, progress, title) {
11130
11206
  return {
11131
11207
  id: row.id,
11132
11208
  kind: row.kind,
11133
- title: row.title,
11209
+ title,
11134
11210
  year: row.year,
11135
11211
  seriesId: row.kind === "episode" ? row.parentId : null,
11136
11212
  seasonNumber: row.seasonNumber,
@@ -12380,6 +12456,51 @@ function createOmdbProvider(deps) {
12380
12456
  }
12381
12457
  };
12382
12458
  }
12459
+ /**
12460
+ * The server's default language, kept in memory so no catalogue read waits on the system call.
12461
+ * A read answers what is held; one that finds it older than {@link SERVER_LANGUAGE_REFRESH_MS}
12462
+ * starts a refresh and does not wait for it. A refresh that fails changes nothing (the last answer
12463
+ * stays, English when there never was one) and says so in the log.
12464
+ */
12465
+ var ServerLanguage = class {
12466
+ read;
12467
+ now;
12468
+ logger;
12469
+ value = "en";
12470
+ attemptedAt = null;
12471
+ inFlight = null;
12472
+ constructor(read, now, logger) {
12473
+ this.read = read;
12474
+ this.now = now;
12475
+ this.logger = logger;
12476
+ }
12477
+ /** Ask now and wait; used at boot and at the start of a scan, never on a read. */
12478
+ refresh() {
12479
+ if (this.inFlight !== null) return this.inFlight;
12480
+ const run = (async () => {
12481
+ try {
12482
+ const read = await this.read();
12483
+ if (read === null) this.logger.warn("server default language unreadable: keeping the last one", { meta: { kept: this.value } });
12484
+ else this.value = read;
12485
+ } catch (error) {
12486
+ this.logger.warn("server default language not read: keeping the last one", { meta: {
12487
+ error: errMsg(error),
12488
+ kept: this.value
12489
+ } });
12490
+ } finally {
12491
+ this.attemptedAt = this.now();
12492
+ this.inFlight = null;
12493
+ }
12494
+ })();
12495
+ this.inFlight = run;
12496
+ return run;
12497
+ }
12498
+ /** The held language; starts a background refresh when it is stale. Never throws, never waits. */
12499
+ current() {
12500
+ if (this.attemptedAt === null || this.now() - this.attemptedAt >= 6e4) this.refresh();
12501
+ return this.value;
12502
+ }
12503
+ };
12383
12504
  //#endregion
12384
12505
  //#region src/tmdb.ts
12385
12506
  var TMDB_ID = "tmdb";
@@ -12395,6 +12516,15 @@ var SearchSchema$2 = object({ results: array(object({
12395
12516
  release_date: string().nullish(),
12396
12517
  first_air_date: string().nullish()
12397
12518
  })) });
12519
+ /** `append_to_response=translations`: one entry per language TMDB holds, `data` carries the text. */
12520
+ var TranslationsSchema = object({ translations: array(object({
12521
+ iso_639_1: string(),
12522
+ data: object({
12523
+ title: string().nullish(),
12524
+ name: string().nullish(),
12525
+ overview: string().nullish()
12526
+ }).nullish()
12527
+ })) });
12398
12528
  var DetailsSchema = object({
12399
12529
  id: number().int(),
12400
12530
  title: string().nullish(),
@@ -12409,7 +12539,8 @@ var DetailsSchema = object({
12409
12539
  imdb_id: string().nullish(),
12410
12540
  tvdb_id: number().int().nullish()
12411
12541
  }).nullish(),
12412
- seasons: array(object({ season_number: number().int() })).nullish()
12542
+ seasons: array(object({ season_number: number().int() })).nullish(),
12543
+ translations: TranslationsSchema.nullish()
12413
12544
  });
12414
12545
  var FindSchema = object({
12415
12546
  movie_results: array(object({ id: number().int() })).default([]),
@@ -12422,6 +12553,10 @@ var SeasonSchema = object({ episodes: array(object({
12422
12553
  overview: string().nullish(),
12423
12554
  still_path: string().nullish()
12424
12555
  })) });
12556
+ /** TMDB's tag for a locale: English keeps the region it was always asked in, others are sent bare. */
12557
+ function tmdbLanguageOf(locale) {
12558
+ return locale === "en" ? DEFAULT_LANGUAGE : locale;
12559
+ }
12425
12560
  function yearOf$1(date) {
12426
12561
  const match = /^(\d{4})/.exec(date ?? "");
12427
12562
  return match?.[1] === void 0 ? null : Number(match[1]);
@@ -12433,6 +12568,25 @@ function text(value) {
12433
12568
  function image(size, path) {
12434
12569
  return path === null || path === void 0 || !path.startsWith("/") ? null : `${IMAGES}/${size}${path}`;
12435
12570
  }
12571
+ /**
12572
+ * The per-language text of a details answer, keyed by TMDB's language tag (`iso_639_1`, lower-cased).
12573
+ * A language that holds neither a title nor an overview is left out; a regional variant of a language
12574
+ * already seen (`pt-BR` after `pt-PT`) never replaces the first.
12575
+ */
12576
+ function translationsOf(details) {
12577
+ const out = {};
12578
+ for (const entry of details.translations?.translations ?? []) {
12579
+ const tag = entry.iso_639_1.trim().toLowerCase();
12580
+ const title = text(entry.data?.title ?? entry.data?.name);
12581
+ const overview = text(entry.data?.overview);
12582
+ if (tag === "" || out[tag] !== void 0 || title === null && overview === null) continue;
12583
+ out[tag] = {
12584
+ title,
12585
+ overview
12586
+ };
12587
+ }
12588
+ return out;
12589
+ }
12436
12590
  var nameOf = (entry) => entry.title ?? entry.name ?? "";
12437
12591
  var yearIn = (entry) => yearOf$1(entry.release_date ?? entry.first_air_date);
12438
12592
  /** TMDB: movies and series, with the installation's own read token. All calls go through the shared remote fetch. */
@@ -12466,11 +12620,12 @@ function createTmdbProvider(deps) {
12466
12620
  tmdbId: details.id,
12467
12621
  imdbId: text(details.external_ids?.imdb_id) ?? text(details.imdb_id),
12468
12622
  poster: image("w500", details.poster_path),
12469
- fanart: image("w1280", details.backdrop_path)
12623
+ fanart: image("w1280", details.backdrop_path),
12624
+ translations: translationsOf(details)
12470
12625
  });
12471
12626
  const detailsOf = async (kind, id) => {
12472
12627
  try {
12473
- return matchOf(DetailsSchema.parse(await call(`/${segment(kind)}/${id}`, { append_to_response: "external_ids" })));
12628
+ return matchOf(DetailsSchema.parse(await call(`/${segment(kind)}/${id}`, { append_to_response: "external_ids,translations" })));
12474
12629
  } catch (error) {
12475
12630
  if (error instanceof Error && /\b404\b/.test(error.message)) return null;
12476
12631
  throw error;
@@ -12478,6 +12633,7 @@ function createTmdbProvider(deps) {
12478
12633
  };
12479
12634
  return {
12480
12635
  id: TMDB_ID,
12636
+ translates: true,
12481
12637
  kinds: ["movie", "series"],
12482
12638
  lookupBy: [
12483
12639
  "tmdbId",
@@ -13205,17 +13361,17 @@ function createFfmpegProber(binaryPath) {
13205
13361
  /** The `media-library` capability over the store. A caller reads and writes only their own progress. */
13206
13362
  function createMediaLibraryProvider(store, scans) {
13207
13363
  return {
13208
- listSeries: ({ limit, offset, caller }) => store.listSeries(caller.userId, limit, offset),
13209
- listMovies: ({ limit, offset, caller }) => store.listMovies(caller.userId, limit, offset),
13364
+ listSeries: ({ limit, offset, language, caller }) => store.listSeries(caller.userId, limit, offset, language),
13365
+ listMovies: ({ limit, offset, language, caller }) => store.listMovies(caller.userId, limit, offset, language),
13210
13366
  listSeasons: ({ seriesId, caller }) => store.listSeasons(caller.userId, seriesId),
13211
- listEpisodes: ({ seriesId, seasonNumber, caller }) => store.listEpisodes(caller.userId, seriesId, seasonNumber),
13212
- getItem: ({ itemId, caller }) => store.getItem(caller.userId, itemId),
13213
- search: ({ query, limit, caller }) => store.search(caller.userId, query, limit),
13214
- listRecentlyAdded: ({ limit, caller }) => store.listRecentlyAdded(caller.userId, limit),
13367
+ listEpisodes: ({ seriesId, seasonNumber, language, caller }) => store.listEpisodes(caller.userId, seriesId, seasonNumber, language),
13368
+ getItem: ({ itemId, language, caller }) => store.getItem(caller.userId, itemId, language),
13369
+ search: ({ query, limit, language, caller }) => store.search(caller.userId, query, limit, language),
13370
+ listRecentlyAdded: ({ limit, language, caller }) => store.listRecentlyAdded(caller.userId, limit, language),
13215
13371
  getProgress: ({ itemId, caller }) => store.getProgress(caller.userId, itemId),
13216
13372
  setProgress: ({ caller, ...input }) => store.setProgress(caller.userId, input),
13217
13373
  markWatched: ({ caller, ...input }) => store.markWatched(caller.userId, input),
13218
- listContinue: ({ limit, caller }) => store.listContinue(caller.userId, limit),
13374
+ listContinue: ({ limit, language, caller }) => store.listContinue(caller.userId, limit, language),
13219
13375
  rescan: async () => ({ started: scans.start("manual") }),
13220
13376
  getScanStatus: async () => scans.status()
13221
13377
  };
@@ -13231,6 +13387,7 @@ function fill(into, from) {
13231
13387
  title: into.title ?? from.title,
13232
13388
  year: into.year ?? from.year,
13233
13389
  overview: into.overview ?? from.overview,
13390
+ translations: into.translations ?? from.translations,
13234
13391
  tvdbId: into.tvdbId ?? from.tvdbId,
13235
13392
  tmdbId: into.tmdbId ?? from.tmdbId,
13236
13393
  imdbId: into.imdbId ?? from.imdbId,
@@ -13303,6 +13460,14 @@ var Enricher = class {
13303
13460
  if ((this.failures.get(id) ?? 0) >= PROVIDER_FAILURE_LIMIT) return null;
13304
13461
  return this.deps.providers.find((entry) => entry.id === id) ?? null;
13305
13462
  }
13463
+ /**
13464
+ * The cache namespace of a provider. A translating one answers its base text in the server's
13465
+ * language, so that language is part of the key: changing it asks again instead of serving the old
13466
+ * language for the cache lifetime.
13467
+ */
13468
+ keyOf(provider) {
13469
+ return provider.translates === true && this.deps.language !== void 0 ? `${provider.id}@${this.deps.language}` : provider.id;
13470
+ }
13306
13471
  imageProvider(id) {
13307
13472
  if ((this.failures.get(id) ?? 0) >= PROVIDER_FAILURE_LIMIT) return null;
13308
13473
  return this.deps.images?.find((entry) => entry.id === id) ?? null;
@@ -13377,10 +13542,19 @@ var Enricher = class {
13377
13542
  }
13378
13543
  });
13379
13544
  }
13545
+ /**
13546
+ * The cached answer for `key`, unless it predates translations: a match a translating provider
13547
+ * cached before it carried them is asked again, so a rollout does not wait out the cache lifetime.
13548
+ */
13549
+ cachedMatch(provider, key) {
13550
+ const known = this.deps.cache.getMatch(key);
13551
+ if (known === null) return null;
13552
+ return known.found && provider.translates === true && known.match.translations === void 0 ? null : known;
13553
+ }
13380
13554
  /** A pinned id is asked for directly: an answer of "nothing" is final, never turned into a title guess. */
13381
13555
  async lookup(provider, ask, item, kind, pin) {
13382
- const key = `${provider.id}:lookup:${kind}:${pin.tvdbId ?? ""}:${pin.imdbId ?? ""}:${pin.tmdbId ?? ""}`;
13383
- const known = this.deps.cache.getMatch(key);
13556
+ const key = `${this.keyOf(provider)}:lookup:${kind}:${pin.tvdbId ?? ""}:${pin.imdbId ?? ""}:${pin.tmdbId ?? ""}`;
13557
+ const known = this.cachedMatch(provider, key);
13384
13558
  if (known !== null) return known.found ? known.match : null;
13385
13559
  const pending = this.matches.get(key);
13386
13560
  if (pending !== void 0) return pending;
@@ -13431,8 +13605,8 @@ var Enricher = class {
13431
13605
  const found = await this.lookup(provider, provider.lookup.bind(provider), item, kind, ask.ids);
13432
13606
  if (found !== null || ask.fromPin) return found;
13433
13607
  }
13434
- const key = `${provider.id}:id:${kind}:${foldTitle(title)}:${year ?? 0}`;
13435
- const known = this.deps.cache.getMatch(key);
13608
+ const key = `${this.keyOf(provider)}:id:${kind}:${foldTitle(title)}:${year ?? 0}`;
13609
+ const known = this.cachedMatch(provider, key);
13436
13610
  if (known !== null) return known.found ? known.match : null;
13437
13611
  const pending = this.matches.get(key);
13438
13612
  if (pending !== void 0) return pending;
@@ -13453,7 +13627,7 @@ var Enricher = class {
13453
13627
  return run;
13454
13628
  }
13455
13629
  async episodesOf(provider, item, match) {
13456
- const key = `${provider.id}:eps:${match.remoteId}`;
13630
+ const key = `${this.keyOf(provider)}:eps:${match.remoteId}`;
13457
13631
  const known = this.deps.cache.getEpisodes(key);
13458
13632
  if (known !== null) return known.episodes;
13459
13633
  try {
@@ -13475,6 +13649,7 @@ var Enricher = class {
13475
13649
  title: match.title,
13476
13650
  year: match.year,
13477
13651
  overview: match.overview,
13652
+ translations: match.translations ?? null,
13478
13653
  tvdbId: match.tvdbId,
13479
13654
  tmdbId: match.tmdbId,
13480
13655
  imdbId: match.imdbId,
@@ -13503,9 +13678,9 @@ var Enricher = class {
13503
13678
  canAsk(provider, item) {
13504
13679
  return provider.kinds.includes(item.kind === "movie" ? "movie" : "series");
13505
13680
  }
13506
- needsOnline(item, acc) {
13681
+ needsOnline(provider, item, acc) {
13507
13682
  if (item.kind === "episode") return acc.overview === null || acc.poster === null || item.titlePlaceholder && acc.title === null;
13508
- return acc.overview === null || acc.poster === null;
13683
+ return acc.overview === null || acc.poster === null || provider.translates === true && acc.translations === null;
13509
13684
  }
13510
13685
  async localLayer(item, firstEpisodeFile) {
13511
13686
  const { reader } = this.deps;
@@ -13541,7 +13716,7 @@ var Enricher = class {
13541
13716
  const images = this.imageProvider(step);
13542
13717
  const provider = this.provider(step);
13543
13718
  if (images !== null && item.kind !== "episode" && images.kinds.includes(item.kind === "movie" ? "movie" : "series") && (acc.poster === null || acc.fanart === null)) acc = fill(acc, await this.imageLayer(images, item, acc));
13544
- else if (provider !== null && this.canAsk(provider, item) && this.needsOnline(item, acc)) acc = fill(acc, await this.onlineLayer(provider, item, acc, resolved, held));
13719
+ else if (provider !== null && this.canAsk(provider, item) && this.needsOnline(provider, item, acc)) acc = fill(acc, await this.onlineLayer(provider, item, acc, resolved, held));
13545
13720
  }
13546
13721
  applyPin();
13547
13722
  acc = fill(acc, fileLayer(item));
@@ -13553,6 +13728,7 @@ var Enricher = class {
13553
13728
  titleFold: foldTitle(title),
13554
13729
  year: acc.year,
13555
13730
  overview: acc.overview,
13731
+ translations: acc.translations,
13556
13732
  tvdbId: acc.tvdbId,
13557
13733
  tmdbId: acc.tmdbId,
13558
13734
  imdbId: acc.imdbId,
@@ -13593,6 +13769,7 @@ function newItem(base) {
13593
13769
  seasonNumber: null,
13594
13770
  episodeNumber: null,
13595
13771
  overview: null,
13772
+ translations: null,
13596
13773
  tvdbId: null,
13597
13774
  tmdbId: null,
13598
13775
  imdbId: null,
@@ -13749,13 +13926,13 @@ async function folderItems(root, paths, reader) {
13749
13926
  //#endregion
13750
13927
  //#region src/scanner.ts
13751
13928
  /** The online providers this scan may ask: the fixed ones, plus each keyed one whose key is set. */
13752
- function onlineProviders(deps, sources) {
13929
+ function onlineProviders(deps, sources, language = "en") {
13753
13930
  const keyed = (make, key) => make !== void 0 && (key ?? "") !== "" ? [make(key ?? "")] : [];
13754
13931
  const fanartKey = sources.fanartApiKey ?? "";
13755
13932
  return {
13756
13933
  providers: [
13757
13934
  ...deps.providers ?? [],
13758
- ...keyed(deps.createTmdb, sources.tmdbToken),
13935
+ ...deps.createTmdb !== void 0 && (sources.tmdbToken ?? "") !== "" ? [deps.createTmdb(sources.tmdbToken ?? "", language)] : [],
13759
13936
  ...keyed(deps.createTvdb, sources.tvdbApiKey),
13760
13937
  ...keyed(deps.createOmdb, sources.omdbApiKey),
13761
13938
  ...deps.createAnilist !== void 0 && (sources.metadataSteps ?? []).includes("anilist") ? [deps.createAnilist()] : []
@@ -13903,12 +14080,14 @@ async function scanLibrary(deps, sources) {
13903
14080
  logger.warn("metadata matches could not be saved: they are asked for again next scan", { meta: { error: error instanceof Error ? error.message : String(error) } });
13904
14081
  }
13905
14082
  };
14083
+ const language = await deps.language?.() ?? "en";
13906
14084
  for (const [index, entry] of harvests.entries()) {
13907
14085
  try {
13908
- const online = onlineProviders(deps, sources);
14086
+ const online = onlineProviders(deps, sources, language);
13909
14087
  const items = await enrichItems(entry.items, sources.metadataSteps ?? DEFAULT_STEPS, {
13910
14088
  reader,
13911
14089
  providers: online.providers,
14090
+ language,
13912
14091
  images: online.images,
13913
14092
  cache,
13914
14093
  logger,
@@ -14182,7 +14361,9 @@ var MediaLibraryAddon = class extends BaseAddon {
14182
14361
  const { ctx } = this;
14183
14362
  const logger = ctx.logger;
14184
14363
  const db = settingsStoreDb(ctx.api.settingsStore);
14185
- const store = new LibraryStore(db, logger);
14364
+ const serverLanguage = new ServerLanguage(async () => (await ctx.api.system.info.query()).defaultLanguage, () => Date.now(), logger);
14365
+ await serverLanguage.refresh();
14366
+ const store = new LibraryStore(db, logger, () => serverLanguage.current());
14186
14367
  await store.init();
14187
14368
  const ffmpeg = await ctx.deps.ensureFfmpeg();
14188
14369
  const scans = new ScanController({
@@ -14203,9 +14384,14 @@ var MediaLibraryAddon = class extends BaseAddon {
14203
14384
  },
14204
14385
  probe: createFfmpegProber(ffmpeg),
14205
14386
  providers: [createTvmazeProvider({ fetch: httpRemoteFetch })],
14206
- createTmdb: (token) => createTmdbProvider({
14387
+ language: async () => {
14388
+ await serverLanguage.refresh();
14389
+ return serverLanguage.current();
14390
+ },
14391
+ createTmdb: (token, language) => createTmdbProvider({
14207
14392
  fetch: httpRemoteFetch,
14208
- token
14393
+ token,
14394
+ language: tmdbLanguageOf(language)
14209
14395
  }),
14210
14396
  createTvdb: (apiKey) => createTvdbProvider({
14211
14397
  fetch: httpRemoteFetch,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dominevo/addon-media-library",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "The self-hosted media library: a catalogue built from the arr apps and plain folders, probed files, per-user progress, direct play with Range and a native /media app in the viewer.",
5
5
  "keywords": [
6
6
  "dominevo",
@@ -58,7 +58,7 @@
58
58
  }
59
59
  ],
60
60
  "requires": {
61
- "server": ">=0.1.55"
61
+ "server": ">=0.1.56"
62
62
  }
63
63
  },
64
64
  "files": [