Skip to content

Commit

Permalink
Merge pull request #434 from Szajkop/master
Browse files Browse the repository at this point in the history
Add default language to trending queries
  • Loading branch information
Shadowghost authored Jan 5, 2024
2 parents 21fc2b5 + c7f50e3 commit 3bf0087
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions TMDbLib/Client/TMDbClientTrending.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Threading;
using System.Threading.Tasks;
using TMDbLib.Objects.General;
using TMDbLib.Objects.Languages;
using TMDbLib.Objects.Search;
using TMDbLib.Objects.Trending;
using TMDbLib.Rest;
Expand All @@ -17,8 +18,11 @@ public async Task<SearchContainer<SearchMovie>> GetTrendingMoviesAsync(TimeWindo

if (page >= 1)
req.AddQueryString("page", page.ToString());
if (language != null)

if (!string.IsNullOrWhiteSpace(language))
req.AddQueryString("language", language);
else if (!string.IsNullOrWhiteSpace(DefaultLanguage))
req.AddParameter("language", DefaultLanguage);

SearchContainer<SearchMovie> resp = await req.GetOfT<SearchContainer<SearchMovie>>(cancellationToken).ConfigureAwait(false);

Expand All @@ -32,8 +36,11 @@ public async Task<SearchContainer<SearchTv>> GetTrendingTvAsync(TimeWindow timeW

if (page >= 1)
req.AddQueryString("page", page.ToString());
if (language != null)

if (!string.IsNullOrWhiteSpace(language))
req.AddQueryString("language", language);
else if (!string.IsNullOrWhiteSpace(DefaultLanguage))
req.AddParameter("language", DefaultLanguage);

SearchContainer<SearchTv> resp = await req.GetOfT<SearchContainer<SearchTv>>(cancellationToken).ConfigureAwait(false);

Expand All @@ -47,8 +54,11 @@ public async Task<SearchContainer<SearchPerson>> GetTrendingPeopleAsync(TimeWind

if (page >= 1)
req.AddQueryString("page", page.ToString());
if (language != null)

if (!string.IsNullOrWhiteSpace(language))
req.AddQueryString("language", language);
else if (!string.IsNullOrWhiteSpace(DefaultLanguage))
req.AddParameter("language", DefaultLanguage);

SearchContainer<SearchPerson> resp = await req.GetOfT<SearchContainer<SearchPerson>>(cancellationToken).ConfigureAwait(false);

Expand All @@ -62,8 +72,11 @@ public async Task<SearchContainer<SearchBase>> GetTrendingAllAsync(TimeWindow ti

if (page >= 1)
req.AddQueryString("page", page.ToString());
if (language != null)

if (!string.IsNullOrWhiteSpace(language))
req.AddQueryString("language", language);
else if (!string.IsNullOrWhiteSpace(DefaultLanguage))
req.AddParameter("language", DefaultLanguage);

SearchContainer<SearchBase> resp = await req.GetOfT<SearchContainer<SearchBase>>(cancellationToken).ConfigureAwait(false);

Expand Down

0 comments on commit 3bf0087

Please sign in to comment.