Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default language to trending queries #434

Merged
merged 3 commits into from
Jan 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading