diff options
| author | Niels van Velzen <nielsvanvelzen@users.noreply.github.com> | 2026-05-05 15:53:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-05-05 15:53:19 +0200 |
| commit | 4178e0ebaf2ff7162f474e17e27cd5bbbfafd548 (patch) | |
| tree | 819a9ec8361334847d8601448273cd71f2aae20a /src/Jellyfin.LiveTv/Guide | |
| parent | 064fd8c5c0946ccecc686606528faa8f3b47dc96 (diff) | |
| parent | 6be96100c72a77b5c1db5921ec731ee002b7c48d (diff) | |
Fix EPG issues
Diffstat (limited to 'src/Jellyfin.LiveTv/Guide')
| -rw-r--r-- | src/Jellyfin.LiveTv/Guide/GuideManager.cs | 55 |
1 files changed, 40 insertions, 15 deletions
diff --git a/src/Jellyfin.LiveTv/Guide/GuideManager.cs b/src/Jellyfin.LiveTv/Guide/GuideManager.cs index ac59a6d125..556516674b 100644 --- a/src/Jellyfin.LiveTv/Guide/GuideManager.cs +++ b/src/Jellyfin.LiveTv/Guide/GuideManager.cs @@ -37,6 +37,7 @@ public class GuideManager : IGuideManager private readonly ILiveTvManager _liveTvManager; private readonly ITunerHostManager _tunerHostManager; private readonly IRecordingsManager _recordingsManager; + private readonly ISchedulesDirectService _schedulesDirectService; private readonly LiveTvDtoService _tvDtoService; /// <summary> @@ -55,6 +56,7 @@ public class GuideManager : IGuideManager /// <param name="liveTvManager">The <see cref="ILiveTvManager"/>.</param> /// <param name="tunerHostManager">The <see cref="ITunerHostManager"/>.</param> /// <param name="recordingsManager">The <see cref="IRecordingsManager"/>.</param> + /// <param name="schedulesDirectService">The <see cref="ISchedulesDirectService"/>.</param> /// <param name="tvDtoService">The <see cref="LiveTvDtoService"/>.</param> public GuideManager( ILogger<GuideManager> logger, @@ -65,6 +67,7 @@ public class GuideManager : IGuideManager ILiveTvManager liveTvManager, ITunerHostManager tunerHostManager, IRecordingsManager recordingsManager, + ISchedulesDirectService schedulesDirectService, LiveTvDtoService tvDtoService) { _logger = logger; @@ -75,6 +78,7 @@ public class GuideManager : IGuideManager _liveTvManager = liveTvManager; _tunerHostManager = tunerHostManager; _recordingsManager = recordingsManager; + _schedulesDirectService = schedulesDirectService; _tvDtoService = tvDtoService; } @@ -723,13 +727,25 @@ public class GuideManager : IGuideManager private async Task PreCacheImages(IReadOnlyList<BaseItem> programs, DateTime maxCacheDate) { + var sdLimitActive = _schedulesDirectService.IsImageDailyLimitActive(); + await Parallel.ForEachAsync( programs .Where(p => p.EndDate.HasValue && p.EndDate.Value < maxCacheDate) + .Where(p => !sdLimitActive || !p.ImageInfos.All( + img => img.IsLocalFile || img.Path.Contains("schedulesdirect", StringComparison.OrdinalIgnoreCase))) .DistinctBy(p => p.Id), _cacheParallelOptions, async (program, cancellationToken) => { + // Re-check: limit may have been set by a parallel task since the LINQ filter ran. + if (_schedulesDirectService.IsImageDailyLimitActive() + && program.ImageInfos.All( + img => img.IsLocalFile || img.Path.Contains("schedulesdirect", StringComparison.OrdinalIgnoreCase))) + { + return; + } + for (var i = 0; i < program.ImageInfos.Length; i++) { if (cancellationToken.IsCancellationRequested) @@ -738,22 +754,31 @@ public class GuideManager : IGuideManager } var imageInfo = program.ImageInfos[i]; - if (!imageInfo.IsLocalFile) + if (imageInfo.IsLocalFile) { - _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.LogWarning(ex, "Unable to pre-cache {Url}", imageInfo.Path); - } + continue; + } + + // Skip SD downloads once the daily limit has been hit. + if (imageInfo.Path.Contains("schedulesdirect", StringComparison.OrdinalIgnoreCase) + && _schedulesDirectService.IsImageDailyLimitActive()) + { + 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.LogWarning(ex, "Unable to pre-cache {Url}", imageInfo.Path); } } }).ConfigureAwait(false); |
