Skip to content

Commit

Permalink
Use TMDB id for VOD metadata if known
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevinjil committed Jan 4, 2025
1 parent 5c59881 commit b9190bb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Jellyfin.Xtream/Client/XtreamClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ public Task<List<StreamInfo>> GetVodStreamsByCategoryAsync(ConnectionInfo connec
$"/player_api.php?username={connectionInfo.UserName}&password={connectionInfo.Password}&action=get_vod_streams&category_id={categoryId}",
cancellationToken);

public Task<VodStreamInfo> GetVodInfoAsync(ConnectionInfo connectionInfo, int streamId, CancellationToken cancellationToken) =>
QueryApi<VodStreamInfo>(
connectionInfo,
$"/player_api.php?username={connectionInfo.UserName}&password={connectionInfo.Password}&action=get_vod_info&vod_id={streamId}",
cancellationToken);

public Task<List<StreamInfo>> GetLiveStreamsByCategoryAsync(ConnectionInfo connectionInfo, int categoryId, CancellationToken cancellationToken) =>
QueryApi<List<StreamInfo>>(
connectionInfo,
Expand Down
12 changes: 10 additions & 2 deletions Jellyfin.Xtream/VodChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,10 @@ private async Task<ChannelItemInfo> 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,
Expand All @@ -161,6 +160,15 @@ private async Task<ChannelItemInfo> CreateChannelItemInfo(StreamInfo stream)
Tags = new List<string>(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<ChannelItemResult> GetCategories(CancellationToken cancellationToken)
Expand Down

0 comments on commit b9190bb

Please sign in to comment.