Update scheduling parameters and refactor channel endpoints: extend HorizonDays to 7 and RetentionDays to 90 in appsettings.json. Consolidate channel-related endpoint logic by removing obsolete files and enhancing the ShowEndpoints with audience and genre management capabilities. Improve error handling and streamline command handlers for channel operations.
This commit is contained in:
@@ -62,10 +62,19 @@ public sealed class OmdbMetadataProvider(
|
||||
Clean(GetString(root, "Title")) ?? "—",
|
||||
YearFrom(GetString(root, "Year")),
|
||||
Clean(GetString(root, "Plot")),
|
||||
Clean(GetString(root, "Poster"))
|
||||
Clean(GetString(root, "Poster")),
|
||||
GenresFrom(Clean(GetString(root, "Genre")))
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>OMDb отдаёт жанры одной строкой через запятую: «Action, Sci-Fi».</summary>
|
||||
private static List<string> GenresFrom(string? value) =>
|
||||
string.IsNullOrWhiteSpace(value)
|
||||
? []
|
||||
: value
|
||||
.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
|
||||
.ToList();
|
||||
|
||||
public async Task<EpisodeMetadata?> GetEpisodeAsync(
|
||||
string externalId,
|
||||
int season,
|
||||
|
||||
@@ -66,10 +66,32 @@ public sealed class TmdbMetadataProvider(
|
||||
GetString(root, "name") ?? "—",
|
||||
YearFrom(GetString(root, "first_air_date")),
|
||||
GetString(root, "overview"),
|
||||
PosterUrl(GetString(root, "poster_path"))
|
||||
PosterUrl(GetString(root, "poster_path")),
|
||||
GenresFrom(root)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Жанры из ответа TMDb в порядке источника: на каждый — сначала идентификатор
|
||||
/// (<c>tmdb:28</c>), затем локализованное название. Идентификатор точнее, название — запасной
|
||||
/// вариант, если справочник его ещё не знает.
|
||||
/// </summary>
|
||||
private static List<string> GenresFrom(JsonElement root)
|
||||
{
|
||||
var genres = new List<string>();
|
||||
if (!root.TryGetProperty("genres", out var array) || array.ValueKind != JsonValueKind.Array)
|
||||
return genres;
|
||||
|
||||
foreach (var item in array.EnumerateArray())
|
||||
{
|
||||
if (GetInt(item, "id") is { } id)
|
||||
genres.Add($"tmdb:{id.ToString(CultureInfo.InvariantCulture)}");
|
||||
if (GetString(item, "name") is { Length: > 0 } name)
|
||||
genres.Add(name);
|
||||
}
|
||||
return genres;
|
||||
}
|
||||
|
||||
public async Task<EpisodeMetadata?> GetEpisodeAsync(
|
||||
string externalId,
|
||||
int season,
|
||||
|
||||
Reference in New Issue
Block a user