diff options
| author | theguymadmax <theguymadmax@proton.me> | 2026-08-05 13:18:08 -0400 |
|---|---|---|
| committer | theguymadmax <theguymadmax@proton.me> | 2026-08-05 14:02:28 -0400 |
| commit | f49a501f71b22b02826c13fad2fc4ebaf82ee3ec (patch) | |
| tree | 661e717caa7853928e29ec9463f6e574e566d384 | |
| parent | f6ca06e9bfa890f8ab31afd3705f5df2c58ed510 (diff) | |
Revert "Refresh Live TV channel icons on every guide update."
This reverts commit 372c1681d8272c6fa8f120a132bc40351067fb10.
| -rw-r--r-- | src/Jellyfin.LiveTv/Channels/ChannelManager.cs | 4 | ||||
| -rw-r--r-- | src/Jellyfin.LiveTv/Guide/GuideManager.cs | 19 | ||||
| -rw-r--r-- | src/Jellyfin.LiveTv/LiveTvChannelImageHelper.cs | 33 | ||||
| -rw-r--r-- | tests/Jellyfin.LiveTv.Tests/LiveTvChannelImageHelperTests.cs | 51 |
4 files changed, 18 insertions, 89 deletions
diff --git a/src/Jellyfin.LiveTv/Channels/ChannelManager.cs b/src/Jellyfin.LiveTv/Channels/ChannelManager.cs index e421601092..ed02fe6a1d 100644 --- a/src/Jellyfin.LiveTv/Channels/ChannelManager.cs +++ b/src/Jellyfin.LiveTv/Channels/ChannelManager.cs @@ -14,7 +14,6 @@ using Jellyfin.Database.Implementations.Entities; using Jellyfin.Database.Implementations.Enums; using Jellyfin.Extensions; using Jellyfin.Extensions.Json; -using Jellyfin.LiveTv; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.Configuration; @@ -1110,8 +1109,9 @@ namespace Jellyfin.LiveTv.Channels item.Path = mediaSource?.Path; } - if (LiveTvChannelImageHelper.UpdateChannelImageIfNeeded(item, null, info.ImageUrl)) + if (!string.IsNullOrEmpty(info.ImageUrl) && !item.HasImage(ImageType.Primary)) { + item.SetImagePath(ImageType.Primary, info.ImageUrl); _logger.LogDebug("Forcing update due to ImageUrl {0}", item.Name); forceUpdate = true; } diff --git a/src/Jellyfin.LiveTv/Guide/GuideManager.cs b/src/Jellyfin.LiveTv/Guide/GuideManager.cs index 4e1b62cdf9..41520f8789 100644 --- a/src/Jellyfin.LiveTv/Guide/GuideManager.cs +++ b/src/Jellyfin.LiveTv/Guide/GuideManager.cs @@ -5,7 +5,6 @@ using System.Threading; using System.Threading.Tasks; using Jellyfin.Data.Enums; using Jellyfin.Extensions; -using Jellyfin.LiveTv; using Jellyfin.LiveTv.Configuration; using Jellyfin.LiveTv.Listings; using MediaBrowser.Common.Configuration; @@ -450,9 +449,23 @@ public class GuideManager : IGuideManager item.Name = channelInfo.Name; - if (LiveTvChannelImageHelper.UpdateChannelImageIfNeeded(item, channelInfo.ImagePath, channelInfo.ImageUrl)) + var currentPrimary = item.GetImageInfo(ImageType.Primary, 0); + var imageUrlIsNull = string.IsNullOrWhiteSpace(channelInfo.ImageUrl); + + // Update channel image if image URL has changed + if (currentPrimary is null + || (!imageUrlIsNull && !string.Equals(currentPrimary.Path, channelInfo.ImageUrl, StringComparison.Ordinal))) { - forceUpdate = true; + if (!string.IsNullOrWhiteSpace(channelInfo.ImagePath)) + { + item.SetImagePath(ImageType.Primary, channelInfo.ImagePath); + forceUpdate = true; + } + else if (!imageUrlIsNull) + { + item.SetImagePath(ImageType.Primary, channelInfo.ImageUrl); + forceUpdate = true; + } } if (isNew) diff --git a/src/Jellyfin.LiveTv/LiveTvChannelImageHelper.cs b/src/Jellyfin.LiveTv/LiveTvChannelImageHelper.cs deleted file mode 100644 index a590193b5f..0000000000 --- a/src/Jellyfin.LiveTv/LiveTvChannelImageHelper.cs +++ /dev/null @@ -1,33 +0,0 @@ -using MediaBrowser.Controller.Entities; -using MediaBrowser.Model.Entities; - -namespace Jellyfin.LiveTv; - -/// <summary> -/// Helpers for keeping Live TV channel icons in sync with guide data. -/// </summary> -internal static class LiveTvChannelImageHelper -{ - /// <summary> - /// Applies the channel icon from guide or tuner metadata. - /// Called on each guide refresh so remote icons are re-downloaded even when the URL is unchanged. - /// </summary> - /// <param name="item">The channel item.</param> - /// <param name="imagePath">The local image path from the tuner, if any.</param> - /// <param name="imageUrl">The remote image URL from the guide provider, if any.</param> - /// <returns><c>true</c> when the item image metadata was updated.</returns> - internal static bool UpdateChannelImageIfNeeded(BaseItem item, string? imagePath, string? imageUrl) - { - var newImageSource = !string.IsNullOrWhiteSpace(imagePath) - ? imagePath - : imageUrl; - - if (string.IsNullOrWhiteSpace(newImageSource)) - { - return false; - } - - item.SetImagePath(ImageType.Primary, newImageSource); - return true; - } -} diff --git a/tests/Jellyfin.LiveTv.Tests/LiveTvChannelImageHelperTests.cs b/tests/Jellyfin.LiveTv.Tests/LiveTvChannelImageHelperTests.cs deleted file mode 100644 index f44cb88834..0000000000 --- a/tests/Jellyfin.LiveTv.Tests/LiveTvChannelImageHelperTests.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Jellyfin.LiveTv; -using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.LiveTv; -using MediaBrowser.Model.Entities; -using Xunit; - -namespace Jellyfin.LiveTv.Tests; - -public class LiveTvChannelImageHelperTests -{ - [Fact] - public void UpdateChannelImageIfNeeded_NoSource_DoesNotUpdate() - { - var channel = new LiveTvChannel { Name = "Test Channel" }; - - var updated = LiveTvChannelImageHelper.UpdateChannelImageIfNeeded(channel, null, null); - - Assert.False(updated); - Assert.False(channel.HasImage(ImageType.Primary)); - } - - [Fact] - public void UpdateChannelImageIfNeeded_WithUrl_AppliesUrl() - { - var channel = new LiveTvChannel { Name = "Test Channel" }; - - var updated = LiveTvChannelImageHelper.UpdateChannelImageIfNeeded( - channel, - null, - "https://example.com/icon.png"); - - Assert.True(updated); - Assert.True(channel.HasImage(ImageType.Primary)); - Assert.Equal("https://example.com/icon.png", channel.GetImagePath(ImageType.Primary)); - } - - [Fact] - public void UpdateChannelImageIfNeeded_SameUrl_StillUpdates() - { - var channel = new LiveTvChannel { Name = "Test Channel" }; - LiveTvChannelImageHelper.UpdateChannelImageIfNeeded(channel, null, "https://example.com/icon.png"); - - var updated = LiveTvChannelImageHelper.UpdateChannelImageIfNeeded( - channel, - null, - "https://example.com/icon.png"); - - Assert.True(updated); - Assert.Equal("https://example.com/icon.png", channel.GetImagePath(ImageType.Primary)); - } -} |
