From 511f1ef882d594df64810d2c36b59ad381fd6e17 Mon Sep 17 00:00:00 2001 From: Shadowghost Date: Fri, 20 Nov 2026 07:23:42 -0500 Subject: Backport pull request #18048 from jellyfin/release-12.z Follow the Schedules Direct API contract when refreshing the guide Original-merge: 85fa90cb758dabfb434fbd00c1128091007cf6a4 Merged-by: Bond-009 Backported-by: Cody Robibero --- .../LiveTv/ISchedulesDirectService.cs | 37 ++++++++++++++++++---- .../LiveTv/ImageDownloadFailureAction.cs | 17 ++++++++++ 2 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 MediaBrowser.Controller/LiveTv/ImageDownloadFailureAction.cs (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/LiveTv/ISchedulesDirectService.cs b/MediaBrowser.Controller/LiveTv/ISchedulesDirectService.cs index 6953650952..a0df011811 100644 --- a/MediaBrowser.Controller/LiveTv/ISchedulesDirectService.cs +++ b/MediaBrowser.Controller/LiveTv/ISchedulesDirectService.cs @@ -1,6 +1,8 @@ using System.IO; +using System.Net; using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Controller.Entities; namespace MediaBrowser.Controller.LiveTv; @@ -17,15 +19,36 @@ public interface ISchedulesDirectService Task GetAvailableCountries(CancellationToken cancellationToken); /// - /// Gets a value indicating whether the Schedules Direct daily image download limit is currently active. + /// Gets a value indicating whether an image may be downloaded from the given url. /// - /// true if the image limit has been hit and has not yet reset; otherwise false. - bool IsImageDailyLimitActive(); + /// The image url. + /// false for a Schedules Direct url while the daily image limit is active; otherwise true. + bool CanDownloadImage(string imageUrl); /// - /// Gets a value indicating whether the Schedules Direct service is available. - /// Returns false if a permanent account error has occurred or a transient backoff is active. + /// Reports a successful image download, so that an unexplained failure streak is reset. /// - /// true if the service can accept requests; otherwise false. - bool IsServiceAvailable(); + /// The image url that was downloaded. + void ReportImageDownloadSuccess(string imageUrl); + + /// + /// Reports a failed image download. Schedules Direct answers an exhausted image quota with + /// an HTTP 200 JSON error body rather than a failure status, so the body is what decides + /// whether image acquisition has to stop. + /// + /// The image url that failed. + /// The HTTP status code of the failure, if any. + /// The body of the failed response, if it was readable. + /// What the caller must do with the image. + ImageDownloadFailureAction ReportImageDownloadFailure(string imageUrl, HttpStatusCode? statusCode, string? responseBody); + + /// + /// Downloads a remote image unless Schedules Direct has blocked it, and reports the outcome. + /// Schedules Direct counts every image request, so downloads outside the guide refresh go through here. + /// + /// The item the image belongs to. + /// The remote image. + /// The image index. + /// The local image, or null when the download is blocked. + Task ConvertImageToLocal(BaseItem item, ItemImageInfo image, int imageIndex); } diff --git a/MediaBrowser.Controller/LiveTv/ImageDownloadFailureAction.cs b/MediaBrowser.Controller/LiveTv/ImageDownloadFailureAction.cs new file mode 100644 index 0000000000..78a1e554b6 --- /dev/null +++ b/MediaBrowser.Controller/LiveTv/ImageDownloadFailureAction.cs @@ -0,0 +1,17 @@ +namespace MediaBrowser.Controller.LiveTv; + +/// +/// What the caller must do with an image after a failed download. +/// +public enum ImageDownloadFailureAction +{ + /// + /// Keep the image; the download may succeed on a later attempt. + /// + None = 0, + + /// + /// Drop the image. The url is permanently invalid and re-requesting it gets the account blocked. + /// + RemoveImage = 1 +} -- cgit v1.2.3