mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-23 10:34:43 +01:00
Update to Jellyfin.XmlTv 10.12.0-pre1
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
#nullable disable
|
||||
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
@@ -62,21 +60,21 @@ namespace Jellyfin.LiveTv.Listings
|
||||
_logger.LogInformation("xmltv path: {Path}", info.Path);
|
||||
|
||||
string cacheFilename = info.Id + ".xml";
|
||||
string cacheFile = Path.Combine(_config.ApplicationPaths.CachePath, "xmltv", cacheFilename);
|
||||
string cacheDir = Path.Join(_config.ApplicationPaths.CachePath, "xmltv");
|
||||
string cacheFile = Path.Join(cacheDir, cacheFilename);
|
||||
|
||||
if (File.Exists(cacheFile) && File.GetLastWriteTimeUtc(cacheFile) >= DateTime.UtcNow.Subtract(_maxCacheAge))
|
||||
{
|
||||
return cacheFile;
|
||||
}
|
||||
|
||||
// Must check if file exists as parent directory may not exist.
|
||||
if (File.Exists(cacheFile))
|
||||
{
|
||||
if (File.GetLastWriteTimeUtc(cacheFile) >= DateTime.UtcNow.Subtract(_maxCacheAge))
|
||||
{
|
||||
return cacheFile;
|
||||
}
|
||||
|
||||
File.Delete(cacheFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(cacheFile));
|
||||
Directory.CreateDirectory(cacheDir);
|
||||
}
|
||||
|
||||
if (info.Path.StartsWith("http", StringComparison.OrdinalIgnoreCase))
|
||||
@@ -154,22 +152,25 @@ namespace Jellyfin.LiveTv.Listings
|
||||
|
||||
private static ProgramInfo GetProgramInfo(XmlTvProgram program, ListingsProviderInfo info)
|
||||
{
|
||||
string episodeTitle = program.Episode.Title;
|
||||
string? episodeTitle = program.Episode?.Title;
|
||||
var programCategories = program.Categories.Where(c => !string.IsNullOrWhiteSpace(c)).ToList();
|
||||
var imageUrl = program.Icons.FirstOrDefault()?.Source;
|
||||
var rating = program.Ratings.FirstOrDefault()?.Value;
|
||||
var starRating = program.StarRatings?.FirstOrDefault()?.StarRating;
|
||||
|
||||
var programInfo = new ProgramInfo
|
||||
{
|
||||
ChannelId = program.ChannelId,
|
||||
EndDate = program.EndDate.UtcDateTime,
|
||||
EpisodeNumber = program.Episode.Episode,
|
||||
EpisodeNumber = program.Episode?.Episode,
|
||||
EpisodeTitle = episodeTitle,
|
||||
Genres = programCategories,
|
||||
StartDate = program.StartDate.UtcDateTime,
|
||||
Name = program.Title,
|
||||
Overview = program.Description,
|
||||
ProductionYear = program.CopyrightDate?.Year,
|
||||
SeasonNumber = program.Episode.Series,
|
||||
IsSeries = program.Episode.Episode is not null,
|
||||
SeasonNumber = program.Episode?.Series,
|
||||
IsSeries = program.Episode?.Episode is not null,
|
||||
IsRepeat = program.IsPreviouslyShown && !program.IsNew,
|
||||
IsPremiere = program.Premiere is not null,
|
||||
IsLive = program.IsLive,
|
||||
@@ -177,11 +178,11 @@ namespace Jellyfin.LiveTv.Listings
|
||||
IsMovie = programCategories.Any(c => info.MovieCategories.Contains(c, StringComparison.OrdinalIgnoreCase)),
|
||||
IsNews = programCategories.Any(c => info.NewsCategories.Contains(c, StringComparison.OrdinalIgnoreCase)),
|
||||
IsSports = programCategories.Any(c => info.SportsCategories.Contains(c, StringComparison.OrdinalIgnoreCase)),
|
||||
ImageUrl = string.IsNullOrEmpty(program.Icon?.Source) ? null : program.Icon.Source,
|
||||
HasImage = !string.IsNullOrEmpty(program.Icon?.Source),
|
||||
OfficialRating = string.IsNullOrEmpty(program.Rating?.Value) ? null : program.Rating.Value,
|
||||
CommunityRating = program.StarRating,
|
||||
SeriesId = program.Episode.Episode is null ? null : program.Title?.GetMD5().ToString("N", CultureInfo.InvariantCulture)
|
||||
ImageUrl = string.IsNullOrEmpty(imageUrl) ? null : imageUrl,
|
||||
HasImage = !string.IsNullOrEmpty(imageUrl),
|
||||
OfficialRating = string.IsNullOrEmpty(rating) ? null : rating,
|
||||
CommunityRating = starRating is null ? null : (float)starRating.Value,
|
||||
SeriesId = program.Episode?.Episode is null ? null : program.Title?.GetMD5().ToString("N", CultureInfo.InvariantCulture)
|
||||
};
|
||||
|
||||
if (string.IsNullOrWhiteSpace(program.ProgramId))
|
||||
@@ -262,7 +263,7 @@ namespace Jellyfin.LiveTv.Listings
|
||||
{
|
||||
Id = c.Id,
|
||||
Name = c.DisplayName,
|
||||
ImageUrl = string.IsNullOrEmpty(c.Icon?.Source) ? null : c.Icon.Source,
|
||||
ImageUrl = string.IsNullOrEmpty(c.Icons.FirstOrDefault()?.Source) ? null : c.Icons.FirstOrDefault()!.Source,
|
||||
Number = string.IsNullOrWhiteSpace(c.Number) ? c.Id : c.Number
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user