| | | 1 | | using MediaBrowser.Controller.Entities; |
| | | 2 | | using MediaBrowser.Model.Entities; |
| | | 3 | | |
| | | 4 | | namespace Jellyfin.LiveTv; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Helpers for keeping Live TV channel icons in sync with guide data. |
| | | 8 | | /// </summary> |
| | | 9 | | internal static class LiveTvChannelImageHelper |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// Applies the channel icon from guide or tuner metadata. |
| | | 13 | | /// Called on each guide refresh so remote icons are re-downloaded even when the URL is unchanged. |
| | | 14 | | /// </summary> |
| | | 15 | | /// <param name="item">The channel item.</param> |
| | | 16 | | /// <param name="imagePath">The local image path from the tuner, if any.</param> |
| | | 17 | | /// <param name="imageUrl">The remote image URL from the guide provider, if any.</param> |
| | | 18 | | /// <returns><c>true</c> when the item image metadata was updated.</returns> |
| | | 19 | | internal static bool UpdateChannelImageIfNeeded(BaseItem item, string? imagePath, string? imageUrl) |
| | | 20 | | { |
| | 4 | 21 | | var newImageSource = !string.IsNullOrWhiteSpace(imagePath) |
| | 4 | 22 | | ? imagePath |
| | 4 | 23 | | : imageUrl; |
| | | 24 | | |
| | 4 | 25 | | if (string.IsNullOrWhiteSpace(newImageSource)) |
| | | 26 | | { |
| | 1 | 27 | | return false; |
| | | 28 | | } |
| | | 29 | | |
| | 3 | 30 | | item.SetImagePath(ImageType.Primary, newImageSource); |
| | 3 | 31 | | return true; |
| | | 32 | | } |
| | | 33 | | } |