From b9190bbb15b5081bf669e46ca0bbe6dee7d924f9 Mon Sep 17 00:00:00 2001 From: Kevin Jilissen Date: Sat, 4 Jan 2025 01:27:38 +0100 Subject: [PATCH] Use TMDB id for VOD metadata if known --- Jellyfin.Xtream/Client/XtreamClient.cs | 6 ++++++ Jellyfin.Xtream/VodChannel.cs | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Jellyfin.Xtream/Client/XtreamClient.cs b/Jellyfin.Xtream/Client/XtreamClient.cs index b635850..2cf8f01 100644 --- a/Jellyfin.Xtream/Client/XtreamClient.cs +++ b/Jellyfin.Xtream/Client/XtreamClient.cs @@ -78,6 +78,12 @@ public Task> GetVodStreamsByCategoryAsync(ConnectionInfo connec $"/player_api.php?username={connectionInfo.UserName}&password={connectionInfo.Password}&action=get_vod_streams&category_id={categoryId}", cancellationToken); + public Task GetVodInfoAsync(ConnectionInfo connectionInfo, int streamId, CancellationToken cancellationToken) => + QueryApi( + connectionInfo, + $"/player_api.php?username={connectionInfo.UserName}&password={connectionInfo.Password}&action=get_vod_info&vod_id={streamId}", + cancellationToken); + public Task> GetLiveStreamsByCategoryAsync(ConnectionInfo connectionInfo, int categoryId, CancellationToken cancellationToken) => QueryApi>( connectionInfo, diff --git a/Jellyfin.Xtream/VodChannel.cs b/Jellyfin.Xtream/VodChannel.cs index f90b038..8be4ded 100644 --- a/Jellyfin.Xtream/VodChannel.cs +++ b/Jellyfin.Xtream/VodChannel.cs @@ -147,11 +147,10 @@ private async Task CreateChannelItemInfo(StreamInfo stream) audioInfo: info?.Info?.Audio) }; - return new ChannelItemInfo() + ChannelItemInfo result = new ChannelItemInfo() { ContentType = ChannelMediaContentType.Movie, DateCreated = DateTimeOffset.FromUnixTimeSeconds(added).DateTime, - FolderType = ChannelFolderType.Container, Id = $"{StreamService.StreamPrefix}{stream.StreamId}", ImageUrl = stream.StreamIcon, IsLiveStream = false, @@ -161,6 +160,15 @@ private async Task CreateChannelItemInfo(StreamInfo stream) Tags = new List(parsedName.Tags), Type = ChannelItemType.Media, }; + + if (info?.Info?.TmdbId is int tmdbId) + { + logger.LogInformation("TMDB id {Id} for {Stream}", tmdbId, stream.StreamId); + result.SetProviderId(MetadataProvider.Tmdb, tmdbId.ToString(CultureInfo.InvariantCulture)); + } + + return result; + } } private async Task GetCategories(CancellationToken cancellationToken)