Add missing episodes feature: implement FindMissingEpisodes endpoint, update metadata providers to retrieve season episode counts, and enhance frontend components for displaying missing episodes report. Update translations for new UI elements.
This commit is contained in:
1 parent
8962840654
commit
44e954920c
11 files changed
+344
-2
No files matched your search
@@ -87,6 +87,25 @@ public sealed class OmdbMetadataProvider(
|
||||
);
|
||||
}
|
||||
|
||||
public async Task<int?> GetSeasonEpisodeCountAsync(
|
||||
string externalId,
|
||||
int season,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var url =
|
||||
$"{_omdb.BaseUrl}/?apikey={_omdb.ApiKey}&i={Uri.EscapeDataString(externalId)}&Season={season}";
|
||||
using var doc = await TryGetJsonAsync(url, cancellationToken);
|
||||
if (
|
||||
doc is null
|
||||
|| !IsResponseTrue(doc.RootElement)
|
||||
|| !doc.RootElement.TryGetProperty("Episodes", out var episodes)
|
||||
|| episodes.ValueKind != JsonValueKind.Array
|
||||
)
|
||||
return null;
|
||||
return episodes.GetArrayLength();
|
||||
}
|
||||
|
||||
/// <summary>GET+parse; бросает при не-2xx/сетевой ошибке (для поиска — чтобы показать сбой).</summary>
|
||||
private async Task<JsonDocument> GetJsonAsync(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
@@ -91,6 +91,25 @@ public sealed class TmdbMetadataProvider(
|
||||
);
|
||||
}
|
||||
|
||||
public async Task<int?> GetSeasonEpisodeCountAsync(
|
||||
string externalId,
|
||||
int season,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var url =
|
||||
$"{Tmdb.BaseUrl}/tv/{externalId}/season/{season}"
|
||||
+ $"?api_key={Tmdb.ApiKey}&language={_options.Language}";
|
||||
using var doc = await TryGetJsonAsync(url, cancellationToken);
|
||||
if (
|
||||
doc is null
|
||||
|| !doc.RootElement.TryGetProperty("episodes", out var episodes)
|
||||
|| episodes.ValueKind != JsonValueKind.Array
|
||||
)
|
||||
return null;
|
||||
return episodes.GetArrayLength();
|
||||
}
|
||||
|
||||
private string? PosterUrl(string? path) =>
|
||||
string.IsNullOrEmpty(path) ? null : $"{Tmdb.ImageBaseUrl}/{Tmdb.PosterSize}{path}";
|
||||
|
||||
|
||||
Reference in new issue
Block a user