aboutsummaryrefslogtreecommitdiff
path: root/src/Jellyfin.LiveTv/Guide/GuideManager.cs
diff options
context:
space:
mode:
authorShadowghost <Ghost_of_Stone@web.de>2026-02-22 11:14:15 +0100
committerShadowghost <Ghost_of_Stone@web.de>2026-02-22 11:14:15 +0100
commit27396bffc6d2cc0595ffba4dd400a9e5bbfafc0f (patch)
tree662a7189e9c96d80df9a1d51babe2b23207c2946 /src/Jellyfin.LiveTv/Guide/GuideManager.cs
parentd156e04c9a2b16d38aede38f0de773a4d128e48f (diff)
Handle 5002, 5003 and add caches
Diffstat (limited to 'src/Jellyfin.LiveTv/Guide/GuideManager.cs')
-rw-r--r--src/Jellyfin.LiveTv/Guide/GuideManager.cs59
1 files changed, 49 insertions, 10 deletions
diff --git a/src/Jellyfin.LiveTv/Guide/GuideManager.cs b/src/Jellyfin.LiveTv/Guide/GuideManager.cs
index ac59a6d125..7e1992baf2 100644
--- a/src/Jellyfin.LiveTv/Guide/GuideManager.cs
+++ b/src/Jellyfin.LiveTv/Guide/GuideManager.cs
@@ -40,6 +40,11 @@ public class GuideManager : IGuideManager
private readonly LiveTvDtoService _tvDtoService;
/// <summary>
+ /// UTC date when the SD image download limit was hit. Cleared after 00:00 UTC rollover.
+ /// </summary>
+ private DateTime? _sdImageLimitHitDate;
+
+ /// <summary>
/// Amount of days images are pre-cached from external sources.
/// </summary>
public const int MaxCacheDays = 2;
@@ -721,6 +726,20 @@ public class GuideManager : IGuideManager
return false;
}
+ private bool IsSdImageLimitActive()
+ {
+ // The SD image counter resets daily at 00:00 UTC.
+ // If we recorded a limit hit on a previous UTC date, clear it.
+ var hitDate = _sdImageLimitHitDate;
+ if (hitDate.HasValue && hitDate.Value.Date < DateTime.UtcNow.Date)
+ {
+ _sdImageLimitHitDate = null;
+ return false;
+ }
+
+ return hitDate.HasValue;
+ }
+
private async Task PreCacheImages(IReadOnlyList<BaseItem> programs, DateTime maxCacheDate)
{
await Parallel.ForEachAsync(
@@ -738,19 +757,39 @@ public class GuideManager : IGuideManager
}
var imageInfo = program.ImageInfos[i];
- if (!imageInfo.IsLocalFile)
+ if (imageInfo.IsLocalFile)
+ {
+ continue;
+ }
+
+ // Skip SD downloads once the daily limit has been hit.
+ if (imageInfo.Path.Contains("schedulesdirect", StringComparison.OrdinalIgnoreCase)
+ && IsSdImageLimitActive())
+ {
+ continue;
+ }
+
+ _logger.LogDebug("Caching image locally: {Url}", imageInfo.Path);
+ try
+ {
+ program.ImageInfos[i] = await _libraryManager.ConvertImageToLocal(
+ program,
+ imageInfo,
+ imageIndex: 0,
+ removeOnFailure: false)
+ .ConfigureAwait(false);
+ }
+ catch (Exception ex)
{
- _logger.LogDebug("Caching image locally: {Url}", imageInfo.Path);
- try
+ if (imageInfo.Path.Contains("schedulesdirect", StringComparison.OrdinalIgnoreCase)
+ && !_sdImageLimitHitDate.HasValue)
{
- program.ImageInfos[i] = await _libraryManager.ConvertImageToLocal(
- program,
- imageInfo,
- imageIndex: 0,
- removeOnFailure: false)
- .ConfigureAwait(false);
+ _sdImageLimitHitDate = DateTime.UtcNow;
+ _logger.LogWarning(
+ "Schedules Direct image download failed for {Url}. Daily download limit may have been reached (resets at 00:00 UTC). Skipping remaining SD images until reset",
+ imageInfo.Path);
}
- catch (Exception ex)
+ else if (!imageInfo.Path.Contains("schedulesdirect", StringComparison.OrdinalIgnoreCase))
{
_logger.LogWarning(ex, "Unable to pre-cache {Url}", imageInfo.Path);
}