Skip to content

Commit

Permalink
Merge pull request jellyfin#401 from angyanmark/features/get-popular-…
Browse files Browse the repository at this point in the history
…people-refactor

Get popular people refactor
  • Loading branch information
LordMike committed Jan 9, 2023
2 parents ddb1233 + 3f69191 commit fe50e09
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 51 deletions.
18 changes: 6 additions & 12 deletions TMDbLib/Client/TMDbClientPeople.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Threading.Tasks;
using TMDbLib.Objects.General;
using TMDbLib.Objects.People;
using TMDbLib.Objects.Search;
using TMDbLib.Rest;
using TMDbLib.Utilities;

Expand Down Expand Up @@ -113,26 +114,19 @@ public async Task<ProfileImages> GetPersonImagesAsync(int personId, Cancellation
return await GetPersonMethodInternal<ProfileImages>(personId, PersonMethods.Images, cancellationToken: cancellationToken).ConfigureAwait(false);
}

public async Task<SearchContainer<PersonResult>> GetPersonListAsync(PersonListType type, int page = 0, CancellationToken cancellationToken = default)
public async Task<SearchContainer<SearchPerson>> GetPersonPopularListAsync(int page = 0, string language = null, CancellationToken cancellationToken = default)
{
RestRequest req;
switch (type)
{
case PersonListType.Popular:
req = _client.Create("person/popular");
break;

default:
throw new ArgumentOutOfRangeException(nameof(type));
}
RestRequest req = _client.Create("person/popular");

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

// TODO: Dateformat?
//req.DateFormat = "yyyy-MM-dd";

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

return resp;
}
Expand Down
27 changes: 0 additions & 27 deletions TMDbLib/Objects/General/PersonResult.cs

This file was deleted.

7 changes: 0 additions & 7 deletions TMDbLib/Objects/People/PersonListType.cs

This file was deleted.

7 changes: 2 additions & 5 deletions TMDbLibTests/ClientPersonTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,9 @@ public async Task TestPersonsTaggedImagesAsync()
[Fact]
public async Task TestPersonsListAsync()
{
foreach (PersonListType type in Enum.GetValues(typeof(PersonListType)).OfType<PersonListType>())
{
SearchContainer<PersonResult> list = await TMDbClient.GetPersonListAsync(type);
SearchContainer<SearchPerson> list = await TMDbClient.GetPersonPopularListAsync();

Assert.NotEmpty(list.Results);
}
Assert.NotEmpty(list.Results);
}

[Fact]
Expand Down

0 comments on commit fe50e09

Please sign in to comment.