Zwei Titel je Film, und die Sprache lässt sich wählen
Die Mediathek sah zweisprachig aus — "Despicable Me" neben "Ich einfach unverbesserlich". Es gab nur ein Titelfeld, und welche Sprache darin landete, entschied die Einstellung zum Zeitpunkt des Scans. Movie und Series tragen jetzt zusätzlich OriginalTitle. Gesucht wird über beide: wer "Despicable Me" tippt, findet "Ich einfach unverbesserlich". Auf der Detailseite steht der Originaltitel unter dem übersetzten, wenn er abweicht. Die Sprache der Metadaten ist in der Verwaltung eine Auswahl statt eines Textfelds. Vorher musste man "de-DE" wissen, und ein Tippfehler darin nahm TMDB stillschweigend als Englisch an. Dazu eine eigene Sprache je Benutzer. Das Ehrliche daran steht im Dialog: die Daten liegen in einer Sprache vor, und wer eine andere wählt, bekommt, was übersetzt vorliegt — für den Rest die Serversprache, nicht ein leeres Feld. ItemTranslation hält die zweite Sprache, gefüllt über eine Sammelaktion. Nicht nebenbei beim Öffnen: das verteilte die Wartezeit über Wochen und träfe immer den, der gerade etwas sucht. Alle Sprachen für alle Titel vorzuhalten wäre der Bestand mal Sprachen an Abrufen und Speicher, für einen Haushalt mit zweien. Deshalb auf Ansage. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
f359807561
commit
921533050b
@@ -88,10 +88,19 @@ public sealed class TmdbClient(
|
||||
return alle.Select(m => Als(m, title)).ToList();
|
||||
}
|
||||
|
||||
public async Task<MovieMetadata?> GetMovieAsync(int providerId, CancellationToken ct = default)
|
||||
public Task<MovieMetadata?> GetMovieAsync(int providerId, CancellationToken ct = default) =>
|
||||
FilmHolenAsync(providerId, null, ct);
|
||||
|
||||
public Task<MovieMetadata?> GetMovieAsync(int providerId, string sprache, CancellationToken ct = default) =>
|
||||
FilmHolenAsync(providerId, sprache, ct);
|
||||
|
||||
/// <summary>Der gemeinsame Weg — mit Sprache oder mit der des Servers.</summary>
|
||||
private async Task<MovieMetadata?> FilmHolenAsync(
|
||||
int providerId, string? sprache, CancellationToken ct)
|
||||
{
|
||||
var einstellung = await einstellungen.GetAsync(ct);
|
||||
if (string.IsNullOrWhiteSpace(einstellung.ApiKey)) return null;
|
||||
if (sprache is { Length: > 0 }) einstellung = einstellung with { Language = sprache };
|
||||
|
||||
// **Alles in einer Anfrage.** `append_to_response` hängt Besetzung,
|
||||
// Fremdkennungen und Freigaben an den Einzelabruf. Drei getrennte
|
||||
@@ -127,7 +136,10 @@ public sealed class TmdbClient(
|
||||
|
||||
private static MovieMetadata Als(TmdbMovie roh, string rückfall) => new(
|
||||
roh.Id, roh.Title ?? rückfall, JahrAus(roh.ReleaseDate), Leer(roh.Overview),
|
||||
Bild(roh.PosterPath, PosterSize), Bild(roh.BackdropPath, BackdropSize));
|
||||
Bild(roh.PosterPath, PosterSize), Bild(roh.BackdropPath, BackdropSize))
|
||||
{
|
||||
OriginalTitle = Leer(roh.OriginalTitle),
|
||||
};
|
||||
|
||||
public async Task<SeriesMetadata?> FindSeriesAsync(string title, int? year, CancellationToken ct = default)
|
||||
{
|
||||
@@ -145,10 +157,18 @@ public sealed class TmdbClient(
|
||||
return alle.Select(s => Als(s, title)).ToList();
|
||||
}
|
||||
|
||||
public async Task<SeriesMetadata?> GetSeriesAsync(int providerId, CancellationToken ct = default)
|
||||
public Task<SeriesMetadata?> GetSeriesAsync(int providerId, CancellationToken ct = default) =>
|
||||
SerieHolenAsync(providerId, null, ct);
|
||||
|
||||
public Task<SeriesMetadata?> GetSeriesAsync(int providerId, string sprache, CancellationToken ct = default) =>
|
||||
SerieHolenAsync(providerId, sprache, ct);
|
||||
|
||||
private async Task<SeriesMetadata?> SerieHolenAsync(
|
||||
int providerId, string? sprache, CancellationToken ct)
|
||||
{
|
||||
var einstellung = await einstellungen.GetAsync(ct);
|
||||
if (string.IsNullOrWhiteSpace(einstellung.ApiKey)) return null;
|
||||
if (sprache is { Length: > 0 }) einstellung = einstellung with { Language = sprache };
|
||||
|
||||
var serie = await HolenAsync<TmdbSeries>(
|
||||
$"tv/{providerId}?language={Uri.EscapeDataString(einstellung.Language)}" +
|
||||
@@ -174,7 +194,10 @@ public sealed class TmdbClient(
|
||||
|
||||
private static SeriesMetadata Als(TmdbSeries roh, string rückfall) => new(
|
||||
roh.Id, roh.Name ?? rückfall, JahrAus(roh.FirstAirDate), Leer(roh.Overview),
|
||||
Bild(roh.PosterPath, PosterSize), Bild(roh.BackdropPath, BackdropSize));
|
||||
Bild(roh.PosterPath, PosterSize), Bild(roh.BackdropPath, BackdropSize))
|
||||
{
|
||||
OriginalTitle = Leer(roh.OriginalName),
|
||||
};
|
||||
|
||||
// Der eigene Abruf von `external_ids` ist entfallen: die Kennung hängt
|
||||
// jetzt über `append_to_response` am Einzelabruf. Das spart eine Anfrage
|
||||
@@ -428,6 +451,7 @@ public sealed class TmdbClient(
|
||||
private sealed record TmdbMovie(
|
||||
[property: JsonPropertyName("id")] int Id,
|
||||
[property: JsonPropertyName("title")] string? Title,
|
||||
[property: JsonPropertyName("original_title")] string? OriginalTitle,
|
||||
[property: JsonPropertyName("release_date")] string? ReleaseDate,
|
||||
[property: JsonPropertyName("overview")] string? Overview,
|
||||
[property: JsonPropertyName("poster_path")] string? PosterPath,
|
||||
@@ -445,6 +469,7 @@ public sealed class TmdbClient(
|
||||
private sealed record TmdbSeries(
|
||||
[property: JsonPropertyName("id")] int Id,
|
||||
[property: JsonPropertyName("name")] string? Name,
|
||||
[property: JsonPropertyName("original_name")] string? OriginalName,
|
||||
[property: JsonPropertyName("first_air_date")] string? FirstAirDate,
|
||||
[property: JsonPropertyName("overview")] string? Overview,
|
||||
[property: JsonPropertyName("poster_path")] string? PosterPath,
|
||||
|
||||
Reference in New Issue
Block a user