mirror of
https://github.com/jellyfin/TMDbLib.git
synced 2024-12-03 11:21:07 +00:00
commit
65ad5eabe5
@ -159,12 +159,12 @@ namespace TMDbLib.Client
|
||||
|
||||
public async Task<ImagesWithId> GetMovieImagesAsync(int movieId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return await GetMovieImagesAsync(movieId, DefaultLanguage, cancellationToken).ConfigureAwait(false);
|
||||
return await GetMovieImagesAsync(movieId, DefaultLanguage, null, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<ImagesWithId> GetMovieImagesAsync(int movieId, string language, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<ImagesWithId> GetMovieImagesAsync(int movieId, string language, string includeImageLanguage = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return await GetMovieMethod<ImagesWithId>(movieId, MovieMethods.Images, language: language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetMovieMethod<ImagesWithId>(movieId, MovieMethods.Images, language: language, includeImageLanguage: includeImageLanguage, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<KeywordsContainer> GetMovieKeywordsAsync(int movieId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
@ -172,7 +172,7 @@ namespace TMDbLib.Client
|
||||
return await GetMovieMethod<KeywordsContainer>(movieId, MovieMethods.Keywords, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<Movie> GetMovieLatestAsync( CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<Movie> GetMovieLatestAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
RestRequest req = _client.Create("movie/latest");
|
||||
RestResponse<Movie> resp = await req.ExecuteGet<Movie>(cancellationToken).ConfigureAwait(false);
|
||||
@ -208,7 +208,7 @@ namespace TMDbLib.Client
|
||||
|
||||
private async Task<T> GetMovieMethod<T>(int movieId, MovieMethods movieMethod, string dateFormat = null,
|
||||
string country = null,
|
||||
string language = null, int page = 0, DateTime? startDate = null, DateTime? endDate = null, CancellationToken cancellationToken = default(CancellationToken)) where T : new()
|
||||
string language = null, string includeImageLanguage = null, int page = 0, DateTime? startDate = null, DateTime? endDate = null, CancellationToken cancellationToken = default(CancellationToken)) where T : new()
|
||||
{
|
||||
RestRequest req = _client.Create("movie/{movieId}/{method}");
|
||||
req.AddUrlSegment("movieId", movieId.ToString(CultureInfo.InvariantCulture));
|
||||
@ -220,6 +220,9 @@ namespace TMDbLib.Client
|
||||
if (!string.IsNullOrWhiteSpace(language))
|
||||
req.AddParameter("language", language);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(includeImageLanguage))
|
||||
req.AddParameter("include_image_language", includeImageLanguage);
|
||||
|
||||
if (page >= 1)
|
||||
req.AddParameter("page", page.ToString());
|
||||
if (startDate.HasValue)
|
||||
@ -382,5 +385,4 @@ namespace TMDbLib.Client
|
||||
return item.StatusCode == 1 || item.StatusCode == 12;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -16,7 +16,7 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public async Task<TvShow> GetLatestTvShowAsync( CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<TvShow> GetLatestTvShowAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
RestRequest req = _client.Create("tv/latest");
|
||||
|
||||
@ -148,9 +148,9 @@ namespace TMDbLib.Client
|
||||
/// For images this means that the image might contain language specifc text
|
||||
/// </param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
public async Task<ImagesWithId> GetTvShowImagesAsync(int id, string language = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<ImagesWithId> GetTvShowImagesAsync(int id, string language = null, string includeImageLanguage = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return await GetTvShowMethod<ImagesWithId>(id, TvShowMethods.Images, language: language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetTvShowMethod<ImagesWithId>(id, TvShowMethods.Images, language: language, includeImageLanguage: includeImageLanguage, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<ResultContainer<Keyword>> GetTvShowKeywordsAsync(int id, CancellationToken cancellationToken = default(CancellationToken))
|
||||
@ -216,7 +216,7 @@ namespace TMDbLib.Client
|
||||
return resp;
|
||||
}
|
||||
|
||||
private async Task<T> GetTvShowMethod<T>(int id, TvShowMethods tvShowMethod, string dateFormat = null, string language = null, int page = 0, CancellationToken cancellationToken = default(CancellationToken)) where T : new()
|
||||
private async Task<T> GetTvShowMethod<T>(int id, TvShowMethods tvShowMethod, string dateFormat = null, string language = null, string includeImageLanguage = null, int page = 0, CancellationToken cancellationToken = default(CancellationToken)) where T : new()
|
||||
{
|
||||
RestRequest req = _client.Create("tv/{id}/{method}");
|
||||
req.AddUrlSegment("id", id.ToString(CultureInfo.InvariantCulture));
|
||||
@ -233,6 +233,9 @@ namespace TMDbLib.Client
|
||||
if (!string.IsNullOrWhiteSpace(language))
|
||||
req.AddParameter("language", language);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(includeImageLanguage))
|
||||
req.AddParameter("include_image_language", includeImageLanguage);
|
||||
|
||||
RestResponse<T> resp = await req.ExecuteGet<T>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
@ -337,6 +340,5 @@ namespace TMDbLib.Client
|
||||
// TODO: Original code had a check for item=null
|
||||
return item.StatusCode == 1 || item.StatusCode == 12;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -216,7 +216,6 @@ namespace TMDbLibTests
|
||||
Assert.Equal("Music", crew.Job);
|
||||
Assert.Equal("Marco Beltrami", crew.Name);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(crew.ProfilePath), "crew.ProfilePath was not a valid image path, was: " + crew.ProfilePath);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -261,6 +260,15 @@ namespace TMDbLibTests
|
||||
Assert.Equal(1000, poster.Width);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestMoviesGetMovieImagesWithImageLanguage()
|
||||
{
|
||||
ImagesWithId resp = Config.Client.GetMovieImagesAsync(IdHelper.AGoodDayToDieHard, language: "en-US", includeImageLanguage: "en").Result;
|
||||
|
||||
Assert.True(resp.Backdrops.Count > 0);
|
||||
Assert.True(resp.Posters.Count > 0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestMoviesGetMovieKeywords()
|
||||
{
|
||||
@ -836,4 +844,4 @@ namespace TMDbLibTests
|
||||
Assert.True(Math.Abs(movie.AccountStates.Rating.Value - 5) < double.Epsilon);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -218,6 +218,15 @@ namespace TMDbLibTests
|
||||
Assert.NotNull(images.Posters);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowGetImagesWithImageLanguage()
|
||||
{
|
||||
ImagesWithId resp = Config.Client.GetTvShowImagesAsync(IdHelper.BreakingBad, language: "en-US", includeImageLanguage: "en").Result;
|
||||
|
||||
Assert.True(resp.Backdrops.Count > 0);
|
||||
Assert.True(resp.Posters.Count > 0);
|
||||
}
|
||||
|
||||
private void TestBreakingBadBaseProperties(TvShow tvShow)
|
||||
{
|
||||
Assert.NotNull(tvShow);
|
||||
@ -367,7 +376,6 @@ namespace TMDbLibTests
|
||||
Assert.True(item.OriginCountry.Contains("US"));
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowRecommendations()
|
||||
{
|
||||
@ -397,7 +405,6 @@ namespace TMDbLibTests
|
||||
Assert.True(item.OriginCountry.Contains("US"));
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowTopRated()
|
||||
{
|
||||
@ -406,10 +413,10 @@ namespace TMDbLibTests
|
||||
|
||||
// This test might fail with inconsistent information from the pages due to a caching problem in the API.
|
||||
// Comment from the Developer of the API
|
||||
// That would be caused from different pages getting cached at different times.
|
||||
// Since top rated only pulls TV shows with 2 or more votes right now this will be something that happens until we have a lot more ratings.
|
||||
// It's the single biggest missing data right now and there's no way around it until we get more people using the TV data.
|
||||
// And as we get more ratings I increase that limit so we get more accurate results.
|
||||
// That would be caused from different pages getting cached at different times.
|
||||
// Since top rated only pulls TV shows with 2 or more votes right now this will be something that happens until we have a lot more ratings.
|
||||
// It's the single biggest missing data right now and there's no way around it until we get more people using the TV data.
|
||||
// And as we get more ratings I increase that limit so we get more accurate results.
|
||||
TestHelpers.SearchPages(i => Config.Client.GetTvShowTopRatedAsync(i).Result);
|
||||
|
||||
SearchContainer<SearchTv> result = Config.Client.GetTvShowTopRatedAsync().Sync();
|
||||
@ -633,4 +640,4 @@ namespace TMDbLibTests
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user