mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-29 11:02:14 +01:00
Refresh Live TV channel icons on every guide update.
Guide refresh skipped channel logos once a primary image existed, so stale EPG/tuner icons never got replaced.
This commit is contained in:
@@ -14,6 +14,7 @@ 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;
|
||||
@@ -1109,9 +1110,8 @@ namespace Jellyfin.LiveTv.Channels
|
||||
item.Path = mediaSource?.Path;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(info.ImageUrl) && !item.HasImage(ImageType.Primary))
|
||||
if (LiveTvChannelImageHelper.UpdateChannelImageIfNeeded(item, null, info.ImageUrl))
|
||||
{
|
||||
item.SetImagePath(ImageType.Primary, info.ImageUrl);
|
||||
_logger.LogDebug("Forcing update due to ImageUrl {0}", item.Name);
|
||||
forceUpdate = true;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Jellyfin.Data.Enums;
|
||||
using Jellyfin.Extensions;
|
||||
using Jellyfin.LiveTv;
|
||||
using Jellyfin.LiveTv.Configuration;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
@@ -448,18 +449,9 @@ public class GuideManager : IGuideManager
|
||||
|
||||
item.Name = channelInfo.Name;
|
||||
|
||||
if (!item.HasImage(ImageType.Primary))
|
||||
if (LiveTvChannelImageHelper.UpdateChannelImageIfNeeded(item, channelInfo.ImagePath, channelInfo.ImageUrl))
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(channelInfo.ImagePath))
|
||||
{
|
||||
item.SetImagePath(ImageType.Primary, channelInfo.ImagePath);
|
||||
forceUpdate = true;
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(channelInfo.ImageUrl))
|
||||
{
|
||||
item.SetImagePath(ImageType.Primary, channelInfo.ImageUrl);
|
||||
forceUpdate = true;
|
||||
}
|
||||
forceUpdate = true;
|
||||
}
|
||||
|
||||
if (isNew)
|
||||
|
||||
33
src/Jellyfin.LiveTv/LiveTvChannelImageHelper.cs
Normal file
33
src/Jellyfin.LiveTv/LiveTvChannelImageHelper.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user