From 35b084f15a3b21013e8a505e486b10408ee7877e Mon Sep 17 00:00:00 2001 From: Dinesh Solanki <15937452+DineshSolanki@users.noreply.github.com> Date: Mon, 8 Jul 2024 14:32:03 +0530 Subject: [PATCH 1/2] fix #500: Add language parameter to GetTvShowVideosAsync method The GetTvShowVideosAsync method has been updated to include an optional language parameter. This parameter allows users of the TMDbClient library to retrieve videos in a specific language instead of only in default(en-US) --- TMDbLib/Client/TMDbClientTvShows.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TMDbLib/Client/TMDbClientTvShows.cs b/TMDbLib/Client/TMDbClientTvShows.cs index 140ae165..f85121aa 100644 --- a/TMDbLib/Client/TMDbClientTvShows.cs +++ b/TMDbLib/Client/TMDbClientTvShows.cs @@ -315,9 +315,9 @@ public async Task GetTvShowTranslationsAsync(int id, Ca return await GetTvShowMethodInternal(id, TvShowMethods.Translations, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task> GetTvShowVideosAsync(int id, CancellationToken cancellationToken = default) + public async Task> GetTvShowVideosAsync(int id, string language = null, CancellationToken cancellationToken = default) { - return await GetTvShowMethodInternal>(id, TvShowMethods.Videos, cancellationToken: cancellationToken).ConfigureAwait(false); + return await GetTvShowMethodInternal>(id, TvShowMethods.Videos, language:language, cancellationToken: cancellationToken).ConfigureAwait(false); } public async Task>> GetTvShowWatchProvidersAsync(int id, CancellationToken cancellationToken = default) From 8a61a9a90b12e556c54ae696217ea86f5cdcf0e0 Mon Sep 17 00:00:00 2001 From: Dinesh Solanki <15937452+DineshSolanki@users.noreply.github.com> Date: Mon, 8 Jul 2024 14:58:26 +0530 Subject: [PATCH 2/2] Refactor GetTvShowMethodInternal to include media language for videos method This change renames the parameter "includeImageLanguage" with "includeMediaLanguage" and adjusts the logic to accommodate either images or videos. This lets user, specify a comma-separated list of language (such as 'hi-IN,en-US') to filter out result instead of a single language. See https://developer.themoviedb.org/reference/tv-series-videos --- TMDbLib/Client/TMDbClientTvShows.cs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/TMDbLib/Client/TMDbClientTvShows.cs b/TMDbLib/Client/TMDbClientTvShows.cs index f85121aa..cdd2c15b 100644 --- a/TMDbLib/Client/TMDbClientTvShows.cs +++ b/TMDbLib/Client/TMDbClientTvShows.cs @@ -18,7 +18,7 @@ namespace TMDbLib.Client { public partial class TMDbClient { - private async Task GetTvShowMethodInternal(int id, TvShowMethods tvShowMethod, string dateFormat = null, string language = null, string includeImageLanguage = null, int page = 0, CancellationToken cancellationToken = default) where T : new() + private async Task GetTvShowMethodInternal(int id, TvShowMethods tvShowMethod, string dateFormat = null, string language = null, string includeMediaLanguage = null, int page = 0, CancellationToken cancellationToken = default) where T : new() { RestRequest req = _client.Create("tv/{id}/{method}"); req.AddUrlSegment("id", id.ToString(CultureInfo.InvariantCulture)); @@ -35,10 +35,14 @@ public partial class TMDbClient if (!string.IsNullOrWhiteSpace(language)) req.AddParameter("language", language); - includeImageLanguage ??= DefaultImageLanguage; - if (!string.IsNullOrWhiteSpace(includeImageLanguage)) - req.AddParameter("include_image_language", includeImageLanguage); - + includeMediaLanguage ??= DefaultImageLanguage; + if (!string.IsNullOrWhiteSpace(includeMediaLanguage)) + { + req.AddParameter( + tvShowMethod == TvShowMethods.Videos ? "include_video_language" : "include_image_language", + includeMediaLanguage); + } + T resp = await req.GetOfT(cancellationToken).ConfigureAwait(false); return resp; @@ -211,7 +215,7 @@ public async Task GetTvShowExternalIdsAsync(int id, Cancellat /// A cancellation token public async Task GetTvShowImagesAsync(int id, string language = null, string includeImageLanguage = null, CancellationToken cancellationToken = default) { - return await GetTvShowMethodInternal(id, TvShowMethods.Images, language: language, includeImageLanguage: includeImageLanguage, cancellationToken: cancellationToken).ConfigureAwait(false); + return await GetTvShowMethodInternal(id, TvShowMethods.Images, language: language, includeMediaLanguage: includeImageLanguage, cancellationToken: cancellationToken).ConfigureAwait(false); } public async Task> GetTvShowReviewsAsync(int id, string language = null, int page = 0, CancellationToken cancellationToken = default) @@ -315,9 +319,9 @@ public async Task GetTvShowTranslationsAsync(int id, Ca return await GetTvShowMethodInternal(id, TvShowMethods.Translations, cancellationToken: cancellationToken).ConfigureAwait(false); } - public async Task> GetTvShowVideosAsync(int id, string language = null, CancellationToken cancellationToken = default) + public async Task> GetTvShowVideosAsync(int id, string includeMediaLanguage = null, CancellationToken cancellationToken = default) { - return await GetTvShowMethodInternal>(id, TvShowMethods.Videos, language:language, cancellationToken: cancellationToken).ConfigureAwait(false); + return await GetTvShowMethodInternal>(id, TvShowMethods.Videos, includeMediaLanguage:includeMediaLanguage, cancellationToken: cancellationToken).ConfigureAwait(false); } public async Task>> GetTvShowWatchProvidersAsync(int id, CancellationToken cancellationToken = default)