mirror of
https://github.com/jellyfin/TMDbLib.git
synced 2024-11-23 05:40:12 +00:00
Merge pull request #347 from LordMike/feature/updates
Large refactoring
This commit is contained in:
commit
a04a3f4116
4
.editorconfig
Normal file
4
.editorconfig
Normal file
@ -0,0 +1,4 @@
|
||||
[*.cs]
|
||||
|
||||
# CS4014: Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
dotnet_diagnostic.CS4014.severity = error
|
9
.gitignore
vendored
9
.gitignore
vendored
@ -3,3 +3,12 @@ bin/
|
||||
obj/
|
||||
*.user
|
||||
Build/
|
||||
*.DotSettings
|
||||
|
||||
# Project specific
|
||||
TestApplication/config.json
|
||||
*.lock.json
|
||||
|
||||
# Verify
|
||||
# https://github.com/VerifyTests/Verify#received-and-verified
|
||||
*.received.*
|
@ -11,6 +11,7 @@ EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{26BF5A0A-354A-46F5-A20C-0BEB5D45783A}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
Directory.Build.props = Directory.Build.props
|
||||
.editorconfig = .editorconfig
|
||||
Readme.md = Readme.md
|
||||
EndProjectSection
|
||||
EndProject
|
||||
|
@ -11,6 +11,7 @@ using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using TMDbLib.Rest;
|
||||
|
||||
namespace TMDbLib.Client
|
||||
{
|
||||
@ -157,7 +158,7 @@ namespace TMDbLib.Client
|
||||
|
||||
public async Task<TMDbConfig> GetConfigAsync()
|
||||
{
|
||||
TMDbConfig config = await _client.Create("configuration").ExecuteGet<TMDbConfig>(CancellationToken.None);
|
||||
TMDbConfig config = await _client.Create("configuration").GetOfT<TMDbConfig>(CancellationToken.None);
|
||||
|
||||
if (config == null)
|
||||
throw new Exception("Unable to retrieve configuration");
|
||||
@ -243,7 +244,7 @@ namespace TMDbLib.Client
|
||||
/// - Use the 'AuthenticationGetUserSessionAsync' and 'AuthenticationCreateGuestSessionAsync' methods to optain the respective session ids.
|
||||
/// - User sessions have access to far for methods than guest sessions, these can currently only be used to rate media.
|
||||
/// </remarks>
|
||||
public void SetSessionInformation(string sessionId, SessionType sessionType)
|
||||
public async Task SetSessionInformationAsync(string sessionId, SessionType sessionType)
|
||||
{
|
||||
ActiveAccount = null;
|
||||
SessionId = sessionId;
|
||||
@ -259,7 +260,7 @@ namespace TMDbLib.Client
|
||||
{
|
||||
try
|
||||
{
|
||||
ActiveAccount = AccountGetDetailsAsync().Result;
|
||||
ActiveAccount = await AccountGetDetailsAsync().ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
@ -13,204 +13,7 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Change the favorite status of a specific movie. Either make the movie a favorite or remove that status depending on the supplied boolean value.
|
||||
/// </summary>
|
||||
/// <param name="mediaType">The type of media to influence</param>
|
||||
/// <param name="mediaId">The id of the movie/tv show to influence</param>
|
||||
/// <param name="isFavorite">True if you want the specified movie to be marked as favorite, false if not</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>True if the the movie's favorite status was successfully updated, false if not</returns>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<bool> AccountChangeFavoriteStatusAsync(MediaType mediaType, int mediaId, bool isFavorite, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
RestRequest request = _client.Create("account/{accountId}/favorite");
|
||||
request.AddUrlSegment("accountId", ActiveAccount.Id.ToString(CultureInfo.InvariantCulture));
|
||||
request.SetBody(new { media_type = mediaType.GetDescription(), media_id = mediaId, favorite = isFavorite });
|
||||
AddSessionId(request, SessionType.UserSession);
|
||||
|
||||
PostReply response = await request.ExecutePost<PostReply>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// status code 1 = "Success" - Returned when adding a movie as favorite for the first time
|
||||
// status code 13 = "The item/record was deleted successfully" - When removing an item as favorite, no matter if it exists or not
|
||||
// status code 12 = "The item/record was updated successfully" - Used when an item is already marked as favorite and trying to do so doing again
|
||||
return response.StatusCode == 1 || response.StatusCode == 12 || response.StatusCode == 13;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the state of a specific movie on the users watchlist. Either add the movie to the list or remove it, depending on the specified boolean value.
|
||||
/// </summary>
|
||||
/// <param name="mediaType">The type of media to influence</param>
|
||||
/// <param name="mediaId">The id of the movie/tv show to influence</param>
|
||||
/// <param name="isOnWatchlist">True if you want the specified movie to be part of the watchlist, false if not</param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
/// <returns>True if the the movie's status on the watchlist was successfully updated, false if not</returns>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<bool> AccountChangeWatchlistStatusAsync(MediaType mediaType, int mediaId, bool isOnWatchlist, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
RestRequest request = _client.Create("account/{accountId}/watchlist");
|
||||
request.AddUrlSegment("accountId", ActiveAccount.Id.ToString(CultureInfo.InvariantCulture));
|
||||
request.SetBody(new { media_type = mediaType.GetDescription(), media_id = mediaId, watchlist = isOnWatchlist });
|
||||
AddSessionId(request, SessionType.UserSession);
|
||||
|
||||
PostReply response = await request.ExecutePost<PostReply>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// status code 1 = "Success"
|
||||
// status code 13 = "The item/record was deleted successfully" - When removing an item from the watchlist, no matter if it exists or not
|
||||
// status code 12 = "The item/record was updated successfully" - Used when an item is already on the watchlist and trying to add it again
|
||||
return response.StatusCode == 1 || response.StatusCode == 12 || response.StatusCode == 13;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Will retrieve the details of the account associated with the current session id
|
||||
/// </summary>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<AccountDetails> AccountGetDetailsAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
RestRequest request = _client.Create("account");
|
||||
AddSessionId(request, SessionType.UserSession);
|
||||
|
||||
AccountDetails response = await request.ExecuteGet<AccountDetails>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of all the movies marked as favorite by the current user
|
||||
/// </summary>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<SearchContainer<SearchMovie>> AccountGetFavoriteMoviesAsync(
|
||||
int page = 1,
|
||||
AccountSortBy sortBy = AccountSortBy.Undefined,
|
||||
SortOrder sortOrder = SortOrder.Undefined,
|
||||
string language = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return await GetAccountList<SearchMovie>(page, sortBy, sortOrder, language, AccountListsMethods.FavoriteMovies, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of all the tv shows marked as favorite by the current user
|
||||
/// </summary>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<SearchContainer<SearchTv>> AccountGetFavoriteTvAsync(
|
||||
int page = 1,
|
||||
AccountSortBy sortBy = AccountSortBy.Undefined,
|
||||
SortOrder sortOrder = SortOrder.Undefined,
|
||||
string language = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return await GetAccountList<SearchTv>(page, sortBy, sortOrder, language, AccountListsMethods.FavoriteTv, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve all lists associated with the provided account id
|
||||
/// This can be lists that were created by the user or lists marked as favorite
|
||||
/// </summary>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<SearchContainer<AccountList>> AccountGetListsAsync(int page = 1, string language = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
RestRequest request = _client.Create("account/{accountId}/lists");
|
||||
request.AddUrlSegment("accountId", ActiveAccount.Id.ToString(CultureInfo.InvariantCulture));
|
||||
AddSessionId(request, SessionType.UserSession);
|
||||
|
||||
if (page > 1)
|
||||
{
|
||||
request.AddQueryString("page", page.ToString());
|
||||
}
|
||||
|
||||
language = language ?? DefaultLanguage;
|
||||
if (!string.IsNullOrWhiteSpace(language))
|
||||
request.AddQueryString("language", language);
|
||||
|
||||
SearchContainer<AccountList> response = await request.ExecuteGet<SearchContainer<AccountList>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of all the movies on the current users match list
|
||||
/// </summary>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<SearchContainer<SearchMovie>> AccountGetMovieWatchlistAsync(
|
||||
int page = 1,
|
||||
AccountSortBy sortBy = AccountSortBy.Undefined,
|
||||
SortOrder sortOrder = SortOrder.Undefined,
|
||||
string language = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return await GetAccountList<SearchMovie>(page, sortBy, sortOrder, language, AccountListsMethods.MovieWatchlist, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of all the movies rated by the current user
|
||||
/// </summary>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<SearchContainer<SearchMovieWithRating>> AccountGetRatedMoviesAsync(
|
||||
int page = 1,
|
||||
AccountSortBy sortBy = AccountSortBy.Undefined,
|
||||
SortOrder sortOrder = SortOrder.Undefined,
|
||||
string language = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return await GetAccountList<SearchMovieWithRating>(page, sortBy, sortOrder, language, AccountListsMethods.RatedMovies, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of all the tv show episodes rated by the current user
|
||||
/// </summary>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<SearchContainer<AccountSearchTvEpisode>> AccountGetRatedTvShowEpisodesAsync(
|
||||
int page = 1,
|
||||
AccountSortBy sortBy = AccountSortBy.Undefined,
|
||||
SortOrder sortOrder = SortOrder.Undefined,
|
||||
string language = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return await GetAccountList<AccountSearchTvEpisode>(page, sortBy, sortOrder, language, AccountListsMethods.RatedTvEpisodes, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of all the tv shows rated by the current user
|
||||
/// </summary>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<SearchContainer<AccountSearchTv>> AccountGetRatedTvShowsAsync(
|
||||
int page = 1,
|
||||
AccountSortBy sortBy = AccountSortBy.Undefined,
|
||||
SortOrder sortOrder = SortOrder.Undefined,
|
||||
string language = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return await GetAccountList<AccountSearchTv>(page, sortBy, sortOrder, language, AccountListsMethods.RatedTv, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of all the tv shows on the current users match list
|
||||
/// </summary>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<SearchContainer<SearchTv>> AccountGetTvWatchlistAsync(
|
||||
int page = 1,
|
||||
AccountSortBy sortBy = AccountSortBy.Undefined,
|
||||
SortOrder sortOrder = SortOrder.Undefined,
|
||||
string language = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return await GetAccountList<SearchTv>(page, sortBy, sortOrder, language, AccountListsMethods.TvWatchlist, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task<SearchContainer<T>> GetAccountList<T>(int page, AccountSortBy sortBy, SortOrder sortOrder, string language, AccountListsMethods method, CancellationToken cancellationToken = default(CancellationToken))
|
||||
private async Task<SearchContainer<T>> GetAccountListInternal<T>(int page, AccountSortBy sortBy, SortOrder sortOrder, string language, AccountListsMethods method, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
@ -231,11 +34,208 @@ namespace TMDbLib.Client
|
||||
if (!string.IsNullOrWhiteSpace(language))
|
||||
request.AddParameter("language", language);
|
||||
|
||||
SearchContainer<T> response = await request.ExecuteGet<SearchContainer<T>>(cancellationToken).ConfigureAwait(false);
|
||||
SearchContainer<T> response = await request.GetOfT<SearchContainer<T>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the favorite status of a specific movie. Either make the movie a favorite or remove that status depending on the supplied boolean value.
|
||||
/// </summary>
|
||||
/// <param name="mediaType">The type of media to influence</param>
|
||||
/// <param name="mediaId">The id of the movie/tv show to influence</param>
|
||||
/// <param name="isFavorite">True if you want the specified movie to be marked as favorite, false if not</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>True if the the movie's favorite status was successfully updated, false if not</returns>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<bool> AccountChangeFavoriteStatusAsync(MediaType mediaType, int mediaId, bool isFavorite, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
RestRequest request = _client.Create("account/{accountId}/favorite");
|
||||
request.AddUrlSegment("accountId", ActiveAccount.Id.ToString(CultureInfo.InvariantCulture));
|
||||
request.SetBody(new { media_type = mediaType.GetDescription(), media_id = mediaId, favorite = isFavorite });
|
||||
AddSessionId(request, SessionType.UserSession);
|
||||
|
||||
PostReply response = await request.PostOfT<PostReply>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// status code 1 = "Success" - Returned when adding a movie as favorite for the first time
|
||||
// status code 13 = "The item/record was deleted successfully" - When removing an item as favorite, no matter if it exists or not
|
||||
// status code 12 = "The item/record was updated successfully" - Used when an item is already marked as favorite and trying to do so doing again
|
||||
return response.StatusCode == 1 || response.StatusCode == 12 || response.StatusCode == 13;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the state of a specific movie on the users watchlist. Either add the movie to the list or remove it, depending on the specified boolean value.
|
||||
/// </summary>
|
||||
/// <param name="mediaType">The type of media to influence</param>
|
||||
/// <param name="mediaId">The id of the movie/tv show to influence</param>
|
||||
/// <param name="isOnWatchlist">True if you want the specified movie to be part of the watchlist, false if not</param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
/// <returns>True if the the movie's status on the watchlist was successfully updated, false if not</returns>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<bool> AccountChangeWatchlistStatusAsync(MediaType mediaType, int mediaId, bool isOnWatchlist, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
RestRequest request = _client.Create("account/{accountId}/watchlist");
|
||||
request.AddUrlSegment("accountId", ActiveAccount.Id.ToString(CultureInfo.InvariantCulture));
|
||||
request.SetBody(new { media_type = mediaType.GetDescription(), media_id = mediaId, watchlist = isOnWatchlist });
|
||||
AddSessionId(request, SessionType.UserSession);
|
||||
|
||||
PostReply response = await request.PostOfT<PostReply>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// status code 1 = "Success"
|
||||
// status code 13 = "The item/record was deleted successfully" - When removing an item from the watchlist, no matter if it exists or not
|
||||
// status code 12 = "The item/record was updated successfully" - Used when an item is already on the watchlist and trying to add it again
|
||||
return response.StatusCode == 1 || response.StatusCode == 12 || response.StatusCode == 13;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Will retrieve the details of the account associated with the current session id
|
||||
/// </summary>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<AccountDetails> AccountGetDetailsAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
RestRequest request = _client.Create("account");
|
||||
AddSessionId(request, SessionType.UserSession);
|
||||
|
||||
AccountDetails response = await request.GetOfT<AccountDetails>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of all the movies marked as favorite by the current user
|
||||
/// </summary>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<SearchContainer<SearchMovie>> AccountGetFavoriteMoviesAsync(
|
||||
int page = 1,
|
||||
AccountSortBy sortBy = AccountSortBy.Undefined,
|
||||
SortOrder sortOrder = SortOrder.Undefined,
|
||||
string language = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetAccountListInternal<SearchMovie>(page, sortBy, sortOrder, language, AccountListsMethods.FavoriteMovies, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of all the tv shows marked as favorite by the current user
|
||||
/// </summary>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<SearchContainer<SearchTv>> AccountGetFavoriteTvAsync(
|
||||
int page = 1,
|
||||
AccountSortBy sortBy = AccountSortBy.Undefined,
|
||||
SortOrder sortOrder = SortOrder.Undefined,
|
||||
string language = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetAccountListInternal<SearchTv>(page, sortBy, sortOrder, language, AccountListsMethods.FavoriteTv, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve all lists associated with the provided account id
|
||||
/// This can be lists that were created by the user or lists marked as favorite
|
||||
/// </summary>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<SearchContainer<AccountList>> AccountGetListsAsync(int page = 1, string language = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
RestRequest request = _client.Create("account/{accountId}/lists");
|
||||
request.AddUrlSegment("accountId", ActiveAccount.Id.ToString(CultureInfo.InvariantCulture));
|
||||
AddSessionId(request, SessionType.UserSession);
|
||||
|
||||
if (page > 1)
|
||||
{
|
||||
request.AddQueryString("page", page.ToString());
|
||||
}
|
||||
|
||||
language = language ?? DefaultLanguage;
|
||||
if (!string.IsNullOrWhiteSpace(language))
|
||||
request.AddQueryString("language", language);
|
||||
|
||||
SearchContainer<AccountList> response = await request.GetOfT<SearchContainer<AccountList>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of all the movies on the current users match list
|
||||
/// </summary>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<SearchContainer<SearchMovie>> AccountGetMovieWatchlistAsync(
|
||||
int page = 1,
|
||||
AccountSortBy sortBy = AccountSortBy.Undefined,
|
||||
SortOrder sortOrder = SortOrder.Undefined,
|
||||
string language = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetAccountListInternal<SearchMovie>(page, sortBy, sortOrder, language, AccountListsMethods.MovieWatchlist, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of all the movies rated by the current user
|
||||
/// </summary>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<SearchContainer<SearchMovieWithRating>> AccountGetRatedMoviesAsync(
|
||||
int page = 1,
|
||||
AccountSortBy sortBy = AccountSortBy.Undefined,
|
||||
SortOrder sortOrder = SortOrder.Undefined,
|
||||
string language = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetAccountListInternal<SearchMovieWithRating>(page, sortBy, sortOrder, language, AccountListsMethods.RatedMovies, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of all the tv show episodes rated by the current user
|
||||
/// </summary>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<SearchContainer<AccountSearchTvEpisode>> AccountGetRatedTvShowEpisodesAsync(
|
||||
int page = 1,
|
||||
AccountSortBy sortBy = AccountSortBy.Undefined,
|
||||
SortOrder sortOrder = SortOrder.Undefined,
|
||||
string language = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetAccountListInternal<AccountSearchTvEpisode>(page, sortBy, sortOrder, language, AccountListsMethods.RatedTvEpisodes, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of all the tv shows rated by the current user
|
||||
/// </summary>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<SearchContainer<AccountSearchTv>> AccountGetRatedTvShowsAsync(
|
||||
int page = 1,
|
||||
AccountSortBy sortBy = AccountSortBy.Undefined,
|
||||
SortOrder sortOrder = SortOrder.Undefined,
|
||||
string language = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetAccountListInternal<AccountSearchTv>(page, sortBy, sortOrder, language, AccountListsMethods.RatedTv, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of all the tv shows on the current users match list
|
||||
/// </summary>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<SearchContainer<SearchTv>> AccountGetTvWatchlistAsync(
|
||||
int page = 1,
|
||||
AccountSortBy sortBy = AccountSortBy.Undefined,
|
||||
SortOrder sortOrder = SortOrder.Undefined,
|
||||
string language = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetAccountListInternal<SearchTv>(page, sortBy, sortOrder, language, AccountListsMethods.TvWatchlist, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private enum AccountListsMethods
|
||||
{
|
||||
[EnumValue("favorite/movies")]
|
||||
|
@ -9,29 +9,29 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public async Task<GuestSession> AuthenticationCreateGuestSessionAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<GuestSession> AuthenticationCreateGuestSessionAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest request = _client.Create("authentication/guest_session/new");
|
||||
//{
|
||||
// DateFormat = "yyyy-MM-dd HH:mm:ss UTC"
|
||||
//};
|
||||
|
||||
RestResponse<GuestSession> response = await request.ExecuteGet<GuestSession>(cancellationToken).ConfigureAwait(false);
|
||||
GuestSession response = await request.GetOfT<GuestSession>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public async Task<UserSession> AuthenticationGetUserSessionAsync(string initialRequestToken, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<UserSession> AuthenticationGetUserSessionAsync(string initialRequestToken, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest request = _client.Create("authentication/session/new");
|
||||
request.AddParameter("request_token", initialRequestToken);
|
||||
|
||||
RestResponse<UserSession> response = await request.ExecuteGet<UserSession>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<UserSession> response = await request.Get<UserSession>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (response.StatusCode == HttpStatusCode.Unauthorized)
|
||||
throw new UnauthorizedAccessException();
|
||||
|
||||
return response;
|
||||
return await response.GetDataObject().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -40,26 +40,26 @@ namespace TMDbLib.Client
|
||||
/// <param name="username">A valid TMDb username</param>
|
||||
/// <param name="password">The passoword for the provided login</param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
public async Task<UserSession> AuthenticationGetUserSessionAsync(string username, string password, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<UserSession> AuthenticationGetUserSessionAsync(string username, string password, CancellationToken cancellationToken = default)
|
||||
{
|
||||
Token token = await AuthenticationRequestAutenticationTokenAsync(cancellationToken).ConfigureAwait(false);
|
||||
await AuthenticationValidateUserTokenAsync(token.RequestToken, username, password, cancellationToken).ConfigureAwait(false);
|
||||
return await AuthenticationGetUserSessionAsync(token.RequestToken, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<Token> AuthenticationRequestAutenticationTokenAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<Token> AuthenticationRequestAutenticationTokenAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest request = _client.Create("authentication/token/new");
|
||||
|
||||
RestResponse<Token> response = await request.ExecuteGet<Token>(cancellationToken).ConfigureAwait(false);
|
||||
Token token = response;
|
||||
RestResponse<Token> response = await request.Get<Token>(cancellationToken).ConfigureAwait(false);
|
||||
Token token = await response.GetDataObject().ConfigureAwait(false);
|
||||
|
||||
token.AuthenticationCallback = response.GetHeader("Authentication-Callback");
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
public async Task AuthenticationValidateUserTokenAsync(string initialRequestToken, string username, string password, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task AuthenticationValidateUserTokenAsync(string initialRequestToken, string username, string password, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest request = _client.Create("authentication/token/validate_with_login");
|
||||
request.AddParameter("request_token", initialRequestToken);
|
||||
@ -69,7 +69,7 @@ namespace TMDbLib.Client
|
||||
RestResponse response;
|
||||
try
|
||||
{
|
||||
response = await request.ExecuteGet(cancellationToken).ConfigureAwait(false);
|
||||
response = await request.Get(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch (AggregateException ex)
|
||||
{
|
||||
|
@ -7,20 +7,20 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public async Task<CertificationsContainer> GetMovieCertificationsAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<CertificationsContainer> GetMovieCertificationsAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("certification/movie/list");
|
||||
|
||||
RestResponse<CertificationsContainer> resp = await req.ExecuteGet<CertificationsContainer>(cancellationToken).ConfigureAwait(false);
|
||||
CertificationsContainer resp = await req.GetOfT<CertificationsContainer>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
public async Task<CertificationsContainer> GetTvCertificationsAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<CertificationsContainer> GetTvCertificationsAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("certification/tv/list");
|
||||
|
||||
RestResponse<CertificationsContainer> resp = await req.ExecuteGet<CertificationsContainer>(cancellationToken).ConfigureAwait(false);
|
||||
CertificationsContainer resp = await req.GetOfT<CertificationsContainer>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using TMDbLib.Objects.Changes;
|
||||
@ -9,11 +10,20 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
private async Task<SearchContainer<ChangesListItem>> GetChanges(string type, int page = 0, DateTime? startDate = null, DateTime? endDate = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
private async Task<T> GetChangesInternal<T>(string type, int page = 0, int? id = null, DateTime? startDate = null, DateTime? endDate = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("{type}/changes");
|
||||
string resource;
|
||||
if (id.HasValue)
|
||||
resource = "{type}/{id}/changes";
|
||||
else
|
||||
resource = "{type}/changes";
|
||||
|
||||
RestRequest req = _client.Create(resource);
|
||||
req.AddUrlSegment("type", type);
|
||||
|
||||
if (id.HasValue)
|
||||
req.AddUrlSegment("id", id.Value.ToString());
|
||||
|
||||
if (page >= 1)
|
||||
req.AddParameter("page", page.ToString());
|
||||
if (startDate.HasValue)
|
||||
@ -21,11 +31,14 @@ namespace TMDbLib.Client
|
||||
if (endDate != null)
|
||||
req.AddParameter("end_date", endDate.Value.ToString("yyyy-MM-dd"));
|
||||
|
||||
RestResponse<SearchContainer<ChangesListItem>> resp = await req.ExecuteGet<SearchContainer<ChangesListItem>>(cancellationToken).ConfigureAwait(false);
|
||||
SearchContainer<ChangesListItem> res = await resp.GetDataObject().ConfigureAwait(false);
|
||||
RestResponse<T> resp = await req.Get<T>(cancellationToken).ConfigureAwait(false);
|
||||
T res = await resp.GetDataObject().ConfigureAwait(false);
|
||||
|
||||
if (res is SearchContainer<ChangesListItem> asSearch)
|
||||
{
|
||||
// https://github.com/LordMike/TMDbLib/issues/296
|
||||
res.Results.RemoveAll(s => s.Id == 0);
|
||||
asSearch.Results.RemoveAll(s => s.Id == 0);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
@ -37,9 +50,9 @@ namespace TMDbLib.Client
|
||||
/// You can then use the movie changes API to get the actual data that has been changed. (.GetMovieChangesAsync)
|
||||
/// </summary>
|
||||
/// <remarks>the change log system to support this was changed on October 5, 2012 and will only show movies that have been edited since.</remarks>
|
||||
public async Task<SearchContainer<ChangesListItem>> GetChangesMoviesAsync(int page = 0, DateTime? startDate = null, DateTime? endDate = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<ChangesListItem>> GetMoviesChangesAsync(int page = 0, DateTime? startDate = null, DateTime? endDate = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetChanges("movie", page, startDate, endDate, cancellationToken).ConfigureAwait(false);
|
||||
return await GetChangesInternal<SearchContainer<ChangesListItem>>("movie", page, startDate: startDate, endDate: endDate, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -49,9 +62,9 @@ namespace TMDbLib.Client
|
||||
/// You can then use the person changes API to get the actual data that has been changed.(.GetPersonChangesAsync)
|
||||
/// </summary>
|
||||
/// <remarks>the change log system to support this was changed on October 5, 2012 and will only show people that have been edited since.</remarks>
|
||||
public async Task<SearchContainer<ChangesListItem>> GetChangesPeopleAsync(int page = 0, DateTime? startDate = null, DateTime? endDate = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<ChangesListItem>> GetPeopleChangesAsync(int page = 0, DateTime? startDate = null, DateTime? endDate = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetChanges("person", page, startDate, endDate, cancellationToken).ConfigureAwait(false);
|
||||
return await GetChangesInternal<SearchContainer<ChangesListItem>>("person", page, startDate: startDate, endDate: endDate, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -64,9 +77,33 @@ namespace TMDbLib.Client
|
||||
/// the change log system to properly support TV was updated on May 13, 2014.
|
||||
/// You'll likely only find the edits made since then to be useful in the change log system.
|
||||
/// </remarks>
|
||||
public async Task<SearchContainer<ChangesListItem>> GetChangesTvAsync(int page = 0, DateTime? startDate = null, DateTime? endDate = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<ChangesListItem>> GetTvChangesAsync(int page = 0, DateTime? startDate = null, DateTime? endDate = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetChanges("tv", page, startDate, endDate, cancellationToken).ConfigureAwait(false);
|
||||
return await GetChangesInternal<SearchContainer<ChangesListItem>>("tv", page, startDate: startDate, endDate: endDate, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<IList<Change>> GetMovieChangesAsync(int movieId, int page = 0, DateTime? startDate = null, DateTime? endDate = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
ChangesContainer changesContainer = await GetChangesInternal<ChangesContainer>("movie", page, movieId, startDate, endDate, cancellationToken);
|
||||
return changesContainer.Changes;
|
||||
}
|
||||
|
||||
public async Task<IList<Change>> GetPersonChangesAsync(int personId, int page = 0, DateTime? startDate = null, DateTime? endDate = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
ChangesContainer changesContainer = await GetChangesInternal<ChangesContainer>("person", page, personId, startDate, endDate, cancellationToken).ConfigureAwait(false);
|
||||
return changesContainer.Changes;
|
||||
}
|
||||
|
||||
public async Task<IList<Change>> GetTvSeasonChangesAsync(int seasonId, int page = 0, DateTime? startDate = null, DateTime? endDate = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
ChangesContainer changesContainer = await GetChangesInternal<ChangesContainer>("tv/season", page, seasonId, startDate, endDate, cancellationToken).ConfigureAwait(false);
|
||||
return changesContainer.Changes;
|
||||
}
|
||||
|
||||
public async Task<IList<Change>> GetTvEpisodeChangesAsync(int episodeId, int page = 0, DateTime? startDate = null, DateTime? endDate = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
ChangesContainer changesContainer = await GetChangesInternal<ChangesContainer>("tv/episode", page, episodeId, startDate, endDate, cancellationToken).ConfigureAwait(false);
|
||||
return changesContainer.Changes;
|
||||
}
|
||||
}
|
||||
}
|
@ -12,12 +12,26 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public async Task<Collection> GetCollectionAsync(int collectionId, CollectionMethods extraMethods = CollectionMethods.Undefined, CancellationToken cancellationToken = default(CancellationToken))
|
||||
private async Task<T> GetCollectionMethodInternal<T>(int collectionId, CollectionMethods collectionMethod, string language = null, CancellationToken cancellationToken = default) where T : new()
|
||||
{
|
||||
RestRequest req = _client.Create("collection/{collectionId}/{method}");
|
||||
req.AddUrlSegment("collectionId", collectionId.ToString());
|
||||
req.AddUrlSegment("method", collectionMethod.GetDescription());
|
||||
|
||||
if (language != null)
|
||||
req.AddParameter("language", language);
|
||||
|
||||
T resp = await req.GetOfT<T>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
public async Task<Collection> GetCollectionAsync(int collectionId, CollectionMethods extraMethods = CollectionMethods.Undefined, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetCollectionAsync(collectionId, DefaultLanguage, null, extraMethods, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<Collection> GetCollectionAsync(int collectionId, string language, string includeImageLanguages, CollectionMethods extraMethods = CollectionMethods.Undefined, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<Collection> GetCollectionAsync(int collectionId, string language, string includeImageLanguages, CollectionMethods extraMethods = CollectionMethods.Undefined, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("collection/{collectionId}");
|
||||
req.AddUrlSegment("collectionId", collectionId.ToString());
|
||||
@ -42,7 +56,7 @@ namespace TMDbLib.Client
|
||||
|
||||
//req.DateFormat = "yyyy-MM-dd";
|
||||
|
||||
RestResponse<Collection> response = await req.ExecuteGet<Collection>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<Collection> response = await req.Get<Collection>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (!response.IsValid)
|
||||
return null;
|
||||
@ -55,23 +69,9 @@ namespace TMDbLib.Client
|
||||
return item;
|
||||
}
|
||||
|
||||
public async Task<ImagesWithId> GetCollectionImagesAsync(int collectionId, string language = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<ImagesWithId> GetCollectionImagesAsync(int collectionId, string language = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetCollectionMethod<ImagesWithId>(collectionId, CollectionMethods.Images, language, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task<T> GetCollectionMethod<T>(int collectionId, CollectionMethods collectionMethod, string language = null, CancellationToken cancellationToken = default(CancellationToken)) where T : new()
|
||||
{
|
||||
RestRequest req = _client.Create("collection/{collectionId}/{method}");
|
||||
req.AddUrlSegment("collectionId", collectionId.ToString());
|
||||
req.AddUrlSegment("method", collectionMethod.GetDescription());
|
||||
|
||||
if (language != null)
|
||||
req.AddParameter("language", language);
|
||||
|
||||
RestResponse<T> resp = await req.ExecuteGet<T>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
return await GetCollectionMethodInternal<ImagesWithId>(collectionId, CollectionMethods.Images, language, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -12,7 +12,24 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public async Task<Company> GetCompanyAsync(int companyId, CompanyMethods extraMethods = CompanyMethods.Undefined, CancellationToken cancellationToken = default(CancellationToken))
|
||||
private async Task<T> GetCompanyMethodInternal<T>(int companyId, CompanyMethods companyMethod, int page = 0, string language = null, CancellationToken cancellationToken = default) where T : new()
|
||||
{
|
||||
RestRequest req = _client.Create("company/{companyId}/{method}");
|
||||
req.AddUrlSegment("companyId", companyId.ToString());
|
||||
req.AddUrlSegment("method", companyMethod.GetDescription());
|
||||
|
||||
if (page >= 1)
|
||||
req.AddParameter("page", page.ToString());
|
||||
language = language ?? DefaultLanguage;
|
||||
if (!string.IsNullOrWhiteSpace(language))
|
||||
req.AddParameter("language", language);
|
||||
|
||||
T resp = await req.GetOfT<T>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
public async Task<Company> GetCompanyAsync(int companyId, CompanyMethods extraMethods = CompanyMethods.Undefined, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("company/{companyId}");
|
||||
req.AddUrlSegment("companyId", companyId.ToString());
|
||||
@ -29,36 +46,19 @@ namespace TMDbLib.Client
|
||||
|
||||
//req.DateFormat = "yyyy-MM-dd";
|
||||
|
||||
RestResponse<Company> resp = await req.ExecuteGet<Company>(cancellationToken).ConfigureAwait(false);
|
||||
Company resp = await req.GetOfT<Company>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
private async Task<T> GetCompanyMethod<T>(int companyId, CompanyMethods companyMethod, int page = 0, string language = null, CancellationToken cancellationToken = default(CancellationToken)) where T : new()
|
||||
{
|
||||
RestRequest req = _client.Create("company/{companyId}/{method}");
|
||||
req.AddUrlSegment("companyId", companyId.ToString());
|
||||
req.AddUrlSegment("method", companyMethod.GetDescription());
|
||||
|
||||
if (page >= 1)
|
||||
req.AddParameter("page", page.ToString());
|
||||
language = language ?? DefaultLanguage;
|
||||
if (!string.IsNullOrWhiteSpace(language))
|
||||
req.AddParameter("language", language);
|
||||
|
||||
RestResponse<T> resp = await req.ExecuteGet<T>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
public async Task<SearchContainerWithId<SearchMovie>> GetCompanyMoviesAsync(int companyId, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainerWithId<SearchMovie>> GetCompanyMoviesAsync(int companyId, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetCompanyMoviesAsync(companyId, DefaultLanguage, page, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainerWithId<SearchMovie>> GetCompanyMoviesAsync(int companyId, string language, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainerWithId<SearchMovie>> GetCompanyMoviesAsync(int companyId, string language, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetCompanyMethod<SearchContainerWithId<SearchMovie>>(companyId, CompanyMethods.Movies, page, language, cancellationToken).ConfigureAwait(false);
|
||||
return await GetCompanyMethodInternal<SearchContainerWithId<SearchMovie>>(companyId, CompanyMethods.Movies, page, language, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -13,47 +13,47 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public async Task<APIConfiguration> GetAPIConfiguration(CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<APIConfiguration> GetAPIConfiguration(CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("configuration");
|
||||
|
||||
RestResponse<APIConfiguration> response = await req.ExecuteGet<APIConfiguration>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<APIConfiguration> response = await req.Get<APIConfiguration>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return (await response.GetDataObject().ConfigureAwait(false));
|
||||
}
|
||||
|
||||
public async Task<List<Country>> GetCountriesAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<List<Country>> GetCountriesAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("configuration/countries");
|
||||
|
||||
RestResponse<List<Country>> response = await req.ExecuteGet<List<Country>>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<List<Country>> response = await req.Get<List<Country>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return (await response.GetDataObject().ConfigureAwait(false));
|
||||
}
|
||||
|
||||
public async Task<List<Language>> GetLanguagesAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<List<Language>> GetLanguagesAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("configuration/languages");
|
||||
|
||||
RestResponse<List<Language>> response = await req.ExecuteGet<List<Language>>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<List<Language>> response = await req.Get<List<Language>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return (await response.GetDataObject().ConfigureAwait(false));
|
||||
}
|
||||
|
||||
public async Task<List<string>> GetPrimaryTranslationsAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<List<string>> GetPrimaryTranslationsAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("configuration/primary_translations");
|
||||
|
||||
RestResponse<List<string>> response = await req.ExecuteGet<List<string>>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<List<string>> response = await req.Get<List<string>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return (await response.GetDataObject().ConfigureAwait(false));
|
||||
}
|
||||
|
||||
public async Task<Timezones> GetTimezonesAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<Timezones> GetTimezonesAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("timezones/list");
|
||||
|
||||
RestResponse<List<Dictionary<string, List<string>>>> resp = await req.ExecuteGet<List<Dictionary<string, List<string>>>>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<List<Dictionary<string, List<string>>>> resp = await req.Get<List<Dictionary<string, List<string>>>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
List<Dictionary<string, List<string>>> item = await resp.GetDataObject().ConfigureAwait(false);
|
||||
|
||||
@ -77,11 +77,11 @@ namespace TMDbLib.Client
|
||||
/// Retrieves a list of departments and positions within
|
||||
/// </summary>
|
||||
/// <returns>Valid jobs and their departments</returns>
|
||||
public async Task<List<Job>> GetJobsAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<List<Job>> GetJobsAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("configuration/jobs");
|
||||
|
||||
RestResponse<List<Job>> response = await req.ExecuteGet<List<Job>>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<List<Job>> response = await req.Get<List<Job>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return (await response.GetDataObject().ConfigureAwait(false));
|
||||
}
|
||||
|
@ -7,12 +7,12 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public async Task<Credit> GetCreditsAsync(string id, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<Credit> GetCreditsAsync(string id, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetCreditsAsync(id, DefaultLanguage, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<Credit> GetCreditsAsync(string id, string language, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<Credit> GetCreditsAsync(string id, string language, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("credit/{id}");
|
||||
|
||||
@ -21,7 +21,7 @@ namespace TMDbLib.Client
|
||||
|
||||
req.AddUrlSegment("id", id);
|
||||
|
||||
RestResponse<Credit> resp = await req.ExecuteGet<Credit>(cancellationToken).ConfigureAwait(false);
|
||||
Credit resp = await req.GetOfT<Credit>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace TMDbLib.Client
|
||||
return new DiscoverMovie(this);
|
||||
}
|
||||
|
||||
internal async Task<SearchContainer<T>> DiscoverPerformAsync<T>(string endpoint, string language, int page, SimpleNamedValueCollection parameters, CancellationToken cancellationToken = default(CancellationToken))
|
||||
internal async Task<SearchContainer<T>> DiscoverPerformAsync<T>(string endpoint, string language, int page, SimpleNamedValueCollection parameters, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest request = _client.Create(endpoint);
|
||||
|
||||
@ -31,7 +31,7 @@ namespace TMDbLib.Client
|
||||
foreach (KeyValuePair<string, string> pair in parameters)
|
||||
request.AddParameter(pair.Key, pair.Value);
|
||||
|
||||
RestResponse<SearchContainer<T>> response = await request.ExecuteGet<SearchContainer<T>>(cancellationToken).ConfigureAwait(false);
|
||||
SearchContainer<T> response = await request.GetOfT<SearchContainer<T>>(cancellationToken).ConfigureAwait(false);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ namespace TMDbLib.Client
|
||||
/// <param name="id">The id of the object you wish to located</param>
|
||||
/// <returns>A list of all objects in TMDb that matched your id</returns>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
public Task<FindContainer> FindAsync(FindExternalSource source, string id, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public Task<FindContainer> FindAsync(FindExternalSource source, string id, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return FindAsync(source, id, null, cancellationToken);
|
||||
}
|
||||
@ -37,7 +37,7 @@ namespace TMDbLib.Client
|
||||
/// <returns>A list of all objects in TMDb that matched your id</returns>
|
||||
/// <param name="language">If specified the api will attempt to return a localized result. ex: en,it,es.</param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
public async Task<FindContainer> FindAsync(FindExternalSource source, string id, string language, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<FindContainer> FindAsync(FindExternalSource source, string id, string language, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("find/{id}");
|
||||
|
||||
@ -49,7 +49,7 @@ namespace TMDbLib.Client
|
||||
if (!string.IsNullOrEmpty(language))
|
||||
req.AddParameter("language", language);
|
||||
|
||||
RestResponse<FindContainer> resp = await req.ExecuteGet<FindContainer>(cancellationToken).ConfigureAwait(false);
|
||||
FindContainer resp = await req.GetOfT<FindContainer>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
@ -12,13 +12,13 @@ namespace TMDbLib.Client
|
||||
public partial class TMDbClient
|
||||
{
|
||||
[Obsolete("GetGenreMovies is deprecated, use DiscoverMovies instead")]
|
||||
public async Task<SearchContainerWithId<SearchMovie>> GetGenreMoviesAsync(int genreId, int page = 0, bool? includeAllMovies = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainerWithId<SearchMovie>> GetGenreMoviesAsync(int genreId, int page = 0, bool? includeAllMovies = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetGenreMoviesAsync(genreId, DefaultLanguage, page, includeAllMovies, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[Obsolete("GetGenreMovies is deprecated, use DiscoverMovies instead")]
|
||||
public async Task<SearchContainerWithId<SearchMovie>> GetGenreMoviesAsync(int genreId, string language, int page = 0, bool? includeAllMovies = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainerWithId<SearchMovie>> GetGenreMoviesAsync(int genreId, string language, int page = 0, bool? includeAllMovies = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("genre/{genreId}/movies");
|
||||
req.AddUrlSegment("genreId", genreId.ToString());
|
||||
@ -32,17 +32,17 @@ namespace TMDbLib.Client
|
||||
if (includeAllMovies.HasValue)
|
||||
req.AddParameter("include_all_movies", includeAllMovies.Value ? "true" : "false");
|
||||
|
||||
RestResponse<SearchContainerWithId<SearchMovie>> resp = await req.ExecuteGet<SearchContainerWithId<SearchMovie>>(cancellationToken).ConfigureAwait(false);
|
||||
SearchContainerWithId<SearchMovie> resp = await req.GetOfT<SearchContainerWithId<SearchMovie>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
public async Task<List<Genre>> GetMovieGenresAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<List<Genre>> GetMovieGenresAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieGenresAsync(DefaultLanguage, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<List<Genre>> GetMovieGenresAsync(string language, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<List<Genre>> GetMovieGenresAsync(string language, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("genre/movie/list");
|
||||
|
||||
@ -50,17 +50,17 @@ namespace TMDbLib.Client
|
||||
if (!string.IsNullOrWhiteSpace(language))
|
||||
req.AddParameter("language", language);
|
||||
|
||||
RestResponse<GenreContainer> resp = await req.ExecuteGet<GenreContainer>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<GenreContainer> resp = await req.Get<GenreContainer>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return (await resp.GetDataObject().ConfigureAwait(false)).Genres;
|
||||
}
|
||||
|
||||
public async Task<List<Genre>> GetTvGenresAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<List<Genre>> GetTvGenresAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvGenresAsync(DefaultLanguage, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<List<Genre>> GetTvGenresAsync(string language, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<List<Genre>> GetTvGenresAsync(string language, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("genre/tv/list");
|
||||
|
||||
@ -68,7 +68,7 @@ namespace TMDbLib.Client
|
||||
if (!string.IsNullOrWhiteSpace(language))
|
||||
req.AddParameter("language", language);
|
||||
|
||||
RestResponse<GenreContainer> resp = await req.ExecuteGet<GenreContainer>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<GenreContainer> resp = await req.Get<GenreContainer>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return (await resp.GetDataObject().ConfigureAwait(false)).Genres;
|
||||
}
|
||||
|
@ -10,12 +10,12 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public async Task<SearchContainer<SearchMovieWithRating>> GetGuestSessionRatedMoviesAsync(int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchMovieWithRating>> GetGuestSessionRatedMoviesAsync(int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetGuestSessionRatedMoviesAsync(DefaultLanguage, page, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchMovieWithRating>> GetGuestSessionRatedMoviesAsync(string language, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchMovieWithRating>> GetGuestSessionRatedMoviesAsync(string language, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RequireSessionId(SessionType.GuestSession);
|
||||
|
||||
@ -29,17 +29,17 @@ namespace TMDbLib.Client
|
||||
|
||||
AddSessionId(request, SessionType.GuestSession, ParameterType.UrlSegment);
|
||||
|
||||
RestResponse<SearchContainer<SearchMovieWithRating>> resp = await request.ExecuteGet<SearchContainer<SearchMovieWithRating>>(cancellationToken).ConfigureAwait(false);
|
||||
SearchContainer<SearchMovieWithRating> resp = await request.GetOfT<SearchContainer<SearchMovieWithRating>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchTvShowWithRating>> GetGuestSessionRatedTvAsync(int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchTvShowWithRating>> GetGuestSessionRatedTvAsync(int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetGuestSessionRatedTvAsync(DefaultLanguage, page, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchTvShowWithRating>> GetGuestSessionRatedTvAsync(string language, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchTvShowWithRating>> GetGuestSessionRatedTvAsync(string language, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RequireSessionId(SessionType.GuestSession);
|
||||
|
||||
@ -53,17 +53,17 @@ namespace TMDbLib.Client
|
||||
|
||||
AddSessionId(request, SessionType.GuestSession, ParameterType.UrlSegment);
|
||||
|
||||
RestResponse<SearchContainer<SearchTvShowWithRating>> resp = await request.ExecuteGet<SearchContainer<SearchTvShowWithRating>>(cancellationToken).ConfigureAwait(false);
|
||||
SearchContainer<SearchTvShowWithRating> resp = await request.GetOfT<SearchContainer<SearchTvShowWithRating>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<TvEpisodeWithRating>> GetGuestSessionRatedTvEpisodesAsync(int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<TvEpisodeWithRating>> GetGuestSessionRatedTvEpisodesAsync(int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetGuestSessionRatedTvEpisodesAsync(DefaultLanguage, page, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<TvEpisodeWithRating>> GetGuestSessionRatedTvEpisodesAsync(string language, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<TvEpisodeWithRating>> GetGuestSessionRatedTvEpisodesAsync(string language, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RequireSessionId(SessionType.GuestSession);
|
||||
|
||||
@ -77,7 +77,7 @@ namespace TMDbLib.Client
|
||||
|
||||
AddSessionId(request, SessionType.GuestSession, ParameterType.UrlSegment);
|
||||
|
||||
RestResponse<SearchContainer<TvEpisodeWithRating>> resp = await request.ExecuteGet<SearchContainer<TvEpisodeWithRating>>(cancellationToken).ConfigureAwait(false);
|
||||
SearchContainer<TvEpisodeWithRating> resp = await request.GetOfT<SearchContainer<TvEpisodeWithRating>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
@ -8,22 +8,22 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public async Task<Keyword> GetKeywordAsync(int keywordId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<Keyword> GetKeywordAsync(int keywordId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("keyword/{keywordId}");
|
||||
req.AddUrlSegment("keywordId", keywordId.ToString());
|
||||
|
||||
RestResponse<Keyword> resp = await req.ExecuteGet<Keyword>(cancellationToken).ConfigureAwait(false);
|
||||
Keyword resp = await req.GetOfT<Keyword>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
public async Task<SearchContainerWithId<SearchMovie>> GetKeywordMoviesAsync(int keywordId, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainerWithId<SearchMovie>> GetKeywordMoviesAsync(int keywordId, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetKeywordMoviesAsync(keywordId, DefaultLanguage, page, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainerWithId<SearchMovie>> GetKeywordMoviesAsync(int keywordId, string language, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainerWithId<SearchMovie>> GetKeywordMoviesAsync(int keywordId, string language, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("keyword/{keywordId}/movies");
|
||||
req.AddUrlSegment("keywordId", keywordId.ToString());
|
||||
@ -35,7 +35,7 @@ namespace TMDbLib.Client
|
||||
if (page >= 1)
|
||||
req.AddParameter("page", page.ToString());
|
||||
|
||||
RestResponse<SearchContainerWithId<SearchMovie>> resp = await req.ExecuteGet<SearchContainerWithId<SearchMovie>>(cancellationToken).ConfigureAwait(false);
|
||||
SearchContainerWithId<SearchMovie> resp = await req.GetOfT<SearchContainerWithId<SearchMovie>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
@ -10,12 +10,40 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
private async Task<bool> GetManipulateMediaListAsyncInternal(string listId, int movieId, string method, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(listId))
|
||||
throw new ArgumentNullException(nameof(listId));
|
||||
|
||||
// Movie Id is expected by the API and can not be null
|
||||
if (movieId <= 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(movieId));
|
||||
|
||||
RestRequest req = _client.Create("list/{listId}/{method}");
|
||||
req.AddUrlSegment("listId", listId);
|
||||
req.AddUrlSegment("method", method);
|
||||
AddSessionId(req, SessionType.UserSession);
|
||||
|
||||
req.SetBody(new { media_id = movieId });
|
||||
|
||||
RestResponse<PostReply> response = await req.Post<PostReply>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// Status code 12 = "The item/record was updated successfully"
|
||||
// Status code 13 = "The item/record was deleted successfully"
|
||||
PostReply item = await response.GetDataObject().ConfigureAwait(false);
|
||||
|
||||
// TODO: Previous code checked for item=null
|
||||
return item.StatusCode == 12 || item.StatusCode == 13;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve a list by it's id
|
||||
/// </summary>
|
||||
/// <param name="listId">The id of the list you want to retrieve</param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
public async Task<GenericList> GetListAsync(string listId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<GenericList> GetListAsync(string listId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(listId))
|
||||
throw new ArgumentNullException(nameof(listId));
|
||||
@ -23,7 +51,7 @@ namespace TMDbLib.Client
|
||||
RestRequest req = _client.Create("list/{listId}");
|
||||
req.AddUrlSegment("listId", listId);
|
||||
|
||||
RestResponse<GenericList> resp = await req.ExecuteGet<GenericList>(cancellationToken).ConfigureAwait(false);
|
||||
GenericList resp = await req.GetOfT<GenericList>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
@ -34,7 +62,7 @@ namespace TMDbLib.Client
|
||||
/// <param name="listId">Id of the list to check in</param>
|
||||
/// <param name="movieId">Id of the movie to check for in the list</param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
public async Task<bool> GetListIsMoviePresentAsync(string listId, int movieId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<bool> GetListIsMoviePresentAsync(string listId, int movieId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(listId))
|
||||
throw new ArgumentNullException(nameof(listId));
|
||||
@ -46,7 +74,7 @@ namespace TMDbLib.Client
|
||||
req.AddUrlSegment("listId", listId);
|
||||
req.AddParameter("movie_id", movieId.ToString());
|
||||
|
||||
RestResponse<ListStatus> response = await req.ExecuteGet<ListStatus>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<ListStatus> response = await req.Get<ListStatus>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return (await response.GetDataObject().ConfigureAwait(false)).ItemPresent;
|
||||
}
|
||||
@ -60,9 +88,9 @@ namespace TMDbLib.Client
|
||||
/// <returns>True if the method was able to add the movie to the list, will retrun false in case of an issue or when the movie was already added to the list</returns>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<bool> ListAddMovieAsync(string listId, int movieId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<bool> ListAddMovieAsync(string listId, int movieId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await ManipulateMediaListAsync(listId, movieId, "add_item", cancellationToken).ConfigureAwait(false);
|
||||
return await GetManipulateMediaListAsyncInternal(listId, movieId, "add_item", cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -73,7 +101,7 @@ namespace TMDbLib.Client
|
||||
/// <returns>True if the method was able to remove the movie from the list, will retrun false in case of an issue or when the movie was not present in the list</returns>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<bool> ListClearAsync(string listId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<bool> ListClearAsync(string listId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
@ -85,7 +113,7 @@ namespace TMDbLib.Client
|
||||
request.AddParameter("confirm", "true");
|
||||
AddSessionId(request, SessionType.UserSession);
|
||||
|
||||
RestResponse<PostReply> response = await request.ExecutePost<PostReply>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<PostReply> response = await request.Post<PostReply>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// Status code 12 = "The item/record was updated successfully"
|
||||
PostReply item = await response.GetDataObject().ConfigureAwait(false);
|
||||
@ -103,7 +131,7 @@ namespace TMDbLib.Client
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<string> ListCreateAsync(string name, string description = "", string language = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<string> ListCreateAsync(string name, string description = "", string language = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
@ -128,7 +156,7 @@ namespace TMDbLib.Client
|
||||
req.SetBody(new { name = name, description = description });
|
||||
}
|
||||
|
||||
RestResponse<ListCreateReply> response = await req.ExecutePost<ListCreateReply>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<ListCreateReply> response = await req.Post<ListCreateReply>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return (await response.GetDataObject().ConfigureAwait(false)).ListId;
|
||||
}
|
||||
@ -140,7 +168,7 @@ namespace TMDbLib.Client
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<bool> ListDeleteAsync(string listId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<bool> ListDeleteAsync(string listId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
@ -151,7 +179,7 @@ namespace TMDbLib.Client
|
||||
req.AddUrlSegment("listId", listId);
|
||||
AddSessionId(req, SessionType.UserSession);
|
||||
|
||||
RestResponse<PostReply> response = await req.ExecuteDelete<PostReply>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<PostReply> response = await req.Delete<PostReply>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// Status code 13 = success
|
||||
PostReply item = await response.GetDataObject().ConfigureAwait(false);
|
||||
@ -169,37 +197,9 @@ namespace TMDbLib.Client
|
||||
/// <returns>True if the method was able to remove the movie from the list, will retrun false in case of an issue or when the movie was not present in the list</returns>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<bool> ListRemoveMovieAsync(string listId, int movieId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<bool> ListRemoveMovieAsync(string listId, int movieId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await ManipulateMediaListAsync(listId, movieId, "remove_item", cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task<bool> ManipulateMediaListAsync(string listId, int movieId, string method, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(listId))
|
||||
throw new ArgumentNullException(nameof(listId));
|
||||
|
||||
// Movie Id is expected by the API and can not be null
|
||||
if (movieId <= 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(movieId));
|
||||
|
||||
RestRequest req = _client.Create("list/{listId}/{method}");
|
||||
req.AddUrlSegment("listId", listId);
|
||||
req.AddUrlSegment("method", method);
|
||||
AddSessionId(req, SessionType.UserSession);
|
||||
|
||||
req.SetBody(new { media_id = movieId });
|
||||
|
||||
RestResponse<PostReply> response = await req.ExecutePost<PostReply>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// Status code 12 = "The item/record was updated successfully"
|
||||
// Status code 13 = "The item/record was deleted successfully"
|
||||
PostReply item = await response.GetDataObject().ConfigureAwait(false);
|
||||
|
||||
// TODO: Previous code checked for item=null
|
||||
return item.StatusCode == 12 || item.StatusCode == 13;
|
||||
return await GetManipulateMediaListAsyncInternal(listId, movieId, "remove_item", cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -6,7 +6,6 @@ using System.Net;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
using TMDbLib.Objects.Changes;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Movies;
|
||||
using TMDbLib.Objects.Reviews;
|
||||
@ -19,6 +18,35 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
private async Task<T> GetMovieMethodInternal<T>(int movieId, MovieMethods movieMethod, string dateFormat = null,
|
||||
string country = null,
|
||||
string language = null, string includeImageLanguage = null, int page = 0, DateTime? startDate = null, DateTime? endDate = null, CancellationToken cancellationToken = default) where T : new()
|
||||
{
|
||||
RestRequest req = _client.Create("movie/{movieId}/{method}");
|
||||
req.AddUrlSegment("movieId", movieId.ToString(CultureInfo.InvariantCulture));
|
||||
req.AddUrlSegment("method", movieMethod.GetDescription());
|
||||
|
||||
if (country != null)
|
||||
req.AddParameter("country", country);
|
||||
language = language ?? DefaultLanguage;
|
||||
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)
|
||||
req.AddParameter("start_date", startDate.Value.ToString("yyyy-MM-dd"));
|
||||
if (endDate != null)
|
||||
req.AddParameter("end_date", endDate.Value.ToString("yyyy-MM-dd"));
|
||||
|
||||
T response = await req.GetOfT<T>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all information for a specific movie in relation to the current user account
|
||||
/// </summary>
|
||||
@ -26,7 +54,7 @@ namespace TMDbLib.Client
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<AccountState> GetMovieAccountStateAsync(int movieId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<AccountState> GetMovieAccountStateAsync(int movieId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
@ -35,32 +63,32 @@ namespace TMDbLib.Client
|
||||
req.AddUrlSegment("method", MovieMethods.AccountStates.GetDescription());
|
||||
AddSessionId(req, SessionType.UserSession);
|
||||
|
||||
RestResponse<AccountState> response = await req.ExecuteGet<AccountState>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<AccountState> response = await req.Get<AccountState>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return await response.GetDataObject().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<AlternativeTitles> GetMovieAlternativeTitlesAsync(int movieId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<AlternativeTitles> GetMovieAlternativeTitlesAsync(int movieId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieAlternativeTitlesAsync(movieId, DefaultCountry, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<AlternativeTitles> GetMovieAlternativeTitlesAsync(int movieId, string country, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<AlternativeTitles> GetMovieAlternativeTitlesAsync(int movieId, string country, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieMethod<AlternativeTitles>(movieId, MovieMethods.AlternativeTitles, country: country, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetMovieMethodInternal<AlternativeTitles>(movieId, MovieMethods.AlternativeTitles, country: country, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<Movie> GetMovieAsync(int movieId, MovieMethods extraMethods = MovieMethods.Undefined, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<Movie> GetMovieAsync(int movieId, MovieMethods extraMethods = MovieMethods.Undefined, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieAsync(movieId, DefaultLanguage, null, extraMethods, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<Movie> GetMovieAsync(string imdbId, MovieMethods extraMethods = MovieMethods.Undefined, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<Movie> GetMovieAsync(string imdbId, MovieMethods extraMethods = MovieMethods.Undefined, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieAsync(imdbId, DefaultLanguage, null, extraMethods, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<Movie> GetMovieAsync(int movieId, string language, string includeImageLanguage = null, MovieMethods extraMethods = MovieMethods.Undefined, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<Movie> GetMovieAsync(int movieId, string language, string includeImageLanguage = null, MovieMethods extraMethods = MovieMethods.Undefined, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieAsync(movieId.ToString(CultureInfo.InvariantCulture), language, includeImageLanguage, extraMethods, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
@ -76,7 +104,7 @@ namespace TMDbLib.Client
|
||||
/// <returns>The reqed movie or null if it could not be found</returns>
|
||||
/// <remarks>Requires a valid user session when specifying the extra method 'AccountStates' flag</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned, see remarks.</exception>
|
||||
public async Task<Movie> GetMovieAsync(string imdbId, string language, string includeImageLanguage = null, MovieMethods extraMethods = MovieMethods.Undefined, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<Movie> GetMovieAsync(string imdbId, string language, string includeImageLanguage = null, MovieMethods extraMethods = MovieMethods.Undefined, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (extraMethods.HasFlag(MovieMethods.AccountStates))
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
@ -103,7 +131,7 @@ namespace TMDbLib.Client
|
||||
if (appends != string.Empty)
|
||||
req.AddParameter("append_to_response", appends);
|
||||
|
||||
RestResponse<Movie> response = await req.ExecuteGet<Movie>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<Movie> response = await req.Get<Movie>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (!response.IsValid)
|
||||
return null;
|
||||
@ -141,15 +169,9 @@ namespace TMDbLib.Client
|
||||
return item;
|
||||
}
|
||||
|
||||
public async Task<List<Change>> GetMovieChangesAsync(int movieId, DateTime? startDate = null, DateTime? endDate = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<Credits> GetMovieCreditsAsync(int movieId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
ChangesContainer changesContainer = await GetMovieMethod<ChangesContainer>(movieId, MovieMethods.Changes, startDate: startDate, endDate: endDate, dateFormat: "yyyy-MM-dd HH:mm:ss UTC", cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return changesContainer.Changes;
|
||||
}
|
||||
|
||||
public async Task<Credits> GetMovieCreditsAsync(int movieId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return await GetMovieMethod<Credits>(movieId, MovieMethods.Credits, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetMovieMethodInternal<Credits>(movieId, MovieMethods.Credits, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -157,30 +179,30 @@ namespace TMDbLib.Client
|
||||
/// </summary>
|
||||
/// <param name="id">The TMDb id of the target movie.</param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
public async Task<ExternalIdsMovie> GetMovieExternalIdsAsync(int id, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<ExternalIdsMovie> GetMovieExternalIdsAsync(int id, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieMethod<ExternalIdsMovie>(id, MovieMethods.ExternalIds, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetMovieMethodInternal<ExternalIdsMovie>(id, MovieMethods.ExternalIds, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<ImagesWithId> GetMovieImagesAsync(int movieId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<ImagesWithId> GetMovieImagesAsync(int movieId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieImagesAsync(movieId, DefaultLanguage, null, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<ImagesWithId> GetMovieImagesAsync(int movieId, string language, string includeImageLanguage = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<ImagesWithId> GetMovieImagesAsync(int movieId, string language, string includeImageLanguage = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieMethod<ImagesWithId>(movieId, MovieMethods.Images, language: language, includeImageLanguage: includeImageLanguage, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetMovieMethodInternal<ImagesWithId>(movieId, MovieMethods.Images, language: language, includeImageLanguage: includeImageLanguage, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<KeywordsContainer> GetMovieKeywordsAsync(int movieId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<KeywordsContainer> GetMovieKeywordsAsync(int movieId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieMethod<KeywordsContainer>(movieId, MovieMethods.Keywords, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetMovieMethodInternal<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)
|
||||
{
|
||||
RestRequest req = _client.Create("movie/latest");
|
||||
RestResponse<Movie> resp = await req.ExecuteGet<Movie>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<Movie> resp = await req.Get<Movie>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
Movie item = await resp.GetDataObject().ConfigureAwait(false);
|
||||
|
||||
@ -191,56 +213,27 @@ namespace TMDbLib.Client
|
||||
return item;
|
||||
}
|
||||
|
||||
public async Task<SearchContainerWithId<ListResult>> GetMovieListsAsync(int movieId, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainerWithId<ListResult>> GetMovieListsAsync(int movieId, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieListsAsync(movieId, DefaultLanguage, page, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainerWithId<ListResult>> GetMovieListsAsync(int movieId, string language, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainerWithId<ListResult>> GetMovieListsAsync(int movieId, string language, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieMethod<SearchContainerWithId<ListResult>>(movieId, MovieMethods.Lists, page: page, language: language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetMovieMethodInternal<SearchContainerWithId<ListResult>>(movieId, MovieMethods.Lists, page: page, language: language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchMovie>> GetMovieRecommendationsAsync(int id, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchMovie>> GetMovieRecommendationsAsync(int id, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieRecommendationsAsync(id, DefaultLanguage, page, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchMovie>> GetMovieRecommendationsAsync(int id, string language, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchMovie>> GetMovieRecommendationsAsync(int id, string language, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieMethod<SearchContainer<SearchMovie>>(id, MovieMethods.Recommendations, language: language, page: page, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetMovieMethodInternal<SearchContainer<SearchMovie>>(id, MovieMethods.Recommendations, language: language, page: page, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task<T> GetMovieMethod<T>(int movieId, MovieMethods movieMethod, string dateFormat = null,
|
||||
string country = null,
|
||||
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));
|
||||
req.AddUrlSegment("method", movieMethod.GetDescription());
|
||||
|
||||
if (country != null)
|
||||
req.AddParameter("country", country);
|
||||
language = language ?? DefaultLanguage;
|
||||
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)
|
||||
req.AddParameter("start_date", startDate.Value.ToString("yyyy-MM-dd"));
|
||||
if (endDate != null)
|
||||
req.AddParameter("end_date", endDate.Value.ToString("yyyy-MM-dd"));
|
||||
|
||||
RestResponse<T> response = await req.ExecuteGet<T>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public async Task<SearchContainerWithDates<SearchMovie>> GetMovieNowPlayingListAsync(string language = null, int page = 0, string region = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainerWithDates<SearchMovie>> GetMovieNowPlayingListAsync(string language = null, int page = 0, string region = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("movie/now_playing");
|
||||
|
||||
@ -251,12 +244,12 @@ namespace TMDbLib.Client
|
||||
if (region != null)
|
||||
req.AddParameter("region", region);
|
||||
|
||||
RestResponse<SearchContainerWithDates<SearchMovie>> resp = await req.ExecuteGet<SearchContainerWithDates<SearchMovie>>(cancellationToken).ConfigureAwait(false);
|
||||
SearchContainerWithDates<SearchMovie> resp = await req.GetOfT<SearchContainerWithDates<SearchMovie>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchMovie>> GetMoviePopularListAsync(string language = null, int page = 0, string region = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchMovie>> GetMoviePopularListAsync(string language = null, int page = 0, string region = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("movie/popular");
|
||||
|
||||
@ -267,42 +260,42 @@ namespace TMDbLib.Client
|
||||
if (region != null)
|
||||
req.AddParameter("region", region);
|
||||
|
||||
RestResponse<SearchContainer<SearchMovie>> resp = await req.ExecuteGet<SearchContainer<SearchMovie>>(cancellationToken).ConfigureAwait(false);
|
||||
SearchContainer<SearchMovie> resp = await req.GetOfT<SearchContainer<SearchMovie>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
public async Task<ResultContainer<ReleaseDatesContainer>> GetMovieReleaseDatesAsync(int movieId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<ResultContainer<ReleaseDatesContainer>> GetMovieReleaseDatesAsync(int movieId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieMethod<ResultContainer<ReleaseDatesContainer>>(movieId, MovieMethods.ReleaseDates, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetMovieMethodInternal<ResultContainer<ReleaseDatesContainer>>(movieId, MovieMethods.ReleaseDates, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<Releases> GetMovieReleasesAsync(int movieId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<Releases> GetMovieReleasesAsync(int movieId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieMethod<Releases>(movieId, MovieMethods.Releases, dateFormat: "yyyy-MM-dd", cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetMovieMethodInternal<Releases>(movieId, MovieMethods.Releases, dateFormat: "yyyy-MM-dd", cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainerWithId<ReviewBase>> GetMovieReviewsAsync(int movieId, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainerWithId<ReviewBase>> GetMovieReviewsAsync(int movieId, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieReviewsAsync(movieId, DefaultLanguage, page, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainerWithId<ReviewBase>> GetMovieReviewsAsync(int movieId, string language, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainerWithId<ReviewBase>> GetMovieReviewsAsync(int movieId, string language, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieMethod<SearchContainerWithId<ReviewBase>>(movieId, MovieMethods.Reviews, page: page, language: language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetMovieMethodInternal<SearchContainerWithId<ReviewBase>>(movieId, MovieMethods.Reviews, page: page, language: language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchMovie>> GetMovieSimilarAsync(int movieId, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchMovie>> GetMovieSimilarAsync(int movieId, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieSimilarAsync(movieId, DefaultLanguage, page, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchMovie>> GetMovieSimilarAsync(int movieId, string language, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchMovie>> GetMovieSimilarAsync(int movieId, string language, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieMethod<SearchContainer<SearchMovie>>(movieId, MovieMethods.Similar, page: page, language: language, dateFormat: "yyyy-MM-dd", cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetMovieMethodInternal<SearchContainer<SearchMovie>>(movieId, MovieMethods.Similar, page: page, language: language, dateFormat: "yyyy-MM-dd", cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchMovie>> GetMovieTopRatedListAsync(string language = null, int page = 0, string region = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchMovie>> GetMovieTopRatedListAsync(string language = null, int page = 0, string region = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("movie/top_rated");
|
||||
|
||||
@ -313,17 +306,17 @@ namespace TMDbLib.Client
|
||||
if (region != null)
|
||||
req.AddParameter("region", region);
|
||||
|
||||
RestResponse<SearchContainer<SearchMovie>> resp = await req.ExecuteGet<SearchContainer<SearchMovie>>(cancellationToken).ConfigureAwait(false);
|
||||
SearchContainer<SearchMovie> resp = await req.GetOfT<SearchContainer<SearchMovie>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
public async Task<TranslationsContainer> GetMovieTranslationsAsync(int movieId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<TranslationsContainer> GetMovieTranslationsAsync(int movieId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieMethod<TranslationsContainer>(movieId, MovieMethods.Translations, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetMovieMethodInternal<TranslationsContainer>(movieId, MovieMethods.Translations, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainerWithDates<SearchMovie>> GetMovieUpcomingListAsync(string language = null, int page = 0, string region = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainerWithDates<SearchMovie>> GetMovieUpcomingListAsync(string language = null, int page = 0, string region = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("movie/upcoming");
|
||||
|
||||
@ -334,22 +327,22 @@ namespace TMDbLib.Client
|
||||
if (region != null)
|
||||
req.AddParameter("region", region);
|
||||
|
||||
RestResponse<SearchContainerWithDates<SearchMovie>> resp = await req.ExecuteGet<SearchContainerWithDates<SearchMovie>>(cancellationToken).ConfigureAwait(false);
|
||||
SearchContainerWithDates<SearchMovie> resp = await req.GetOfT<SearchContainerWithDates<SearchMovie>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
public async Task<ResultContainer<Video>> GetMovieVideosAsync(int movieId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<ResultContainer<Video>> GetMovieVideosAsync(int movieId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieMethod<ResultContainer<Video>>(movieId, MovieMethods.Videos, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetMovieMethodInternal<ResultContainer<Video>>(movieId, MovieMethods.Videos, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SingleResultContainer<Dictionary<string, WatchProviders>>> GetMovieWatchProvidersAsync(int movieId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SingleResultContainer<Dictionary<string, WatchProviders>>> GetMovieWatchProvidersAsync(int movieId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetMovieMethod<SingleResultContainer<Dictionary<string, WatchProviders>>>(movieId, MovieMethods.WatchProviders, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetMovieMethodInternal<SingleResultContainer<Dictionary<string, WatchProviders>>>(movieId, MovieMethods.WatchProviders, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<bool> MovieRemoveRatingAsync(int movieId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<bool> MovieRemoveRatingAsync(int movieId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RequireSessionId(SessionType.GuestSession);
|
||||
|
||||
@ -357,7 +350,7 @@ namespace TMDbLib.Client
|
||||
req.AddUrlSegment("movieId", movieId.ToString(CultureInfo.InvariantCulture));
|
||||
AddSessionId(req);
|
||||
|
||||
RestResponse<PostReply> response = await req.ExecuteDelete<PostReply>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<PostReply> response = await req.Delete<PostReply>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// status code 13 = "The item/record was deleted successfully."
|
||||
PostReply item = await response.GetDataObject().ConfigureAwait(false);
|
||||
@ -375,7 +368,7 @@ namespace TMDbLib.Client
|
||||
/// <returns>True if the the movie's rating was successfully updated, false if not</returns>
|
||||
/// <remarks>Requires a valid guest or user session</remarks>
|
||||
/// <exception cref="GuestSessionRequiredException">Thrown when the current client object doens't have a guest or user session assigned.</exception>
|
||||
public async Task<bool> MovieSetRatingAsync(int movieId, double rating, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<bool> MovieSetRatingAsync(int movieId, double rating, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RequireSessionId(SessionType.GuestSession);
|
||||
|
||||
@ -385,7 +378,7 @@ namespace TMDbLib.Client
|
||||
|
||||
req.SetBody(new { value = rating });
|
||||
|
||||
RestResponse<PostReply> response = await req.ExecutePost<PostReply>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<PostReply> response = await req.Post<PostReply>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// status code 1 = "Success"
|
||||
// status code 12 = "The item/record was updated successfully" - Used when an item was previously rated by the user
|
||||
|
@ -14,12 +14,12 @@ namespace TMDbLib.Client
|
||||
/// </summary>
|
||||
/// <param name="networkId">The id of the network object to retrieve</param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
public async Task<Network> GetNetworkAsync(int networkId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<Network> GetNetworkAsync(int networkId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("network/{networkId}");
|
||||
req.AddUrlSegment("networkId", networkId.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
RestResponse<Network> response = await req.ExecuteGet<Network>(cancellationToken).ConfigureAwait(false);
|
||||
Network response = await req.GetOfT<Network>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return response;
|
||||
}
|
||||
@ -29,12 +29,12 @@ namespace TMDbLib.Client
|
||||
/// </summary>
|
||||
/// <param name="networkId">The TMDb id of the network</param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
public async Task<NetworkLogos> GetNetworkImagesAsync(int networkId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<NetworkLogos> GetNetworkImagesAsync(int networkId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("network/{networkId}/images");
|
||||
req.AddUrlSegment("networkId", networkId.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
RestResponse<NetworkLogos> response = await req.ExecuteGet<NetworkLogos>(cancellationToken).ConfigureAwait(false);
|
||||
NetworkLogos response = await req.GetOfT<NetworkLogos>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return response;
|
||||
}
|
||||
@ -44,12 +44,12 @@ namespace TMDbLib.Client
|
||||
/// </summary>
|
||||
/// <param name="networkId">The TMDb id of the network</param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
public async Task<AlternativeNames> GetNetworkAlternativeNamesAsync(int networkId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<AlternativeNames> GetNetworkAlternativeNamesAsync(int networkId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("network/{networkId}/alternative_names");
|
||||
req.AddUrlSegment("networkId", networkId.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
RestResponse<AlternativeNames> response = await req.ExecuteGet<AlternativeNames>(cancellationToken).ConfigureAwait(false);
|
||||
AlternativeNames response = await req.GetOfT<AlternativeNames>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using TMDbLib.Objects.Changes;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.People;
|
||||
using TMDbLib.Rest;
|
||||
@ -13,110 +11,8 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public async Task<Person> GetLatestPersonAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
RestRequest req = _client.Create("person/latest");
|
||||
|
||||
// TODO: Dateformat?
|
||||
//req.DateFormat = "yyyy-MM-dd";
|
||||
|
||||
RestResponse<Person> resp = await req.ExecuteGet<Person>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
public async Task<Person> GetPersonAsync(int personId, PersonMethods extraMethods = PersonMethods.Undefined,
|
||||
CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return await GetPersonAsync(personId, DefaultLanguage, extraMethods, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<Person> GetPersonAsync(int personId, string language, PersonMethods extraMethods = PersonMethods.Undefined, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
RestRequest req = _client.Create("person/{personId}");
|
||||
req.AddUrlSegment("personId", personId.ToString());
|
||||
|
||||
if (language != null)
|
||||
req.AddParameter("language", language);
|
||||
|
||||
string appends = string.Join(",",
|
||||
Enum.GetValues(typeof(PersonMethods))
|
||||
.OfType<PersonMethods>()
|
||||
.Except(new[] { PersonMethods.Undefined })
|
||||
.Where(s => extraMethods.HasFlag(s))
|
||||
.Select(s => s.GetDescription()));
|
||||
|
||||
if (appends != string.Empty)
|
||||
req.AddParameter("append_to_response", appends);
|
||||
|
||||
// TODO: Dateformat?
|
||||
//req.DateFormat = "yyyy-MM-dd";
|
||||
|
||||
RestResponse<Person> response = await req.ExecuteGet<Person>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (!response.IsValid)
|
||||
return null;
|
||||
|
||||
Person item = await response.GetDataObject().ConfigureAwait(false);
|
||||
|
||||
// Patch up data, so that the end user won't notice that we share objects between request-types.
|
||||
if (item != null)
|
||||
{
|
||||
if (item.Images != null)
|
||||
item.Images.Id = item.Id;
|
||||
|
||||
if (item.TvCredits != null)
|
||||
item.TvCredits.Id = item.Id;
|
||||
|
||||
if (item.MovieCredits != null)
|
||||
item.MovieCredits.Id = item.Id;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public async Task<List<Change>> GetPersonChangesAsync(int personId, DateTime? startDate = null, DateTime? endDate = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
ChangesContainer changesContainer = await GetPersonMethod<ChangesContainer>(personId, PersonMethods.Changes, startDate: startDate, endDate: endDate, dateFormat: "yyyy-MM-dd HH:mm:ss UTC", cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return changesContainer.Changes;
|
||||
}
|
||||
|
||||
public async Task<ExternalIdsPerson> GetPersonExternalIdsAsync(int personId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return await GetPersonMethod<ExternalIdsPerson>(personId, PersonMethods.ExternalIds, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<ProfileImages> GetPersonImagesAsync(int personId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return await GetPersonMethod<ProfileImages>(personId, PersonMethods.Images, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<PersonResult>> GetPersonListAsync(PersonListType type, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
RestRequest req;
|
||||
switch (type)
|
||||
{
|
||||
case PersonListType.Popular:
|
||||
req = _client.Create("person/popular");
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(type));
|
||||
}
|
||||
|
||||
if (page >= 1)
|
||||
req.AddParameter("page", page.ToString());
|
||||
|
||||
// TODO: Dateformat?
|
||||
//req.DateFormat = "yyyy-MM-dd";
|
||||
|
||||
RestResponse<SearchContainer<PersonResult>> resp = await req.ExecuteGet<SearchContainer<PersonResult>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
private async Task<T> GetPersonMethod<T>(int personId, PersonMethods personMethod, 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()
|
||||
private async Task<T> GetPersonMethodInternal<T>(int personId, PersonMethods personMethod, string dateFormat = null, string country = null, string language = null,
|
||||
int page = 0, DateTime? startDate = null, DateTime? endDate = null, CancellationToken cancellationToken = default) where T : new()
|
||||
{
|
||||
RestRequest req = _client.Create("person/{personId}/{method}");
|
||||
req.AddUrlSegment("personId", personId.ToString());
|
||||
@ -139,39 +35,135 @@ namespace TMDbLib.Client
|
||||
if (endDate != null)
|
||||
req.AddParameter("endDate", endDate.Value.ToString("yyyy-MM-dd"));
|
||||
|
||||
RestResponse<T> resp = await req.ExecuteGet<T>(cancellationToken).ConfigureAwait(false);
|
||||
T resp = await req.GetOfT<T>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
public async Task<MovieCredits> GetPersonMovieCreditsAsync(int personId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<Person> GetLatestPersonAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("person/latest");
|
||||
|
||||
// TODO: Dateformat?
|
||||
//req.DateFormat = "yyyy-MM-dd";
|
||||
|
||||
Person resp = await req.GetOfT<Person>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
public async Task<Person> GetPersonAsync(int personId, PersonMethods extraMethods = PersonMethods.Undefined,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetPersonAsync(personId, DefaultLanguage, extraMethods, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<Person> GetPersonAsync(int personId, string language, PersonMethods extraMethods = PersonMethods.Undefined, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("person/{personId}");
|
||||
req.AddUrlSegment("personId", personId.ToString());
|
||||
|
||||
if (language != null)
|
||||
req.AddParameter("language", language);
|
||||
|
||||
string appends = string.Join(",",
|
||||
Enum.GetValues(typeof(PersonMethods))
|
||||
.OfType<PersonMethods>()
|
||||
.Except(new[] { PersonMethods.Undefined })
|
||||
.Where(s => extraMethods.HasFlag(s))
|
||||
.Select(s => s.GetDescription()));
|
||||
|
||||
if (appends != string.Empty)
|
||||
req.AddParameter("append_to_response", appends);
|
||||
|
||||
// TODO: Dateformat?
|
||||
//req.DateFormat = "yyyy-MM-dd";
|
||||
|
||||
RestResponse<Person> response = await req.Get<Person>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (!response.IsValid)
|
||||
return null;
|
||||
|
||||
Person item = await response.GetDataObject().ConfigureAwait(false);
|
||||
|
||||
// Patch up data, so that the end user won't notice that we share objects between request-types.
|
||||
if (item != null)
|
||||
{
|
||||
if (item.Images != null)
|
||||
item.Images.Id = item.Id;
|
||||
|
||||
if (item.TvCredits != null)
|
||||
item.TvCredits.Id = item.Id;
|
||||
|
||||
if (item.MovieCredits != null)
|
||||
item.MovieCredits.Id = item.Id;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public async Task<ExternalIdsPerson> GetPersonExternalIdsAsync(int personId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetPersonMethodInternal<ExternalIdsPerson>(personId, PersonMethods.ExternalIds, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<ProfileImages> GetPersonImagesAsync(int personId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
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)
|
||||
{
|
||||
RestRequest req;
|
||||
switch (type)
|
||||
{
|
||||
case PersonListType.Popular:
|
||||
req = _client.Create("person/popular");
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(type));
|
||||
}
|
||||
|
||||
if (page >= 1)
|
||||
req.AddParameter("page", page.ToString());
|
||||
|
||||
// TODO: Dateformat?
|
||||
//req.DateFormat = "yyyy-MM-dd";
|
||||
|
||||
SearchContainer<PersonResult> resp = await req.GetOfT<SearchContainer<PersonResult>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
public async Task<MovieCredits> GetPersonMovieCreditsAsync(int personId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetPersonMovieCreditsAsync(personId, DefaultLanguage, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<MovieCredits> GetPersonMovieCreditsAsync(int personId, string language, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<MovieCredits> GetPersonMovieCreditsAsync(int personId, string language, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetPersonMethod<MovieCredits>(personId, PersonMethods.MovieCredits, language: language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetPersonMethodInternal<MovieCredits>(personId, PersonMethods.MovieCredits, language: language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainerWithId<TaggedImage>> GetPersonTaggedImagesAsync(int personId, int page, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainerWithId<TaggedImage>> GetPersonTaggedImagesAsync(int personId, int page, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetPersonTaggedImagesAsync(personId, DefaultLanguage, page, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainerWithId<TaggedImage>> GetPersonTaggedImagesAsync(int personId, string language, int page, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainerWithId<TaggedImage>> GetPersonTaggedImagesAsync(int personId, string language, int page, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetPersonMethod<SearchContainerWithId<TaggedImage>>(personId, PersonMethods.TaggedImages, language: language, page: page, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetPersonMethodInternal<SearchContainerWithId<TaggedImage>>(personId, PersonMethods.TaggedImages, language: language, page: page, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<TvCredits> GetPersonTvCreditsAsync(int personId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<TvCredits> GetPersonTvCreditsAsync(int personId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetPersonTvCreditsAsync(personId, DefaultLanguage, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<TvCredits> GetPersonTvCreditsAsync(int personId, string language, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<TvCredits> GetPersonTvCreditsAsync(int personId, string language, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetPersonMethod<TvCredits>(personId, PersonMethods.TvCredits, language: language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetPersonMethodInternal<TvCredits>(personId, PersonMethods.TvCredits, language: language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public async Task<Review> GetReviewAsync(string reviewId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<Review> GetReviewAsync(string reviewId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest request = _client.Create("review/{reviewId}");
|
||||
request.AddUrlSegment("reviewId", reviewId);
|
||||
@ -15,7 +15,7 @@ namespace TMDbLib.Client
|
||||
// TODO: Dateformat?
|
||||
//request.DateFormat = "yyyy-MM-dd";
|
||||
|
||||
RestResponse<Review> resp = await request.ExecuteGet<Review>(cancellationToken).ConfigureAwait(false);
|
||||
Review resp = await request.GetOfT<Review>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
private async Task<T> SearchMethod<T>(string method, string query, int page, string language = null, bool? includeAdult = null, int year = 0, string dateFormat = null, string region = null, int primaryReleaseYear = 0, int firstAirDateYear = 0, CancellationToken cancellationToken = default(CancellationToken)) where T : new()
|
||||
private async Task<T> SearchMethodInternal<T>(string method, string query, int page, string language = null, bool? includeAdult = null, int year = 0, string dateFormat = null, string region = null, int primaryReleaseYear = 0, int firstAirDateYear = 0, CancellationToken cancellationToken = default) where T : new()
|
||||
{
|
||||
RestRequest req = _client.Create("search/{method}");
|
||||
req.AddUrlSegment("method", method);
|
||||
@ -38,75 +38,75 @@ namespace TMDbLib.Client
|
||||
if (firstAirDateYear >= 1)
|
||||
req.AddParameter("first_air_date_year", firstAirDateYear.ToString());
|
||||
|
||||
RestResponse<T> resp = await req.ExecuteGet<T>(cancellationToken).ConfigureAwait(false);
|
||||
T resp = await req.GetOfT<T>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchCollection>> SearchCollectionAsync(string query, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchCollection>> SearchCollectionAsync(string query, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await SearchCollectionAsync(query, DefaultLanguage, page, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchCollection>> SearchCollectionAsync(string query, string language, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchCollection>> SearchCollectionAsync(string query, string language, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await SearchMethod<SearchContainer<SearchCollection>>("collection", query, page, language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await SearchMethodInternal<SearchContainer<SearchCollection>>("collection", query, page, language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchCompany>> SearchCompanyAsync(string query, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchCompany>> SearchCompanyAsync(string query, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await SearchMethod<SearchContainer<SearchCompany>>("company", query, page, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await SearchMethodInternal<SearchContainer<SearchCompany>>("company", query, page, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchKeyword>> SearchKeywordAsync(string query, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchKeyword>> SearchKeywordAsync(string query, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await SearchMethod<SearchContainer<SearchKeyword>>("keyword", query, page, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await SearchMethodInternal<SearchContainer<SearchKeyword>>("keyword", query, page, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[Obsolete("20200701 No longer present in public API")]
|
||||
public async Task<SearchContainer<SearchList>> SearchListAsync(string query, int page = 0, bool includeAdult = false, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchList>> SearchListAsync(string query, int page = 0, bool includeAdult = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await SearchMethod<SearchContainer<SearchList>>("list", query, page, includeAdult: includeAdult, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await SearchMethodInternal<SearchContainer<SearchList>>("list", query, page, includeAdult: includeAdult, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchMovie>> SearchMovieAsync(string query, int page = 0, bool includeAdult = false, int year = 0, string region = null, int primaryReleaseYear = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchMovie>> SearchMovieAsync(string query, int page = 0, bool includeAdult = false, int year = 0, string region = null, int primaryReleaseYear = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await SearchMovieAsync(query, DefaultLanguage, page, includeAdult, year, region, primaryReleaseYear, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchMovie>> SearchMovieAsync(string query, string language, int page = 0, bool includeAdult = false, int year = 0, string region = null, int primaryReleaseYear = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchMovie>> SearchMovieAsync(string query, string language, int page = 0, bool includeAdult = false, int year = 0, string region = null, int primaryReleaseYear = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await SearchMethod<SearchContainer<SearchMovie>>("movie", query, page, language, includeAdult, year, "yyyy-MM-dd", region, primaryReleaseYear, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await SearchMethodInternal<SearchContainer<SearchMovie>>("movie", query, page, language, includeAdult, year, "yyyy-MM-dd", region, primaryReleaseYear, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchBase>> SearchMultiAsync(string query, int page = 0, bool includeAdult = false, int year = 0, string region = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchBase>> SearchMultiAsync(string query, int page = 0, bool includeAdult = false, int year = 0, string region = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await SearchMultiAsync(query, DefaultLanguage, page, includeAdult, year, region, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchBase>> SearchMultiAsync(string query, string language, int page = 0, bool includeAdult = false, int year = 0, string region = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchBase>> SearchMultiAsync(string query, string language, int page = 0, bool includeAdult = false, int year = 0, string region = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await SearchMethod<SearchContainer<SearchBase>>("multi", query, page, language, includeAdult, year, "yyyy-MM-dd", region, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await SearchMethodInternal<SearchContainer<SearchBase>>("multi", query, page, language, includeAdult, year, "yyyy-MM-dd", region, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchPerson>> SearchPersonAsync(string query, int page = 0, bool includeAdult = false, string region = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchPerson>> SearchPersonAsync(string query, int page = 0, bool includeAdult = false, string region = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await SearchPersonAsync(query, DefaultLanguage, page, includeAdult, region, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchPerson>> SearchPersonAsync(string query, string language, int page = 0, bool includeAdult = false, string region = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchPerson>> SearchPersonAsync(string query, string language, int page = 0, bool includeAdult = false, string region = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await SearchMethod<SearchContainer<SearchPerson>>("person", query, page, language, includeAdult, region: region, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await SearchMethodInternal<SearchContainer<SearchPerson>>("person", query, page, language, includeAdult, region: region, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchTv>> SearchTvShowAsync(string query, int page = 0, bool includeAdult = false, int firstAirDateYear = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchTv>> SearchTvShowAsync(string query, int page = 0, bool includeAdult = false, int firstAirDateYear = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await SearchTvShowAsync(query, DefaultLanguage, page, includeAdult, firstAirDateYear, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchTv>> SearchTvShowAsync(string query, string language, int page = 0, bool includeAdult = false, int firstAirDateYear = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchTv>> SearchTvShowAsync(string query, string language, int page = 0, bool includeAdult = false, int firstAirDateYear = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await SearchMethod<SearchContainer<SearchTv>>("tv", query, page, language, includeAdult, firstAirDateYear: firstAirDateYear, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await SearchMethodInternal<SearchContainer<SearchTv>>("tv", query, page, language, includeAdult, firstAirDateYear: firstAirDateYear, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public async Task<SearchContainer<SearchMovie>> GetTrendingMoviesAsync(TimeWindow timeWindow, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchMovie>> GetTrendingMoviesAsync(TimeWindow timeWindow, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("trending/movie/{time_window}");
|
||||
req.AddUrlSegment("time_window", timeWindow.ToString());
|
||||
@ -17,12 +17,12 @@ namespace TMDbLib.Client
|
||||
if (page >= 1)
|
||||
req.AddQueryString("page", page.ToString());
|
||||
|
||||
RestResponse<SearchContainer<SearchMovie>> resp = await req.ExecuteGet<SearchContainer<SearchMovie>>(cancellationToken).ConfigureAwait(false);
|
||||
SearchContainer<SearchMovie> resp = await req.GetOfT<SearchContainer<SearchMovie>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchTv>> GetTrendingTvAsync(TimeWindow timeWindow, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchTv>> GetTrendingTvAsync(TimeWindow timeWindow, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("trending/tv/{time_window}");
|
||||
req.AddUrlSegment("time_window", timeWindow.ToString());
|
||||
@ -30,12 +30,12 @@ namespace TMDbLib.Client
|
||||
if (page >= 1)
|
||||
req.AddQueryString("page", page.ToString());
|
||||
|
||||
RestResponse<SearchContainer<SearchTv>> resp = await req.ExecuteGet<SearchContainer<SearchTv>>(cancellationToken).ConfigureAwait(false);
|
||||
SearchContainer<SearchTv> resp = await req.GetOfT<SearchContainer<SearchTv>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchPerson>> GetTrendingPeopleAsync(TimeWindow timeWindow, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchPerson>> GetTrendingPeopleAsync(TimeWindow timeWindow, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("trending/person/{time_window}");
|
||||
req.AddUrlSegment("time_window", timeWindow.ToString());
|
||||
@ -43,7 +43,7 @@ namespace TMDbLib.Client
|
||||
if (page >= 1)
|
||||
req.AddQueryString("page", page.ToString());
|
||||
|
||||
RestResponse<SearchContainer<SearchPerson>> resp = await req.ExecuteGet<SearchContainer<SearchPerson>>(cancellationToken).ConfigureAwait(false);
|
||||
SearchContainer<SearchPerson> resp = await req.GetOfT<SearchContainer<SearchPerson>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace TMDbLib.Client
|
||||
/// <param name="language">If specified the api will attempt to return a localized result. ex: en,it,es </param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
/// <returns>The requested collection of tv episode groups</returns>
|
||||
public async Task<TvGroupCollection> GetTvEpisodeGroupsAsync(string id, string language = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<TvGroupCollection> GetTvEpisodeGroupsAsync(string id, string language = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("tv/episode_group/{id}");
|
||||
req.AddUrlSegment("id", id);
|
||||
@ -23,7 +23,7 @@ namespace TMDbLib.Client
|
||||
if (!string.IsNullOrWhiteSpace(language))
|
||||
req.AddParameter("language", language);
|
||||
|
||||
RestResponse<TvGroupCollection> response = await req.ExecuteGet<TvGroupCollection>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<TvGroupCollection> response = await req.Get<TvGroupCollection>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (!response.IsValid)
|
||||
return null;
|
||||
|
@ -4,7 +4,6 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
using TMDbLib.Objects.Changes;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.TvShows;
|
||||
using TMDbLib.Rest;
|
||||
@ -14,7 +13,29 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public async Task<TvEpisodeAccountState> GetTvEpisodeAccountStateAsync(int tvShowId, int seasonNumber, int episodeNumber, CancellationToken cancellationToken = default(CancellationToken))
|
||||
private async Task<T> GetTvEpisodeMethodInternal<T>(int tvShowId, int seasonNumber, int episodeNumber, TvEpisodeMethods tvShowMethod, string dateFormat = null, string language = null, CancellationToken cancellationToken = default) where T : new()
|
||||
{
|
||||
RestRequest req = _client.Create("tv/{id}/season/{season_number}/episode/{episode_number}/{method}");
|
||||
req.AddUrlSegment("id", tvShowId.ToString(CultureInfo.InvariantCulture));
|
||||
req.AddUrlSegment("season_number", seasonNumber.ToString(CultureInfo.InvariantCulture));
|
||||
req.AddUrlSegment("episode_number", episodeNumber.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
req.AddUrlSegment("method", tvShowMethod.GetDescription());
|
||||
|
||||
// TODO: Dateformat?
|
||||
//if (dateFormat != null)
|
||||
// req.DateFormat = dateFormat;
|
||||
|
||||
language = language ?? DefaultLanguage;
|
||||
if (!string.IsNullOrWhiteSpace(language))
|
||||
req.AddParameter("language", language);
|
||||
|
||||
T resp = await req.GetOfT<T>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
public async Task<TvEpisodeAccountState> GetTvEpisodeAccountStateAsync(int tvShowId, int seasonNumber, int episodeNumber, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
@ -25,7 +46,7 @@ namespace TMDbLib.Client
|
||||
req.AddUrlSegment("method", TvEpisodeMethods.AccountStates.GetDescription());
|
||||
AddSessionId(req, SessionType.UserSession);
|
||||
|
||||
RestResponse<TvEpisodeAccountState> response = await req.ExecuteGet<TvEpisodeAccountState>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<TvEpisodeAccountState> response = await req.Get<TvEpisodeAccountState>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return await response.GetDataObject().ConfigureAwait(false);
|
||||
}
|
||||
@ -40,7 +61,7 @@ namespace TMDbLib.Client
|
||||
/// <param name="language">If specified the api will attempt to return a localized result. ex: en,it,es </param>
|
||||
/// <param name="includeImageLanguage">If specified the api will attempt to return localized image results eg. en,it,es.</param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
public async Task<TvEpisode> GetTvEpisodeAsync(int tvShowId, int seasonNumber, int episodeNumber, TvEpisodeMethods extraMethods = TvEpisodeMethods.Undefined, string language = null, string includeImageLanguage = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<TvEpisode> GetTvEpisodeAsync(int tvShowId, int seasonNumber, int episodeNumber, TvEpisodeMethods extraMethods = TvEpisodeMethods.Undefined, string language = null, string includeImageLanguage = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (extraMethods.HasFlag(TvEpisodeMethods.AccountStates))
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
@ -71,7 +92,7 @@ namespace TMDbLib.Client
|
||||
if (appends != string.Empty)
|
||||
req.AddParameter("append_to_response", appends);
|
||||
|
||||
RestResponse<TvEpisode> response = await req.ExecuteGet<TvEpisode>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<TvEpisode> response = await req.Get<TvEpisode>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (!response.IsValid)
|
||||
return null;
|
||||
@ -98,22 +119,12 @@ namespace TMDbLib.Client
|
||||
return item;
|
||||
}
|
||||
|
||||
public async Task<ChangesContainer> GetTvEpisodeChangesAsync(int episodeId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
RestRequest req = _client.Create("tv/episode/{id}/changes");
|
||||
req.AddUrlSegment("id", episodeId.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
RestResponse<ChangesContainer> response = await req.ExecuteGet<ChangesContainer>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public async Task<ResultContainer<TvEpisodeInfo>> GetTvEpisodesScreenedTheatricallyAsync(int tvShowId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<ResultContainer<TvEpisodeInfo>> GetTvEpisodesScreenedTheatricallyAsync(int tvShowId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("tv/{tv_id}/screened_theatrically");
|
||||
req.AddUrlSegment("tv_id", tvShowId.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
return await req.ExecuteGet<ResultContainer<TvEpisodeInfo>>(cancellationToken).ConfigureAwait(false);
|
||||
return await req.GetOfT<ResultContainer<TvEpisodeInfo>>(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -124,9 +135,9 @@ namespace TMDbLib.Client
|
||||
/// <param name="episodeNumber">The episode number of the episode you want to retrieve information for.</param>
|
||||
/// <param name="language">If specified the api will attempt to return a localized result. ex: en,it,es </param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
public async Task<CreditsWithGuestStars> GetTvEpisodeCreditsAsync(int tvShowId, int seasonNumber, int episodeNumber, string language = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<CreditsWithGuestStars> GetTvEpisodeCreditsAsync(int tvShowId, int seasonNumber, int episodeNumber, string language = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvEpisodeMethod<CreditsWithGuestStars>(tvShowId, seasonNumber, episodeNumber, TvEpisodeMethods.Credits, dateFormat: "yyyy-MM-dd", language: language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetTvEpisodeMethodInternal<CreditsWithGuestStars>(tvShowId, seasonNumber, episodeNumber, TvEpisodeMethods.Credits, dateFormat: "yyyy-MM-dd", language: language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -136,9 +147,9 @@ namespace TMDbLib.Client
|
||||
/// <param name="seasonNumber">The season number of the season the episode belongs to. Note use 0 for specials.</param>
|
||||
/// <param name="episodeNumber">The episode number of the episode you want to retrieve information for.</param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
public async Task<ExternalIdsTvEpisode> GetTvEpisodeExternalIdsAsync(int tvShowId, int seasonNumber, int episodeNumber, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<ExternalIdsTvEpisode> GetTvEpisodeExternalIdsAsync(int tvShowId, int seasonNumber, int episodeNumber, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvEpisodeMethod<ExternalIdsTvEpisode>(tvShowId, seasonNumber, episodeNumber, TvEpisodeMethods.ExternalIds, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetTvEpisodeMethodInternal<ExternalIdsTvEpisode>(tvShowId, seasonNumber, episodeNumber, TvEpisodeMethods.ExternalIds, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -152,39 +163,17 @@ 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<StillImages> GetTvEpisodeImagesAsync(int tvShowId, int seasonNumber, int episodeNumber, string language = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<StillImages> GetTvEpisodeImagesAsync(int tvShowId, int seasonNumber, int episodeNumber, string language = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvEpisodeMethod<StillImages>(tvShowId, seasonNumber, episodeNumber, TvEpisodeMethods.Images, language: language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetTvEpisodeMethodInternal<StillImages>(tvShowId, seasonNumber, episodeNumber, TvEpisodeMethods.Images, language: language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task<T> GetTvEpisodeMethod<T>(int tvShowId, int seasonNumber, int episodeNumber, TvEpisodeMethods tvShowMethod, string dateFormat = null, string language = null, CancellationToken cancellationToken = default(CancellationToken)) where T : new()
|
||||
public async Task<ResultContainer<Video>> GetTvEpisodeVideosAsync(int tvShowId, int seasonNumber, int episodeNumber, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("tv/{id}/season/{season_number}/episode/{episode_number}/{method}");
|
||||
req.AddUrlSegment("id", tvShowId.ToString(CultureInfo.InvariantCulture));
|
||||
req.AddUrlSegment("season_number", seasonNumber.ToString(CultureInfo.InvariantCulture));
|
||||
req.AddUrlSegment("episode_number", episodeNumber.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
req.AddUrlSegment("method", tvShowMethod.GetDescription());
|
||||
|
||||
// TODO: Dateformat?
|
||||
//if (dateFormat != null)
|
||||
// req.DateFormat = dateFormat;
|
||||
|
||||
language = language ?? DefaultLanguage;
|
||||
if (!string.IsNullOrWhiteSpace(language))
|
||||
req.AddParameter("language", language);
|
||||
|
||||
RestResponse<T> resp = await req.ExecuteGet<T>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
return await GetTvEpisodeMethodInternal<ResultContainer<Video>>(tvShowId, seasonNumber, episodeNumber, TvEpisodeMethods.Videos, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<ResultContainer<Video>> GetTvEpisodeVideosAsync(int tvShowId, int seasonNumber, int episodeNumber, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return await GetTvEpisodeMethod<ResultContainer<Video>>(tvShowId, seasonNumber, episodeNumber, TvEpisodeMethods.Videos, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<bool> TvEpisodeRemoveRatingAsync(int tvShowId, int seasonNumber, int episodeNumber, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<bool> TvEpisodeRemoveRatingAsync(int tvShowId, int seasonNumber, int episodeNumber, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RequireSessionId(SessionType.GuestSession);
|
||||
|
||||
@ -195,7 +184,7 @@ namespace TMDbLib.Client
|
||||
|
||||
AddSessionId(req);
|
||||
|
||||
RestResponse<PostReply> response = await req.ExecuteDelete<PostReply>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<PostReply> response = await req.Delete<PostReply>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// status code 13 = "The item/record was deleted successfully."
|
||||
PostReply item = await response.GetDataObject().ConfigureAwait(false);
|
||||
@ -204,7 +193,7 @@ namespace TMDbLib.Client
|
||||
return item.StatusCode == 13;
|
||||
}
|
||||
|
||||
public async Task<bool> TvEpisodeSetRatingAsync(int tvShowId, int seasonNumber, int episodeNumber, double rating, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<bool> TvEpisodeSetRatingAsync(int tvShowId, int seasonNumber, int episodeNumber, double rating, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RequireSessionId(SessionType.GuestSession);
|
||||
|
||||
@ -217,7 +206,7 @@ namespace TMDbLib.Client
|
||||
|
||||
req.SetBody(new { value = rating });
|
||||
|
||||
RestResponse<PostReply> response = await req.ExecutePost<PostReply>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<PostReply> response = await req.Post<PostReply>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// status code 1 = "Success"
|
||||
// status code 12 = "The item/record was updated successfully" - Used when an item was previously rated by the user
|
||||
|
@ -4,7 +4,6 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
using TMDbLib.Objects.Changes;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.TvShows;
|
||||
using TMDbLib.Rest;
|
||||
@ -15,7 +14,27 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public async Task<ResultContainer<TvEpisodeAccountStateWithNumber>> GetTvSeasonAccountStateAsync(int tvShowId, int seasonNumber, CancellationToken cancellationToken = default(CancellationToken))
|
||||
private async Task<T> GetTvSeasonMethodInternal<T>(int tvShowId, int seasonNumber, TvSeasonMethods tvShowMethod, string dateFormat = null, string language = null, CancellationToken cancellationToken = default) where T : new()
|
||||
{
|
||||
RestRequest req = _client.Create("tv/{id}/season/{season_number}/{method}");
|
||||
req.AddUrlSegment("id", tvShowId.ToString(CultureInfo.InvariantCulture));
|
||||
req.AddUrlSegment("season_number", seasonNumber.ToString(CultureInfo.InvariantCulture));
|
||||
req.AddUrlSegment("method", tvShowMethod.GetDescription());
|
||||
|
||||
// TODO: Dateformat?
|
||||
//if (dateFormat != null)
|
||||
// req.DateFormat = dateFormat;
|
||||
|
||||
language = language ?? DefaultLanguage;
|
||||
if (!string.IsNullOrWhiteSpace(language))
|
||||
req.AddParameter("language", language);
|
||||
|
||||
T response = await req.GetOfT<T>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public async Task<ResultContainer<TvEpisodeAccountStateWithNumber>> GetTvSeasonAccountStateAsync(int tvShowId, int seasonNumber, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
@ -25,7 +44,7 @@ namespace TMDbLib.Client
|
||||
req.AddUrlSegment("method", TvEpisodeMethods.AccountStates.GetDescription());
|
||||
AddSessionId(req, SessionType.UserSession);
|
||||
|
||||
RestResponse<ResultContainer<TvEpisodeAccountStateWithNumber>> response = await req.ExecuteGet<ResultContainer<TvEpisodeAccountStateWithNumber>>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<ResultContainer<TvEpisodeAccountStateWithNumber>> response = await req.Get<ResultContainer<TvEpisodeAccountStateWithNumber>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return await response.GetDataObject().ConfigureAwait(false);
|
||||
}
|
||||
@ -40,7 +59,7 @@ namespace TMDbLib.Client
|
||||
/// <param name="includeImageLanguage">If specified the api will attempt to return localized image results eg. en,it,es.</param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
/// <returns>The requested season for the specified tv show</returns>
|
||||
public async Task<TvSeason> GetTvSeasonAsync(int tvShowId, int seasonNumber, TvSeasonMethods extraMethods = TvSeasonMethods.Undefined, string language = null, string includeImageLanguage = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<TvSeason> GetTvSeasonAsync(int tvShowId, int seasonNumber, TvSeasonMethods extraMethods = TvSeasonMethods.Undefined, string language = null, string includeImageLanguage = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (extraMethods.HasFlag(TvSeasonMethods.AccountStates))
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
@ -70,7 +89,7 @@ namespace TMDbLib.Client
|
||||
if (appends != string.Empty)
|
||||
req.AddParameter("append_to_response", appends);
|
||||
|
||||
RestResponse<TvSeason> response = await req.ExecuteGet<TvSeason>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<TvSeason> response = await req.Get<TvSeason>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (!response.IsValid)
|
||||
return null;
|
||||
@ -99,16 +118,6 @@ namespace TMDbLib.Client
|
||||
return item;
|
||||
}
|
||||
|
||||
public async Task<ChangesContainer> GetTvSeasonChangesAsync(int seasonId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
RestRequest req = _client.Create("tv/season/{id}/changes");
|
||||
req.AddUrlSegment("id", seasonId.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
RestResponse<ChangesContainer> response = await req.ExecuteGet<ChangesContainer>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a credits object for the season of the tv show associated with the provided TMDb id.
|
||||
/// </summary>
|
||||
@ -116,9 +125,9 @@ namespace TMDbLib.Client
|
||||
/// <param name="seasonNumber">The season number of the season you want to retrieve information for. Note use 0 for specials.</param>
|
||||
/// <param name="language">If specified the api will attempt to return a localized result. ex: en,it,es </param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
public async Task<Credits> GetTvSeasonCreditsAsync(int tvShowId, int seasonNumber, string language = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<Credits> GetTvSeasonCreditsAsync(int tvShowId, int seasonNumber, string language = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvSeasonMethod<Credits>(tvShowId, seasonNumber, TvSeasonMethods.Credits, dateFormat: "yyyy-MM-dd", language: language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetTvSeasonMethodInternal<Credits>(tvShowId, seasonNumber, TvSeasonMethods.Credits, dateFormat: "yyyy-MM-dd", language: language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -127,9 +136,9 @@ namespace TMDbLib.Client
|
||||
/// <param name="tvShowId">The TMDb id of the target tv show.</param>
|
||||
/// <param name="seasonNumber">The season number of the season you want to retrieve information for. Note use 0 for specials.</param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
public async Task<ExternalIdsTvSeason> GetTvSeasonExternalIdsAsync(int tvShowId, int seasonNumber, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<ExternalIdsTvSeason> GetTvSeasonExternalIdsAsync(int tvShowId, int seasonNumber, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvSeasonMethod<ExternalIdsTvSeason>(tvShowId, seasonNumber, TvSeasonMethods.ExternalIds, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetTvSeasonMethodInternal<ExternalIdsTvSeason>(tvShowId, seasonNumber, TvSeasonMethods.ExternalIds, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -142,34 +151,14 @@ 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<PosterImages> GetTvSeasonImagesAsync(int tvShowId, int seasonNumber, string language = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<PosterImages> GetTvSeasonImagesAsync(int tvShowId, int seasonNumber, string language = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvSeasonMethod<PosterImages>(tvShowId, seasonNumber, TvSeasonMethods.Images, language: language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetTvSeasonMethodInternal<PosterImages>(tvShowId, seasonNumber, TvSeasonMethods.Images, language: language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task<T> GetTvSeasonMethod<T>(int tvShowId, int seasonNumber, TvSeasonMethods tvShowMethod, string dateFormat = null, string language = null, CancellationToken cancellationToken = default(CancellationToken)) where T : new()
|
||||
public async Task<ResultContainer<Video>> GetTvSeasonVideosAsync(int tvShowId, int seasonNumber, string language = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("tv/{id}/season/{season_number}/{method}");
|
||||
req.AddUrlSegment("id", tvShowId.ToString(CultureInfo.InvariantCulture));
|
||||
req.AddUrlSegment("season_number", seasonNumber.ToString(CultureInfo.InvariantCulture));
|
||||
req.AddUrlSegment("method", tvShowMethod.GetDescription());
|
||||
|
||||
// TODO: Dateformat?
|
||||
//if (dateFormat != null)
|
||||
// req.DateFormat = dateFormat;
|
||||
|
||||
language = language ?? DefaultLanguage;
|
||||
if (!string.IsNullOrWhiteSpace(language))
|
||||
req.AddParameter("language", language);
|
||||
|
||||
RestResponse<T> response = await req.ExecuteGet<T>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public async Task<ResultContainer<Video>> GetTvSeasonVideosAsync(int tvShowId, int seasonNumber, string language = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return await GetTvSeasonMethod<ResultContainer<Video>>(tvShowId, seasonNumber, TvSeasonMethods.Videos, language: language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetTvSeasonMethodInternal<ResultContainer<Video>>(tvShowId, seasonNumber, TvSeasonMethods.Videos, language: language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -18,11 +18,53 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public async Task<TvShow> GetLatestTvShowAsync(CancellationToken cancellationToken = default(CancellationToken))
|
||||
private async Task<T> GetTvShowMethodInternal<T>(int id, TvShowMethods tvShowMethod, string dateFormat = null, string language = null, string includeImageLanguage = null, int page = 0, CancellationToken cancellationToken = default) where T : new()
|
||||
{
|
||||
RestRequest req = _client.Create("tv/{id}/{method}");
|
||||
req.AddUrlSegment("id", id.ToString(CultureInfo.InvariantCulture));
|
||||
req.AddUrlSegment("method", tvShowMethod.GetDescription());
|
||||
|
||||
// TODO: Dateformat?
|
||||
//if (dateFormat != null)
|
||||
// req.DateFormat = dateFormat;
|
||||
|
||||
if (page > 0)
|
||||
req.AddParameter("page", page.ToString());
|
||||
|
||||
language = language ?? DefaultLanguage;
|
||||
if (!string.IsNullOrWhiteSpace(language))
|
||||
req.AddParameter("language", language);
|
||||
|
||||
includeImageLanguage = includeImageLanguage ?? DefaultImageLanguage;
|
||||
if (!string.IsNullOrWhiteSpace(includeImageLanguage))
|
||||
req.AddParameter("include_image_language", includeImageLanguage);
|
||||
|
||||
T resp = await req.GetOfT<T>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
private async Task<SearchContainer<SearchTv>> GetTvShowListInternal(int page, string language, string tvShowListType, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("tv/" + tvShowListType);
|
||||
|
||||
language = language ?? DefaultLanguage;
|
||||
if (!string.IsNullOrWhiteSpace(language))
|
||||
req.AddParameter("language", language);
|
||||
|
||||
if (page >= 1)
|
||||
req.AddParameter("page", page.ToString());
|
||||
|
||||
SearchContainer<SearchTv> response = await req.GetOfT<SearchContainer<SearchTv>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
public async Task<TvShow> GetLatestTvShowAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("tv/latest");
|
||||
|
||||
RestResponse<TvShow> resp = await req.ExecuteGet<TvShow>(cancellationToken).ConfigureAwait(false);
|
||||
TvShow resp = await req.GetOfT<TvShow>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
@ -34,7 +76,7 @@ namespace TMDbLib.Client
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
/// <remarks>Requires a valid user session</remarks>
|
||||
/// <exception cref="UserSessionRequiredException">Thrown when the current client object doens't have a user session assigned.</exception>
|
||||
public async Task<AccountState> GetTvShowAccountStateAsync(int tvShowId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<AccountState> GetTvShowAccountStateAsync(int tvShowId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
@ -43,14 +85,14 @@ namespace TMDbLib.Client
|
||||
req.AddUrlSegment("method", TvShowMethods.AccountStates.GetDescription());
|
||||
AddSessionId(req, SessionType.UserSession);
|
||||
|
||||
RestResponse<AccountState> response = await req.ExecuteGet<AccountState>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<AccountState> response = await req.Get<AccountState>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return await response.GetDataObject().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<ResultContainer<AlternativeTitle>> GetTvShowAlternativeTitlesAsync(int id, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<ResultContainer<AlternativeTitle>> GetTvShowAlternativeTitlesAsync(int id, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvShowMethod<ResultContainer<AlternativeTitle>>(id, TvShowMethods.AlternativeTitles, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetTvShowMethodInternal<ResultContainer<AlternativeTitle>>(id, TvShowMethods.AlternativeTitles, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -62,7 +104,7 @@ namespace TMDbLib.Client
|
||||
/// <param name="includeImageLanguage">If specified the api will attempt to return localized image results eg. en,it,es.</param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
/// <returns>The requested Tv Show</returns>
|
||||
public async Task<TvShow> GetTvShowAsync(int id, TvShowMethods extraMethods = TvShowMethods.Undefined, string language = null, string includeImageLanguage = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<TvShow> GetTvShowAsync(int id, TvShowMethods extraMethods = TvShowMethods.Undefined, string language = null, string includeImageLanguage = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (extraMethods.HasFlag(TvShowMethods.AccountStates))
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
@ -90,7 +132,7 @@ namespace TMDbLib.Client
|
||||
if (appends != string.Empty)
|
||||
req.AddParameter("append_to_response", appends);
|
||||
|
||||
RestResponse<TvShow> response = await req.ExecuteGet<TvShow>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<TvShow> response = await req.Get<TvShow>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (!response.IsValid)
|
||||
return null;
|
||||
@ -117,14 +159,14 @@ namespace TMDbLib.Client
|
||||
return item;
|
||||
}
|
||||
|
||||
public async Task<ChangesContainer> GetTvShowChangesAsync(int id, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<ChangesContainer> GetTvShowChangesAsync(int id, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvShowMethod<ChangesContainer>(id, TvShowMethods.Changes, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetTvShowMethodInternal<ChangesContainer>(id, TvShowMethods.Changes, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<ResultContainer<ContentRating>> GetTvShowContentRatingsAsync(int id, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<ResultContainer<ContentRating>> GetTvShowContentRatingsAsync(int id, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvShowMethod<ResultContainer<ContentRating>>(id, TvShowMethods.ContentRatings, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetTvShowMethodInternal<ResultContainer<ContentRating>>(id, TvShowMethods.ContentRatings, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -133,9 +175,9 @@ namespace TMDbLib.Client
|
||||
/// <param name="id">The TMDb id of the target tv show.</param>
|
||||
/// <param name="language">If specified the api will attempt to return a localized result. ex: en,it,es </param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
public async Task<Credits> GetTvShowCreditsAsync(int id, string language = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<Credits> GetTvShowCreditsAsync(int id, string language = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvShowMethod<Credits>(id, TvShowMethods.Credits, "yyyy-MM-dd", language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetTvShowMethodInternal<Credits>(id, TvShowMethods.Credits, "yyyy-MM-dd", language, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -143,9 +185,9 @@ namespace TMDbLib.Client
|
||||
/// </summary>
|
||||
/// <param name="id">The TMDb id of the target tv show.</param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
public async Task<ExternalIdsTvShow> GetTvShowExternalIdsAsync(int id, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<ExternalIdsTvShow> GetTvShowExternalIdsAsync(int id, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvShowMethod<ExternalIdsTvShow>(id, TvShowMethods.ExternalIds, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetTvShowMethodInternal<ExternalIdsTvShow>(id, TvShowMethods.ExternalIds, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -157,35 +199,19 @@ 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, string includeImageLanguage = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<ImagesWithId> GetTvShowImagesAsync(int id, string language = null, string includeImageLanguage = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvShowMethod<ImagesWithId>(id, TvShowMethods.Images, language: language, includeImageLanguage: includeImageLanguage, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetTvShowMethodInternal<ImagesWithId>(id, TvShowMethods.Images, language: language, includeImageLanguage: includeImageLanguage, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainerWithId<ReviewBase>> GetTvShowReviewsAsync(int id, string language = null, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainerWithId<ReviewBase>> GetTvShowReviewsAsync(int id, string language = null, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvShowMethod<SearchContainerWithId<ReviewBase>>(id, TvShowMethods.Reviews, language: language, page: page, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetTvShowMethodInternal<SearchContainerWithId<ReviewBase>>(id, TvShowMethods.Reviews, language: language, page: page, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<ResultContainer<Keyword>> GetTvShowKeywordsAsync(int id, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<ResultContainer<Keyword>> GetTvShowKeywordsAsync(int id, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvShowMethod<ResultContainer<Keyword>>(id, TvShowMethods.Keywords, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task<SearchContainer<SearchTv>> GetTvShowListAsync(int page, string language, string tvShowListType, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
RestRequest req = _client.Create("tv/" + tvShowListType);
|
||||
|
||||
language = language ?? DefaultLanguage;
|
||||
if (!string.IsNullOrWhiteSpace(language))
|
||||
req.AddParameter("language", language);
|
||||
|
||||
if (page >= 1)
|
||||
req.AddParameter("page", page.ToString());
|
||||
|
||||
RestResponse<SearchContainer<SearchTv>> response = await req.ExecuteGet<SearchContainer<SearchTv>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return response;
|
||||
return await GetTvShowMethodInternal<ResultContainer<Keyword>>(id, TvShowMethods.Keywords, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -196,7 +222,7 @@ namespace TMDbLib.Client
|
||||
/// <param name="timezone">Only relevant for list type AiringToday</param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
/// <returns></returns>
|
||||
public async Task<SearchContainer<SearchTv>> GetTvShowListAsync(TvShowListType list, int page = 0, string timezone = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchTv>> GetTvShowListAsync(TvShowListType list, int page = 0, string timezone = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvShowListAsync(list, DefaultLanguage, page, timezone, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
@ -210,7 +236,7 @@ namespace TMDbLib.Client
|
||||
/// <param name="timezone">Only relevant for list type AiringToday</param>
|
||||
/// <param name="cancellationToken">A cancellation token</param>
|
||||
/// <returns></returns>
|
||||
public async Task<SearchContainer<SearchTv>> GetTvShowListAsync(TvShowListType list, string language, int page = 0, string timezone = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchTv>> GetTvShowListAsync(TvShowListType list, string language, int page = 0, string timezone = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RestRequest req = _client.Create("tv/{method}");
|
||||
req.AddUrlSegment("method", list.GetDescription());
|
||||
@ -225,33 +251,7 @@ namespace TMDbLib.Client
|
||||
if (!string.IsNullOrWhiteSpace(language))
|
||||
req.AddParameter("language", language);
|
||||
|
||||
RestResponse<SearchContainer<SearchTv>> resp = await req.ExecuteGet<SearchContainer<SearchTv>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
|
||||
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));
|
||||
req.AddUrlSegment("method", tvShowMethod.GetDescription());
|
||||
|
||||
// TODO: Dateformat?
|
||||
//if (dateFormat != null)
|
||||
// req.DateFormat = dateFormat;
|
||||
|
||||
if (page > 0)
|
||||
req.AddParameter("page", page.ToString());
|
||||
|
||||
language = language ?? DefaultLanguage;
|
||||
if (!string.IsNullOrWhiteSpace(language))
|
||||
req.AddParameter("language", language);
|
||||
|
||||
includeImageLanguage = includeImageLanguage ?? DefaultImageLanguage;
|
||||
if (!string.IsNullOrWhiteSpace(includeImageLanguage))
|
||||
req.AddParameter("include_image_language", includeImageLanguage);
|
||||
|
||||
RestResponse<T> resp = await req.ExecuteGet<T>(cancellationToken).ConfigureAwait(false);
|
||||
SearchContainer<SearchTv> resp = await req.GetOfT<SearchContainer<SearchTv>>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return resp;
|
||||
}
|
||||
@ -263,29 +263,29 @@ namespace TMDbLib.Client
|
||||
/// Returns the basic information about a tv show.
|
||||
/// For additional data use the main GetTvShowAsync method using the tv show id as parameter.
|
||||
/// </returns>
|
||||
public async Task<SearchContainer<SearchTv>> GetTvShowPopularAsync(int page = -1, string language = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchTv>> GetTvShowPopularAsync(int page = -1, string language = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvShowListAsync(page, language, "popular", cancellationToken).ConfigureAwait(false);
|
||||
return await GetTvShowListInternal(page, language, "popular", cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchTv>> GetTvShowSimilarAsync(int id, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchTv>> GetTvShowSimilarAsync(int id, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvShowSimilarAsync(id, DefaultLanguage, page, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchTv>> GetTvShowSimilarAsync(int id, string language, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchTv>> GetTvShowSimilarAsync(int id, string language, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvShowMethod<SearchContainer<SearchTv>>(id, TvShowMethods.Similar, language: language, page: page, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetTvShowMethodInternal<SearchContainer<SearchTv>>(id, TvShowMethods.Similar, language: language, page: page, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchTv>> GetTvShowRecommendationsAsync(int id, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchTv>> GetTvShowRecommendationsAsync(int id, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvShowRecommendationsAsync(id, DefaultLanguage, page, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<SearchTv>> GetTvShowRecommendationsAsync(int id, string language, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchTv>> GetTvShowRecommendationsAsync(int id, string language, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvShowMethod<SearchContainer<SearchTv>>(id, TvShowMethods.Recommendations, language: language, page: page, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetTvShowMethodInternal<SearchContainer<SearchTv>>(id, TvShowMethods.Recommendations, language: language, page: page, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -295,27 +295,27 @@ namespace TMDbLib.Client
|
||||
/// Returns the basic information about a tv show.
|
||||
/// For additional data use the main GetTvShowAsync method using the tv show id as parameter
|
||||
/// </returns>
|
||||
public async Task<SearchContainer<SearchTv>> GetTvShowTopRatedAsync(int page = -1, string language = null, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<SearchTv>> GetTvShowTopRatedAsync(int page = -1, string language = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvShowListAsync(page, language, "top_rated", cancellationToken).ConfigureAwait(false);
|
||||
return await GetTvShowListInternal(page, language, "top_rated", cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<TranslationsContainerTv> GetTvShowTranslationsAsync(int id, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<TranslationsContainerTv> GetTvShowTranslationsAsync(int id, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvShowMethod<TranslationsContainerTv>(id, TvShowMethods.Translations, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetTvShowMethodInternal<TranslationsContainerTv>(id, TvShowMethods.Translations, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<ResultContainer<Video>> GetTvShowVideosAsync(int id, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<ResultContainer<Video>> GetTvShowVideosAsync(int id, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvShowMethod<ResultContainer<Video>>(id, TvShowMethods.Videos, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetTvShowMethodInternal<ResultContainer<Video>>(id, TvShowMethods.Videos, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SingleResultContainer<Dictionary<string, WatchProviders>>> GetTvShowWatchProvidersAsync(int id, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SingleResultContainer<Dictionary<string, WatchProviders>>> GetTvShowWatchProvidersAsync(int id, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await GetTvShowMethod<SingleResultContainer<Dictionary<string, WatchProviders>>>(id, TvShowMethods.WatchProviders, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
return await GetTvShowMethodInternal<SingleResultContainer<Dictionary<string, WatchProviders>>>(id, TvShowMethods.WatchProviders, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<bool> TvShowRemoveRatingAsync(int tvShowId, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<bool> TvShowRemoveRatingAsync(int tvShowId, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RequireSessionId(SessionType.GuestSession);
|
||||
|
||||
@ -323,7 +323,7 @@ namespace TMDbLib.Client
|
||||
req.AddUrlSegment("tvShowId", tvShowId.ToString(CultureInfo.InvariantCulture));
|
||||
AddSessionId(req);
|
||||
|
||||
RestResponse<PostReply> response = await req.ExecuteDelete<PostReply>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<PostReply> response = await req.Delete<PostReply>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// status code 13 = "The item/record was deleted successfully."
|
||||
PostReply item = await response.GetDataObject().ConfigureAwait(false);
|
||||
@ -341,7 +341,7 @@ namespace TMDbLib.Client
|
||||
/// <returns>True if the the tv show's rating was successfully updated, false if not</returns>
|
||||
/// <remarks>Requires a valid guest or user session</remarks>
|
||||
/// <exception cref="GuestSessionRequiredException">Thrown when the current client object doens't have a guest or user session assigned.</exception>
|
||||
public async Task<bool> TvShowSetRatingAsync(int tvShowId, double rating, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<bool> TvShowSetRatingAsync(int tvShowId, double rating, CancellationToken cancellationToken = default)
|
||||
{
|
||||
RequireSessionId(SessionType.GuestSession);
|
||||
|
||||
@ -351,7 +351,7 @@ namespace TMDbLib.Client
|
||||
|
||||
req.SetBody(new { value = rating });
|
||||
|
||||
RestResponse<PostReply> response = await req.ExecutePost<PostReply>(cancellationToken).ConfigureAwait(false);
|
||||
RestResponse<PostReply> response = await req.Post<PostReply>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// status code 1 = "Success"
|
||||
// status code 12 = "The item/record was updated successfully" - Used when an item was previously rated by the user
|
||||
|
@ -19,12 +19,12 @@ namespace TMDbLib.Objects.Discover
|
||||
Parameters = new SimpleNamedValueCollection();
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<T>> Query(int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<T>> Query(int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await Query(_client.DefaultLanguage, page, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<SearchContainer<T>> Query(string language, int page = 0, CancellationToken cancellationToken = default(CancellationToken))
|
||||
public async Task<SearchContainer<T>> Query(string language, int page = 0, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return await _client.DiscoverPerformAsync<T>(_endpoint, language, page, Parameters, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
@ -1,11 +1,9 @@
|
||||
using System;
|
||||
using TMDbLib.Utilities;
|
||||
using TMDbLib.Utilities;
|
||||
|
||||
namespace TMDbLib.Objects.Discover
|
||||
{
|
||||
public enum DiscoverMovieSortBy
|
||||
{
|
||||
[Obsolete]
|
||||
Undefined,
|
||||
[EnumValue("popularity.asc")]
|
||||
Popularity,
|
||||
|
@ -1,11 +1,9 @@
|
||||
using System;
|
||||
using TMDbLib.Utilities;
|
||||
using TMDbLib.Utilities;
|
||||
|
||||
namespace TMDbLib.Objects.Discover
|
||||
{
|
||||
public enum DiscoverTvShowSortBy
|
||||
{
|
||||
[Obsolete]
|
||||
Undefined,
|
||||
[EnumValue("vote_average.asc")]
|
||||
VoteAverage,
|
||||
|
@ -3,7 +3,7 @@ using TMDbLib.Objects.General;
|
||||
|
||||
namespace TMDbLib.Objects.Lists
|
||||
{
|
||||
public class AccountList : List
|
||||
public class AccountList : TMDbList<int>
|
||||
{
|
||||
[JsonProperty("list_type")]
|
||||
public MediaType ListType { get; set; }
|
||||
|
@ -4,7 +4,7 @@ using TMDbLib.Objects.Search;
|
||||
|
||||
namespace TMDbLib.Objects.Lists
|
||||
{
|
||||
public class GenericList : List
|
||||
public class GenericList : TMDbList<string>
|
||||
{
|
||||
[JsonProperty("created_by")]
|
||||
public string CreatedBy { get; set; }
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace TMDbLib.Objects.Lists
|
||||
{
|
||||
public class List
|
||||
public abstract class TMDbList<TId>
|
||||
{
|
||||
[JsonProperty("description")]
|
||||
public string Description { get; set; }
|
||||
@ -11,7 +11,7 @@ namespace TMDbLib.Objects.Lists
|
||||
public int FavoriteCount { get; set; }
|
||||
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
public TId Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A language code, e.g. en
|
@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using TMDbLib.Objects.General;
|
||||
|
||||
namespace TMDbLib.Objects.Movies
|
||||
{
|
||||
@ -22,6 +23,9 @@ namespace TMDbLib.Objects.Movies
|
||||
[JsonProperty("item_Count")]
|
||||
public int ItemCount { get; set; }
|
||||
|
||||
[JsonProperty("list_type")]
|
||||
public MediaType ListType { get; set; }
|
||||
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.People;
|
||||
|
||||
namespace TMDbLib.Objects.Search
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using TMDbLib.Objects.General;
|
||||
|
||||
|
@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using TMDbLib.Objects.General;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace TMDbLib.Objects.TvShows
|
||||
{
|
||||
|
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TMDbLib.Objects.TvShows
|
||||
namespace TMDbLib.Objects.TvShows
|
||||
{
|
||||
public enum TvGroupType
|
||||
{
|
||||
|
@ -86,42 +86,42 @@ namespace TMDbLib.Rest
|
||||
AppendQueryString(sb, value.Key, value.Value);
|
||||
}
|
||||
|
||||
public async Task<RestResponse> ExecuteDelete(CancellationToken cancellationToken)
|
||||
public async Task<RestResponse> Delete(CancellationToken cancellationToken)
|
||||
{
|
||||
HttpResponseMessage resp = await SendInternal(HttpMethod.Delete, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return new RestResponse(resp);
|
||||
}
|
||||
|
||||
public async Task<RestResponse<T>> ExecuteDelete<T>(CancellationToken cancellationToken)
|
||||
public async Task<RestResponse<T>> Delete<T>(CancellationToken cancellationToken)
|
||||
{
|
||||
HttpResponseMessage resp = await SendInternal(HttpMethod.Delete, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return new RestResponse<T>(resp, _client);
|
||||
}
|
||||
|
||||
public async Task<RestResponse> ExecuteGet(CancellationToken cancellationToken)
|
||||
public async Task<RestResponse> Get(CancellationToken cancellationToken)
|
||||
{
|
||||
HttpResponseMessage resp = await SendInternal(HttpMethod.Get, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return new RestResponse(resp);
|
||||
}
|
||||
|
||||
public async Task<RestResponse<T>> ExecuteGet<T>(CancellationToken cancellationToken)
|
||||
public async Task<RestResponse<T>> Get<T>(CancellationToken cancellationToken)
|
||||
{
|
||||
HttpResponseMessage resp = await SendInternal(HttpMethod.Get, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return new RestResponse<T>(resp, _client);
|
||||
}
|
||||
|
||||
public async Task<RestResponse> ExecutePost(CancellationToken cancellationToken)
|
||||
public async Task<RestResponse> Post(CancellationToken cancellationToken)
|
||||
{
|
||||
HttpResponseMessage resp = await SendInternal(HttpMethod.Post, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return new RestResponse(resp);
|
||||
}
|
||||
|
||||
public async Task<RestResponse<T>> ExecutePost<T>(CancellationToken cancellationToken)
|
||||
public async Task<RestResponse<T>> Post<T>(CancellationToken cancellationToken)
|
||||
{
|
||||
HttpResponseMessage resp = await SendInternal(HttpMethod.Post, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
|
38
TMDbLib/Rest/RestRequestExtensions.cs
Normal file
38
TMDbLib/Rest/RestRequestExtensions.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TMDbLib.Rest
|
||||
{
|
||||
internal static class RestRequestExtensions
|
||||
{
|
||||
public static async Task<T> DeleteOfT<T>(this RestRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
RestResponse<T> resp = await request.Delete<T>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (!resp.IsValid)
|
||||
return default;
|
||||
|
||||
return await resp.GetDataObject().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public static async Task<T> GetOfT<T>(this RestRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
RestResponse<T> resp = await request.Get<T>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (!resp.IsValid)
|
||||
return default;
|
||||
|
||||
return await resp.GetDataObject().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public static async Task<T> PostOfT<T>(this RestRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
RestResponse<T> resp = await request.Post<T>(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (!resp.IsValid)
|
||||
return default;
|
||||
|
||||
return await resp.GetDataObject().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
@ -50,20 +49,5 @@ namespace TMDbLib.Rest
|
||||
using (JsonTextReader tr = new JsonTextReader(sr))
|
||||
return _client.Serializer.Deserialize<T>(tr);
|
||||
}
|
||||
|
||||
public static implicit operator T(RestResponse<T> response)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (response.IsValid)
|
||||
return response.GetDataObject().Result;
|
||||
|
||||
return default(T);
|
||||
}
|
||||
catch (AggregateException ex)
|
||||
{
|
||||
throw ex.InnerException;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -33,6 +33,9 @@ namespace TMDbLib.Utilities.Converters
|
||||
return new List<int>();
|
||||
}
|
||||
|
||||
if (reader.TokenType == JsonToken.Null)
|
||||
return null;
|
||||
|
||||
throw new Exception("Unable to convert list of integers");
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace TMDbLib.Utilities.Converters
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
var date = value as DateTime?;
|
||||
DateTime? date = value as DateTime?;
|
||||
writer.WriteValue(date?.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ namespace TMDbLib.Utilities
|
||||
}
|
||||
}
|
||||
|
||||
return default(T);
|
||||
return default;
|
||||
}
|
||||
|
||||
public static object GetValue(string input, Type type)
|
||||
|
@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Account;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Lists;
|
||||
@ -15,375 +15,267 @@ namespace TMDbLibTests
|
||||
{
|
||||
public class ClientAccountTests : TestBase
|
||||
{
|
||||
public ClientAccountTests() : base()
|
||||
public ClientAccountTests()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Config.UserSessionId))
|
||||
if (string.IsNullOrWhiteSpace(TestConfig.UserSessionId))
|
||||
throw new ConfigurationErrorsException("To successfully complete the ClientAccountTests you will need to specify a valid 'UserSessionId' in the test config file");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAccountGetDetailsGuestAccount()
|
||||
public async Task TestAccountGetDetailsGuestAccount()
|
||||
{
|
||||
Config.Client.SetSessionInformation(Config.GuestTestSessionId, SessionType.GuestSession);
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.GuestTestSessionId, SessionType.GuestSession);
|
||||
|
||||
Assert.Throws<UserSessionRequiredException>(() => Config.Client.AccountGetDetailsAsync().Sync());
|
||||
await Assert.ThrowsAsync<UserSessionRequiredException>(() => TMDbClient.AccountGetDetailsAsync());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAccountGetDetailsUserAccount()
|
||||
public async Task TestAccountGetDetailsUserAccount()
|
||||
{
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
AccountDetails account = Config.Client.AccountGetDetailsAsync().Sync();
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Naturally the specified account must have these values populated for the test to pass
|
||||
Assert.NotNull(account);
|
||||
Assert.True(account.Id > 1);
|
||||
Assert.Equal("Test Name", account.Name);
|
||||
Assert.Equal("TMDbTestAccount", account.Username);
|
||||
Assert.Equal("BE", account.Iso_3166_1);
|
||||
Assert.Equal("en", account.Iso_639_1);
|
||||
|
||||
Assert.NotNull(account.Avatar);
|
||||
Assert.NotNull(account.Avatar.Gravatar);
|
||||
Assert.Equal("7cf5357dbc2014cbd616257c358ea0a1", account.Avatar.Gravatar.Hash);
|
||||
await Verify(TMDbClient.ActiveAccount);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAccountAccountGetLists()
|
||||
public async Task TestAccountAccountGetLists()
|
||||
{
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
TestHelpers.SearchPages(i => Config.Client.AccountGetListsAsync(i).Result);
|
||||
AccountList list = Config.Client.AccountGetListsAsync().Sync().Results[0];
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
Assert.NotNull(list.Id);
|
||||
Assert.NotNull(list.Name);
|
||||
Assert.Null(list.PosterPath);
|
||||
Assert.NotNull(list.Description);
|
||||
Assert.NotNull(list.ListType);
|
||||
Assert.NotNull(list.Iso_639_1);
|
||||
SearchContainer<AccountList> result = await TMDbClient.AccountGetListsAsync();
|
||||
|
||||
Assert.NotEmpty(result.Results);
|
||||
|
||||
AccountList single = result.Results.Single(s => s.Id == 1724);
|
||||
|
||||
await Verify(single);
|
||||
}
|
||||
|
||||
[Fact(Skip = "TMDb has an issue in pagination of AccountGetListsAsync")]
|
||||
public async Task TestAccountAccountGetListsPaged()
|
||||
{
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
await TestHelpers.SearchPagesAsync(i => TMDbClient.AccountGetListsAsync(i));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAccountGetFavoriteMovies()
|
||||
public async Task TestAccountGetFavoriteMovies()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
TestHelpers.SearchPages(i => Config.Client.AccountGetFavoriteMoviesAsync(i).Result);
|
||||
SearchMovie movie = Config.Client.AccountGetFavoriteMoviesAsync().Sync().Results[0];
|
||||
await TestHelpers.SearchPagesAsync(i => TMDbClient.AccountGetFavoriteMoviesAsync(i));
|
||||
|
||||
// Requires that you have marked at least one movie as favorite else this test will fail
|
||||
Assert.True(movie.Id > 0);
|
||||
Assert.NotNull(movie.Title);
|
||||
Assert.NotNull(movie.PosterPath);
|
||||
Assert.NotNull(movie.BackdropPath);
|
||||
Assert.NotNull(movie.OriginalTitle);
|
||||
Assert.NotNull(movie.Overview);
|
||||
Assert.NotNull(movie.OriginalLanguage);
|
||||
Assert.NotNull(movie.ReleaseDate);
|
||||
Assert.True(movie.VoteCount > 0);
|
||||
Assert.True(movie.VoteAverage > 0);
|
||||
Assert.True(movie.Popularity > 0);
|
||||
SearchContainer<SearchMovie> movies = await TMDbClient.AccountGetFavoriteMoviesAsync();
|
||||
SearchMovie movie = movies.Results.Single(s => s.Id == IdHelper.Avatar);
|
||||
|
||||
Assert.NotNull(movie.GenreIds);
|
||||
Assert.True(movie.GenreIds.Any());
|
||||
await Verify(movie, x => x.IgnoreProperty<SearchMovie>(n => n.VoteCount, n => n.Popularity));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAccountGetFavoriteTv()
|
||||
public async Task TestAccountGetFavoriteTv()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
TestHelpers.SearchPages(i => Config.Client.AccountGetFavoriteTvAsync(i).Result);
|
||||
SearchTv tvShow = Config.Client.AccountGetFavoriteTvAsync().Sync().Results[0];
|
||||
await TestHelpers.SearchPagesAsync(i => TMDbClient.AccountGetFavoriteTvAsync(i));
|
||||
|
||||
// Requires that you have marked at least one movie as favorite else this test will fail
|
||||
Assert.True(tvShow.Id > 0);
|
||||
Assert.NotNull(tvShow.Name);
|
||||
Assert.NotNull(tvShow.PosterPath);
|
||||
Assert.NotNull(tvShow.BackdropPath);
|
||||
Assert.NotNull(tvShow.OriginalName);
|
||||
Assert.NotNull(tvShow.Overview);
|
||||
Assert.NotNull(tvShow.OriginalLanguage);
|
||||
Assert.NotNull(tvShow.FirstAirDate);
|
||||
Assert.True(tvShow.VoteCount > 0);
|
||||
Assert.True(tvShow.VoteAverage > 0);
|
||||
Assert.True(tvShow.Popularity > 0);
|
||||
SearchContainer<SearchTv> tvShows = await TMDbClient.AccountGetFavoriteTvAsync();
|
||||
SearchTv tvShow = tvShows.Results.Single(s => s.Id == IdHelper.BreakingBad);
|
||||
|
||||
Assert.NotNull(tvShow.GenreIds);
|
||||
Assert.True(tvShow.GenreIds.Any());
|
||||
await Verify(tvShow);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAccountGetMovieWatchlist()
|
||||
public async Task TestAccountGetMovieWatchlist()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
TestHelpers.SearchPages(i => Config.Client.AccountGetFavoriteMoviesAsync(i).Result);
|
||||
SearchMovie movie = Config.Client.AccountGetFavoriteMoviesAsync().Sync().Results[0];
|
||||
await TestHelpers.SearchPagesAsync(i => TMDbClient.AccountGetMovieWatchlistAsync(i));
|
||||
|
||||
// Requires that you have added at least one movie to your watchlist else this test will fail
|
||||
Assert.True(movie.Id > 0);
|
||||
Assert.NotNull(movie.Title);
|
||||
Assert.NotNull(movie.PosterPath);
|
||||
Assert.NotNull(movie.BackdropPath);
|
||||
Assert.NotNull(movie.OriginalTitle);
|
||||
Assert.NotNull(movie.Overview);
|
||||
Assert.NotNull(movie.OriginalLanguage);
|
||||
Assert.NotNull(movie.ReleaseDate);
|
||||
Assert.True(movie.VoteCount > 0);
|
||||
Assert.True(movie.VoteAverage > 0);
|
||||
Assert.True(movie.Popularity > 0);
|
||||
SearchContainer<SearchMovie> watchlist = await TMDbClient.AccountGetMovieWatchlistAsync();
|
||||
SearchMovie movie = watchlist.Results.Single(s => s.Id == 100042);
|
||||
|
||||
Assert.NotNull(movie.GenreIds);
|
||||
Assert.True(movie.GenreIds.Any());
|
||||
await Verify(movie);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAccountGetTvWatchlist()
|
||||
public async Task TestAccountGetTvWatchlist()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
TestHelpers.SearchPages(i => Config.Client.AccountGetTvWatchlistAsync(i).Result);
|
||||
SearchTv tvShow = Config.Client.AccountGetTvWatchlistAsync().Sync().Results[0];
|
||||
await TestHelpers.SearchPagesAsync(i => TMDbClient.AccountGetTvWatchlistAsync(i));
|
||||
|
||||
// Requires that you have added at least one movie to your watchlist else this test will fail
|
||||
Assert.True(tvShow.Id > 0);
|
||||
Assert.NotNull(tvShow.Name);
|
||||
Assert.NotNull(tvShow.PosterPath);
|
||||
Assert.NotNull(tvShow.BackdropPath);
|
||||
Assert.NotNull(tvShow.OriginalName);
|
||||
Assert.NotNull(tvShow.Overview);
|
||||
Assert.NotNull(tvShow.OriginalLanguage);
|
||||
Assert.NotNull(tvShow.FirstAirDate);
|
||||
Assert.True(tvShow.VoteCount > 0);
|
||||
Assert.True(tvShow.VoteAverage > 0);
|
||||
Assert.True(tvShow.Popularity > 0);
|
||||
SearchContainer<SearchTv> tvShows = await TMDbClient.AccountGetTvWatchlistAsync();
|
||||
SearchTv tvShow = tvShows.Results.Single(s => s.Id == 2691);
|
||||
|
||||
Assert.NotNull(tvShow.GenreIds);
|
||||
Assert.True(tvShow.GenreIds.Any());
|
||||
await Verify(tvShow);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAccountGetRatedMovies()
|
||||
public async Task TestAccountGetRatedMovies()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
TestHelpers.SearchPages(i => Config.Client.AccountGetFavoriteMoviesAsync(i).Result);
|
||||
SearchMovie movie = Config.Client.AccountGetFavoriteMoviesAsync().Sync().Results[0];
|
||||
await TestHelpers.SearchPagesAsync(i => TMDbClient.AccountGetFavoriteMoviesAsync(i));
|
||||
|
||||
// Requires that you have rated at least one movie else this test will fail
|
||||
Assert.True(movie.Id > 0);
|
||||
Assert.NotNull(movie.Title);
|
||||
Assert.NotNull(movie.PosterPath);
|
||||
Assert.NotNull(movie.BackdropPath);
|
||||
Assert.NotNull(movie.OriginalTitle);
|
||||
Assert.NotNull(movie.Overview);
|
||||
Assert.NotNull(movie.OriginalLanguage);
|
||||
Assert.NotNull(movie.ReleaseDate);
|
||||
Assert.True(movie.VoteCount > 0);
|
||||
Assert.True(movie.VoteAverage > 0);
|
||||
Assert.True(movie.Popularity > 0);
|
||||
SearchContainer<SearchMovie> movies = await TMDbClient.AccountGetFavoriteMoviesAsync();
|
||||
SearchMovie movie = movies.Results.Single(s => s.Id == IdHelper.Avatar);
|
||||
|
||||
Assert.NotNull(movie.GenreIds);
|
||||
Assert.True(movie.GenreIds.Any());
|
||||
await Verify(movie);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAccountGetRatedTv()
|
||||
public async Task TestAccountGetRatedTv()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
TestHelpers.SearchPages(i => Config.Client.AccountGetRatedTvShowsAsync(i).Result);
|
||||
AccountSearchTv tvShow = Config.Client.AccountGetRatedTvShowsAsync().Sync().Results[0];
|
||||
await TestHelpers.SearchPagesAsync(i => TMDbClient.AccountGetRatedTvShowsAsync(i));
|
||||
|
||||
// Requires that you have rated at least one movie else this test will fail
|
||||
Assert.True(tvShow.Id > 0);
|
||||
Assert.NotNull(tvShow.Name);
|
||||
Assert.NotNull(tvShow.PosterPath);
|
||||
Assert.NotNull(tvShow.BackdropPath);
|
||||
Assert.NotNull(tvShow.OriginalName);
|
||||
Assert.NotNull(tvShow.Overview);
|
||||
Assert.NotNull(tvShow.OriginalLanguage);
|
||||
Assert.NotNull(tvShow.FirstAirDate);
|
||||
Assert.True(tvShow.VoteCount > 0);
|
||||
Assert.True(tvShow.VoteAverage > 0);
|
||||
Assert.True(tvShow.Popularity > 0);
|
||||
SearchContainer<AccountSearchTv> tvShows = await TMDbClient.AccountGetRatedTvShowsAsync();
|
||||
AccountSearchTv tvShow = tvShows.Results.Single(s => s.Id == IdHelper.BigBangTheory);
|
||||
|
||||
Assert.NotNull(tvShow.GenreIds);
|
||||
Assert.True(tvShow.GenreIds.Any());
|
||||
await Verify(tvShow);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAccountGetRatedTvEpisodes()
|
||||
public async Task TestAccountGetRatedTvEpisodes()
|
||||
{
|
||||
IgnoreMissingCSharp("results[array]._id / _id");
|
||||
|
||||
// TODO: Error in TMDb: https://www.themoviedb.org/talk/557f1af49251410a2c002480
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
TestHelpers.SearchPages(i => Config.Client.AccountGetRatedTvShowEpisodesAsync(i).Result);
|
||||
AccountSearchTvEpisode tvEpisode = Config.Client.AccountGetRatedTvShowEpisodesAsync().Sync().Results[0];
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Requires that you have rated at least one movie else this test will fail
|
||||
Assert.True(tvEpisode.Id > 0);
|
||||
Assert.True(tvEpisode.ShowId > 0);
|
||||
Assert.True(tvEpisode.EpisodeNumber > 0);
|
||||
Assert.True(tvEpisode.SeasonNumber > 0);
|
||||
Assert.NotNull(tvEpisode.Name);
|
||||
Assert.NotNull(tvEpisode.AirDate);
|
||||
Assert.NotNull(tvEpisode.StillPath);
|
||||
Assert.True(tvEpisode.VoteCount > 0);
|
||||
Assert.True(tvEpisode.VoteAverage > 0);
|
||||
Assert.True(tvEpisode.Rating > 0);
|
||||
await TestHelpers.SearchPagesAsync(i => TMDbClient.AccountGetRatedTvShowEpisodesAsync(i));
|
||||
|
||||
SearchContainer<AccountSearchTvEpisode> tvEpisodes = await TMDbClient.AccountGetRatedTvShowEpisodesAsync();
|
||||
AccountSearchTvEpisode tvEpisode = tvEpisodes.Results.Single(s => s.Id == IdHelper.BreakingBadSeason1Episode1Id);
|
||||
|
||||
await Verify(tvEpisode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAccountChangeTvFavoriteStatus()
|
||||
public async Task TestAccountChangeTvFavoriteStatusAsync()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Ensure that the test movie is not marked as favorite before we start the test
|
||||
if (DoesFavoriteListContainSpecificTvShow(IdHelper.DoctorWho))
|
||||
Assert.True(Config.Client.AccountChangeFavoriteStatusAsync(MediaType.Tv, IdHelper.DoctorWho, false).Result);
|
||||
if (await DoesFavoriteListContainSpecificTvShow(IdHelper.DoctorWho))
|
||||
Assert.True(await TMDbClient.AccountChangeFavoriteStatusAsync(MediaType.Tv, IdHelper.DoctorWho, false));
|
||||
|
||||
if (DoesFavoriteListContainSpecificTvShow(IdHelper.DoctorWho))
|
||||
if (await DoesFavoriteListContainSpecificTvShow(IdHelper.DoctorWho))
|
||||
throw new Exception($"Test tv show '{IdHelper.DoctorWho}' was already marked as favorite. Unable to perform test correctly");
|
||||
|
||||
// Try to mark is as a favorite
|
||||
Assert.True(Config.Client.AccountChangeFavoriteStatusAsync(MediaType.Tv, IdHelper.DoctorWho, true).Result);
|
||||
Assert.True(await TMDbClient.AccountChangeFavoriteStatusAsync(MediaType.Tv, IdHelper.DoctorWho, true));
|
||||
|
||||
// Check if it worked
|
||||
Assert.True(DoesFavoriteListContainSpecificTvShow(IdHelper.DoctorWho));
|
||||
Assert.True(await DoesFavoriteListContainSpecificTvShow(IdHelper.DoctorWho));
|
||||
|
||||
// Try to un-mark is as a favorite
|
||||
Assert.True(Config.Client.AccountChangeFavoriteStatusAsync(MediaType.Tv, IdHelper.DoctorWho, false).Result);
|
||||
Assert.True(await TMDbClient.AccountChangeFavoriteStatusAsync(MediaType.Tv, IdHelper.DoctorWho, false));
|
||||
|
||||
// Check if it worked
|
||||
Assert.False(DoesFavoriteListContainSpecificTvShow(IdHelper.DoctorWho));
|
||||
Assert.False(await DoesFavoriteListContainSpecificTvShow(IdHelper.DoctorWho));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAccountChangeMovieFavoriteStatus()
|
||||
public async Task TestAccountChangeMovieFavoriteStatusAsync()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Ensure that the test movie is not marked as favorite before we start the test
|
||||
if (DoesFavoriteListContainSpecificMovie(IdHelper.Terminator))
|
||||
Assert.True(Config.Client.AccountChangeFavoriteStatusAsync(MediaType.Movie, IdHelper.Terminator, false).Result);
|
||||
if (await DoesFavoriteListContainSpecificMovie(IdHelper.Terminator))
|
||||
Assert.True(await TMDbClient.AccountChangeFavoriteStatusAsync(MediaType.Movie, IdHelper.Terminator, false));
|
||||
|
||||
if (DoesFavoriteListContainSpecificMovie(IdHelper.Terminator))
|
||||
if (await DoesFavoriteListContainSpecificMovie(IdHelper.Terminator))
|
||||
throw new Exception($"Test movie '{IdHelper.Terminator}' was already marked as favorite. Unable to perform test correctly");
|
||||
|
||||
// Try to mark is as a favorite
|
||||
Assert.True(Config.Client.AccountChangeFavoriteStatusAsync(MediaType.Movie, IdHelper.Terminator, true).Result);
|
||||
Assert.True(await TMDbClient.AccountChangeFavoriteStatusAsync(MediaType.Movie, IdHelper.Terminator, true));
|
||||
|
||||
// Check if it worked
|
||||
Assert.True(DoesFavoriteListContainSpecificMovie(IdHelper.Terminator));
|
||||
Assert.True(await DoesFavoriteListContainSpecificMovie(IdHelper.Terminator));
|
||||
|
||||
// Try to un-mark is as a favorite
|
||||
Assert.True(Config.Client.AccountChangeFavoriteStatusAsync(MediaType.Movie, IdHelper.Terminator, false).Result);
|
||||
Assert.True(await TMDbClient.AccountChangeFavoriteStatusAsync(MediaType.Movie, IdHelper.Terminator, false));
|
||||
|
||||
// Check if it worked
|
||||
Assert.False(DoesFavoriteListContainSpecificMovie(IdHelper.Terminator));
|
||||
Assert.False(await DoesFavoriteListContainSpecificMovie(IdHelper.Terminator));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAccountChangeTvWatchlistStatus()
|
||||
public async Task TestAccountChangeTvWatchlistStatusAsync()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Ensure that the test movie is not marked as favorite before we start the test
|
||||
if (DoesWatchListContainSpecificTvShow(IdHelper.DoctorWho))
|
||||
Assert.True(Config.Client.AccountChangeWatchlistStatusAsync(MediaType.Tv, IdHelper.DoctorWho, false).Result);
|
||||
if (await DoesWatchListContainSpecificTvShow(IdHelper.DoctorWho))
|
||||
Assert.True(await TMDbClient.AccountChangeWatchlistStatusAsync(MediaType.Tv, IdHelper.DoctorWho, false));
|
||||
|
||||
if (DoesWatchListContainSpecificTvShow(IdHelper.DoctorWho))
|
||||
if (await DoesWatchListContainSpecificTvShow(IdHelper.DoctorWho))
|
||||
throw new Exception($"Test tv show '{IdHelper.DoctorWho}' was already on watchlist. Unable to perform test correctly");
|
||||
|
||||
// Try to add an item to the watchlist
|
||||
Assert.True(Config.Client.AccountChangeWatchlistStatusAsync(MediaType.Tv, IdHelper.DoctorWho, true).Result);
|
||||
Assert.True(await TMDbClient.AccountChangeWatchlistStatusAsync(MediaType.Tv, IdHelper.DoctorWho, true));
|
||||
|
||||
// Check if it worked
|
||||
Assert.True(DoesWatchListContainSpecificTvShow(IdHelper.DoctorWho));
|
||||
Assert.True(await DoesWatchListContainSpecificTvShow(IdHelper.DoctorWho));
|
||||
|
||||
// Try to remove item from watchlist
|
||||
Assert.True(Config.Client.AccountChangeWatchlistStatusAsync(MediaType.Tv, IdHelper.DoctorWho, false).Result);
|
||||
Assert.True(await TMDbClient.AccountChangeWatchlistStatusAsync(MediaType.Tv, IdHelper.DoctorWho, false));
|
||||
|
||||
// Check if it worked
|
||||
Assert.False(DoesWatchListContainSpecificTvShow(IdHelper.DoctorWho));
|
||||
Assert.False(await DoesWatchListContainSpecificTvShow(IdHelper.DoctorWho));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAccountChangeMovieWatchlistStatus()
|
||||
public async Task TestAccountChangeMovieWatchlistStatusAsync()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Ensure that the test movie is not marked as favorite before we start the test
|
||||
if (DoesWatchListContainSpecificMovie(IdHelper.Terminator))
|
||||
Assert.True(Config.Client.AccountChangeWatchlistStatusAsync(MediaType.Movie, IdHelper.Terminator, false).Result);
|
||||
if (await DoesWatchListContainSpecificMovie(IdHelper.Terminator))
|
||||
Assert.True(await TMDbClient.AccountChangeWatchlistStatusAsync(MediaType.Movie, IdHelper.Terminator, false));
|
||||
|
||||
if (DoesWatchListContainSpecificMovie(IdHelper.Terminator))
|
||||
if (await DoesWatchListContainSpecificMovie(IdHelper.Terminator))
|
||||
throw new Exception($"Test movie '{IdHelper.Terminator}' was already on watchlist. Unable to perform test correctly");
|
||||
|
||||
// Try to add an item to the watchlist
|
||||
Assert.True(Config.Client.AccountChangeWatchlistStatusAsync(MediaType.Movie, IdHelper.Terminator, true).Result);
|
||||
Assert.True(await TMDbClient.AccountChangeWatchlistStatusAsync(MediaType.Movie, IdHelper.Terminator, true));
|
||||
|
||||
// Check if it worked
|
||||
Assert.True(DoesWatchListContainSpecificMovie(IdHelper.Terminator));
|
||||
Assert.True(await DoesWatchListContainSpecificMovie(IdHelper.Terminator));
|
||||
|
||||
// Try to remove item from watchlist
|
||||
Assert.True(Config.Client.AccountChangeWatchlistStatusAsync(MediaType.Movie, IdHelper.Terminator, false).Result);
|
||||
Assert.True(await TMDbClient.AccountChangeWatchlistStatusAsync(MediaType.Movie, IdHelper.Terminator, false));
|
||||
|
||||
// Check if it worked
|
||||
Assert.False(DoesWatchListContainSpecificMovie(IdHelper.Terminator));
|
||||
Assert.False(await DoesWatchListContainSpecificMovie(IdHelper.Terminator));
|
||||
}
|
||||
|
||||
private bool DoesFavoriteListContainSpecificTvShow(int tvId)
|
||||
private async Task<bool> DoesFavoriteListContainSpecificTvShow(int tvId)
|
||||
{
|
||||
return DoesListContainSpecificMovie(tvId, page => Config.Client.AccountGetFavoriteTvAsync(page).Result.Results.Select(s => s.Id));
|
||||
return await DoesListContainSpecificMovie(tvId, async page => (await TMDbClient.AccountGetFavoriteTvAsync(page)).Results.Select(s => s.Id));
|
||||
}
|
||||
|
||||
private bool DoesWatchListContainSpecificTvShow(int tvId)
|
||||
private async Task<bool> DoesWatchListContainSpecificTvShow(int tvId)
|
||||
{
|
||||
return DoesListContainSpecificMovie(tvId, page => Config.Client.AccountGetTvWatchlistAsync(page).Result.Results.Select(s => s.Id));
|
||||
return await DoesListContainSpecificMovie(tvId, async page => (await TMDbClient.AccountGetTvWatchlistAsync(page)).Results.Select(s => s.Id));
|
||||
}
|
||||
|
||||
private bool DoesFavoriteListContainSpecificMovie(int movieId)
|
||||
private async Task<bool> DoesFavoriteListContainSpecificMovie(int movieId)
|
||||
{
|
||||
return DoesListContainSpecificMovie(movieId, page => Config.Client.AccountGetFavoriteMoviesAsync(page).Result.Results.Select(s => s.Id));
|
||||
return await DoesListContainSpecificMovie(movieId, async page => (await TMDbClient.AccountGetFavoriteMoviesAsync(page)).Results.Select(s => s.Id));
|
||||
}
|
||||
|
||||
private bool DoesWatchListContainSpecificMovie(int movieId)
|
||||
private async Task<bool> DoesWatchListContainSpecificMovie(int movieId)
|
||||
{
|
||||
return DoesListContainSpecificMovie(movieId, page => Config.Client.AccountGetMovieWatchlistAsync(page).Result.Results.Select(s => s.Id));
|
||||
return await DoesListContainSpecificMovie(movieId, async page => (await TMDbClient.AccountGetMovieWatchlistAsync(page)).Results.Select(s => s.Id));
|
||||
}
|
||||
|
||||
private bool DoesListContainSpecificMovie(int movieId, Func<int, IEnumerable<int>> listGetter)
|
||||
private async Task<bool> DoesListContainSpecificMovie(int movieId, Func<int, Task<IEnumerable<int>>> listGetter)
|
||||
{
|
||||
int page = 1;
|
||||
List<int> originalList = listGetter(1).ToList();
|
||||
List<int> originalList = (await listGetter(page)).ToList();
|
||||
while (originalList != null && originalList.Any())
|
||||
{
|
||||
// Check if the current result page contains the relevant movie
|
||||
@ -391,7 +283,7 @@ namespace TMDbLibTests
|
||||
return true;
|
||||
|
||||
// See if there is an other page we could try, if not the test passes
|
||||
originalList = originalList.Any() ? listGetter(++page).ToList() : null;
|
||||
originalList = originalList.Any() ? (await listGetter(++page)).ToList() : null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using TMDbLibTests.Exceptions;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
using TMDbLibTests.Helpers;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
@ -14,19 +14,18 @@ namespace TMDbLibTests
|
||||
{
|
||||
public ClientAuthenticationTests()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Config.Username) || string.IsNullOrWhiteSpace(Config.Password))
|
||||
if (string.IsNullOrWhiteSpace(TestConfig.Username) || string.IsNullOrWhiteSpace(TestConfig.Password))
|
||||
throw new ConfigurationErrorsException("You need to provide a username and password or some tests won't be able to execute.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAuthenticationRequestNewToken()
|
||||
public async Task TestAuthenticationRequestNewToken()
|
||||
{
|
||||
Token token = Config.Client.AuthenticationRequestAutenticationTokenAsync().Sync();
|
||||
Token token = await TMDbClient.AuthenticationRequestAutenticationTokenAsync();
|
||||
|
||||
Assert.NotNull(token);
|
||||
Assert.True(token.Success);
|
||||
Assert.NotNull(token.AuthenticationCallback);
|
||||
Assert.NotNull(token.ExpiresAt);
|
||||
Assert.NotNull(token.RequestToken);
|
||||
}
|
||||
|
||||
@ -49,39 +48,39 @@ namespace TMDbLibTests
|
||||
//}
|
||||
|
||||
[Fact]
|
||||
public void TestAuthenticationUserAuthenticatedSessionInvalidToken()
|
||||
public async Task TestAuthenticationUserAuthenticatedSessionInvalidTokenAsync()
|
||||
{
|
||||
const string requestToken = "bla";
|
||||
|
||||
Assert.Throws<UnauthorizedAccessException>(() => Config.Client.AuthenticationGetUserSessionAsync(requestToken).Sync());
|
||||
await Assert.ThrowsAsync<UnauthorizedAccessException>(() => TMDbClient.AuthenticationGetUserSessionAsync(requestToken));
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// Requires a valid test user to be assigned
|
||||
/// </remarks>
|
||||
[Fact]
|
||||
public void TestAuthenticationGetUserSessionApiUserValidationSuccess()
|
||||
public async Task TestAuthenticationGetUserSessionApiUserValidationSuccessAsync()
|
||||
{
|
||||
Token token = Config.Client.AuthenticationRequestAutenticationTokenAsync().Sync();
|
||||
Token token = await TMDbClient.AuthenticationRequestAutenticationTokenAsync();
|
||||
|
||||
Config.Client.AuthenticationValidateUserTokenAsync(token.RequestToken, Config.Username, Config.Password).Sync();
|
||||
await TMDbClient.AuthenticationValidateUserTokenAsync(token.RequestToken, TestConfig.Username, TestConfig.Password);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAuthenticationGetUserSessionApiUserValidationInvalidLogin()
|
||||
public async Task TestAuthenticationGetUserSessionApiUserValidationInvalidLoginAsync()
|
||||
{
|
||||
Token token = Config.Client.AuthenticationRequestAutenticationTokenAsync().Sync();
|
||||
Token token = await TMDbClient.AuthenticationRequestAutenticationTokenAsync();
|
||||
|
||||
Assert.Throws<UnauthorizedAccessException>(() => Config.Client.AuthenticationValidateUserTokenAsync(token.RequestToken, "bla", "bla").Sync());
|
||||
await Assert.ThrowsAsync<UnauthorizedAccessException>(() => TMDbClient.AuthenticationValidateUserTokenAsync(token.RequestToken, "bla", "bla"));
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// Requires a valid test user to be assigned
|
||||
/// </remarks>
|
||||
[Fact]
|
||||
public void AuthenticationGetUserSessionWithLoginSuccess()
|
||||
public async Task AuthenticationGetUserSessionWithLoginSuccess()
|
||||
{
|
||||
UserSession session = Config.Client.AuthenticationGetUserSessionAsync(Config.Username, Config.Password).Result;
|
||||
UserSession session = await TMDbClient.AuthenticationGetUserSessionAsync(TestConfig.Username, TestConfig.Password);
|
||||
|
||||
Assert.NotNull(session);
|
||||
Assert.True(session.Success);
|
||||
@ -89,21 +88,20 @@ namespace TMDbLibTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAuthenticationUserAuthenticatedSessionOldToken()
|
||||
public async Task TestAuthenticationUserAuthenticatedSessionOldTokenAsync()
|
||||
{
|
||||
const string requestToken = "5f3a62c0d7977319e3d14adf1a2064c0c0938bcf";
|
||||
|
||||
Assert.Throws<UnauthorizedAccessException>(() => Config.Client.AuthenticationGetUserSessionAsync(requestToken).Sync());
|
||||
await Assert.ThrowsAsync<UnauthorizedAccessException>(() => TMDbClient.AuthenticationGetUserSessionAsync(requestToken));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAuthenticationCreateGuestSession()
|
||||
public async Task TestAuthenticationCreateGuestSessionAsync()
|
||||
{
|
||||
GuestSession guestSession = Config.Client.AuthenticationCreateGuestSessionAsync().Sync();
|
||||
GuestSession guestSession = await TMDbClient.AuthenticationCreateGuestSessionAsync();
|
||||
|
||||
Assert.NotNull(guestSession);
|
||||
Assert.True(guestSession.Success);
|
||||
Assert.NotNull(guestSession.ExpiresAt);
|
||||
Assert.NotNull(guestSession.GuestSessionId);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Certifications;
|
||||
using TMDbLibTests.Helpers;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
@ -10,43 +10,31 @@ namespace TMDbLibTests
|
||||
public class ClientCertificationsTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void TestCertificationsListMovie()
|
||||
public async Task TestCertificationsListMovieAsync()
|
||||
{
|
||||
CertificationsContainer result = Config.Client.GetMovieCertificationsAsync().Sync();
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.Certifications);
|
||||
Assert.True(result.Certifications.Count > 1);
|
||||
CertificationsContainer result = await TMDbClient.GetMovieCertificationsAsync();
|
||||
Assert.NotEmpty(result.Certifications);
|
||||
|
||||
List<CertificationItem> certAu = result.Certifications["AU"];
|
||||
Assert.NotNull(certAu);
|
||||
Assert.True(certAu.Count > 2);
|
||||
Assert.NotEmpty(certAu);
|
||||
|
||||
CertificationItem ratingE = certAu.Single(s => s.Certification == "E");
|
||||
|
||||
Assert.NotNull(ratingE);
|
||||
Assert.Equal("E", ratingE.Certification);
|
||||
Assert.Equal("Exempt from classification. Films that are exempt from classification must not contain contentious material (i.e. material that would ordinarily be rated M or higher).", ratingE.Meaning);
|
||||
Assert.Equal(1, ratingE.Order);
|
||||
await Verify(ratingE);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestCertificationsListTv()
|
||||
public async Task TestCertificationsListTvAsync()
|
||||
{
|
||||
CertificationsContainer result = Config.Client.GetTvCertificationsAsync().Sync();
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.Certifications);
|
||||
Assert.True(result.Certifications.Count > 1);
|
||||
CertificationsContainer result = await TMDbClient.GetTvCertificationsAsync();
|
||||
Assert.NotEmpty(result.Certifications);
|
||||
|
||||
List<CertificationItem> certUs = result.Certifications["US"];
|
||||
Assert.NotNull(certUs);
|
||||
Assert.True(certUs.Count > 2);
|
||||
Assert.NotEmpty(certUs);
|
||||
|
||||
CertificationItem ratingNr = certUs.SingleOrDefault(s => s.Certification == "NR");
|
||||
|
||||
Assert.NotNull(ratingNr);
|
||||
Assert.Equal("NR", ratingNr.Certification);
|
||||
Assert.Equal("No rating information.", ratingNr.Meaning);
|
||||
Assert.Equal(0, ratingNr.Order);
|
||||
await Verify(ratingNr);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
using System.Threading.Tasks;
|
||||
using TMDbLib.Objects.Changes;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLibTests.Helpers;
|
||||
using Xunit;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
@ -11,130 +11,42 @@ namespace TMDbLibTests
|
||||
public class ClientChangesTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void TestChangesMovies()
|
||||
public async Task TestChangesMoviesAsync()
|
||||
{
|
||||
// Basic check
|
||||
SearchContainer<ChangesListItem> changesPage1 = Config.Client.GetChangesMoviesAsync().Sync();
|
||||
SearchContainer<ChangesListItem> page1 = await TMDbClient.GetMoviesChangesAsync(1);
|
||||
SearchContainer<ChangesListItem> oldChanges = await TMDbClient.GetMoviesChangesAsync(endDate: DateTime.UtcNow.AddMonths(-1));
|
||||
|
||||
Assert.NotNull(changesPage1);
|
||||
Assert.True(changesPage1.Results.Count > 0);
|
||||
Assert.True(changesPage1.TotalResults > changesPage1.Results.Count);
|
||||
Assert.Equal(1, changesPage1.Page);
|
||||
Assert.NotEmpty(page1.Results);
|
||||
Assert.NotEmpty(oldChanges.Results);
|
||||
|
||||
// Page 2
|
||||
SearchContainer<ChangesListItem> changesPage2 = Config.Client.GetChangesMoviesAsync(2).Result;
|
||||
|
||||
Assert.NotNull(changesPage2);
|
||||
Assert.Equal(2, changesPage2.Page);
|
||||
|
||||
// Check date range (max)
|
||||
DateTime higher = DateTime.UtcNow.AddDays(-7);
|
||||
SearchContainer<ChangesListItem> changesMaxDate = Config.Client.GetChangesMoviesAsync(endDate: higher).Result;
|
||||
|
||||
Assert.NotNull(changesMaxDate);
|
||||
Assert.Equal(1, changesMaxDate.Page);
|
||||
Assert.NotEqual(changesPage1.TotalResults, changesMaxDate.TotalResults);
|
||||
|
||||
// Check date range (lower)
|
||||
DateTime lower = DateTime.UtcNow.AddDays(-6); // Use 6 days to avoid clashes with the 'higher'
|
||||
SearchContainer<ChangesListItem> changesLowDate = Config.Client.GetChangesMoviesAsync(startDate: lower).Result;
|
||||
|
||||
Assert.NotNull(changesLowDate);
|
||||
Assert.Equal(1, changesLowDate.Page);
|
||||
Assert.NotEqual(changesPage1.TotalResults, changesLowDate.TotalResults);
|
||||
// At least one item must be newer in page1
|
||||
Assert.Contains(page1.Results, x => oldChanges.Results.All(s => s.Id != x.Id));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestChangesPeople()
|
||||
public async Task TestChangesPeopleAsync()
|
||||
{
|
||||
// Basic check
|
||||
SearchContainer<ChangesListItem> changesPage1 = Config.Client.GetChangesPeopleAsync().Sync();
|
||||
SearchContainer<ChangesListItem> page1 = await TMDbClient.GetPeopleChangesAsync(1);
|
||||
SearchContainer<ChangesListItem> oldChanges = await TMDbClient.GetPeopleChangesAsync(endDate: DateTime.UtcNow.AddMonths(-1));
|
||||
|
||||
Assert.NotNull(changesPage1);
|
||||
Assert.True(changesPage1.Results.Count > 0);
|
||||
Assert.True(changesPage1.TotalResults > changesPage1.Results.Count);
|
||||
Assert.Equal(1, changesPage1.Page);
|
||||
Assert.NotEmpty(page1.Results);
|
||||
Assert.NotEmpty(oldChanges.Results);
|
||||
|
||||
// Page 2
|
||||
SearchContainer<ChangesListItem> changesPage2 = Config.Client.GetChangesPeopleAsync(2).Result;
|
||||
|
||||
Assert.NotNull(changesPage2);
|
||||
Assert.Equal(2, changesPage2.Page);
|
||||
|
||||
// Check date range (max)
|
||||
DateTime higher = DateTime.UtcNow.AddDays(-7);
|
||||
SearchContainer<ChangesListItem> changesMaxDate = Config.Client.GetChangesPeopleAsync(endDate: higher).Result;
|
||||
|
||||
Assert.NotNull(changesMaxDate);
|
||||
Assert.Equal(1, changesMaxDate.Page);
|
||||
Assert.NotEqual(changesPage1.TotalResults, changesMaxDate.TotalResults);
|
||||
|
||||
// Check date range (lower)
|
||||
DateTime lower = DateTime.UtcNow.AddDays(-6); // Use 6 days to avoid clashes with the 'higher'
|
||||
SearchContainer<ChangesListItem> changesLowDate = Config.Client.GetChangesPeopleAsync(startDate: lower).Result;
|
||||
|
||||
Assert.NotNull(changesLowDate);
|
||||
Assert.Equal(1, changesLowDate.Page);
|
||||
Assert.NotEqual(changesPage1.TotalResults, changesLowDate.TotalResults);
|
||||
|
||||
// None of the id's in changesLowDate should exist in changesMaxDate, and vice versa
|
||||
Assert.True(changesLowDate.Results.All(lowItem => changesMaxDate.Results.All(maxItem => maxItem.Id != lowItem.Id)));
|
||||
Assert.True(changesMaxDate.Results.All(maxItem => changesLowDate.Results.All(lowItem => maxItem.Id != lowItem.Id)));
|
||||
// At least one item must be newer in page1
|
||||
Assert.Contains(page1.Results, x => oldChanges.Results.All(s => s.Id != x.Id));
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void TestChangesTvShows()
|
||||
public async Task TestChangesTvShowsAsync()
|
||||
{
|
||||
// Basic check
|
||||
SearchContainer<ChangesListItem> changesPage1 = Config.Client.GetChangesTvAsync().Sync();
|
||||
SearchContainer<ChangesListItem> page1 = await TMDbClient.GetTvChangesAsync(1);
|
||||
SearchContainer<ChangesListItem> oldChanges = await TMDbClient.GetTvChangesAsync(endDate: DateTime.UtcNow.AddMonths(-1));
|
||||
|
||||
Assert.NotNull(changesPage1);
|
||||
Assert.NotNull(changesPage1.Results);
|
||||
Assert.True(changesPage1.Results.Count > 0);
|
||||
Assert.True(changesPage1.TotalResults >= changesPage1.Results.Count);
|
||||
Assert.Equal(1, changesPage1.Page);
|
||||
Assert.NotEmpty(page1.Results);
|
||||
Assert.NotEmpty(oldChanges.Results);
|
||||
|
||||
if (changesPage1.TotalPages > 1)
|
||||
{
|
||||
Assert.True(changesPage1.TotalResults > changesPage1.Results.Count);
|
||||
// Page 2
|
||||
SearchContainer<ChangesListItem> changesPage2 = Config.Client.GetChangesTvAsync(2).Result;
|
||||
|
||||
Assert.NotNull(changesPage2);
|
||||
Assert.Equal(2, changesPage2.Page);
|
||||
}
|
||||
|
||||
// Check date range (max)
|
||||
DateTime higher = DateTime.UtcNow.AddDays(-8);
|
||||
SearchContainer<ChangesListItem> changesMaxDate = Config.Client.GetChangesTvAsync(endDate: higher).Result;
|
||||
|
||||
Assert.NotNull(changesMaxDate);
|
||||
Assert.Equal(1, changesMaxDate.Page);
|
||||
Assert.NotEqual(changesPage1.TotalResults, changesMaxDate.TotalResults);
|
||||
|
||||
// Check date range (lower)
|
||||
DateTime lower = DateTime.UtcNow.AddDays(-6); // Use 6 days to avoid clashes with the 'higher'
|
||||
SearchContainer<ChangesListItem> changesLowDate = Config.Client.GetChangesTvAsync(startDate: lower).Result;
|
||||
|
||||
Assert.NotNull(changesLowDate);
|
||||
Assert.Equal(1, changesLowDate.Page);
|
||||
Assert.NotEqual(changesPage1.TotalResults, changesLowDate.TotalResults);
|
||||
|
||||
// None of the id's in changesLowDate should exist in changesMaxDate, and vice versa
|
||||
foreach (ChangesListItem changeItem in changesLowDate.Results)
|
||||
{
|
||||
bool existsInOtherList = changesMaxDate.Results.Any(x => x.Id == changeItem.Id);
|
||||
|
||||
Assert.False(existsInOtherList, "Item id " + changeItem.Id + " is duplicated");
|
||||
}
|
||||
|
||||
foreach (ChangesListItem changeItem in changesMaxDate.Results)
|
||||
{
|
||||
bool existsInOtherList = changesLowDate.Results.Any(x => x.Id == changeItem.Id);
|
||||
|
||||
Assert.False(existsInOtherList, "Item id " + changeItem.Id + " is duplicated");
|
||||
}
|
||||
// At least one item must be newer in page1
|
||||
Assert.Contains(page1.Results, x => oldChanges.Results.All(s => s.Id != x.Id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Collections;
|
||||
using TMDbLib.Objects.General;
|
||||
@ -11,94 +11,60 @@ namespace TMDbLibTests
|
||||
{
|
||||
public class ClientCollectionTests : TestBase
|
||||
{
|
||||
private static Dictionary<CollectionMethods, Func<Collection, object>> _methods;
|
||||
private static readonly Dictionary<CollectionMethods, Func<Collection, object>> Methods;
|
||||
|
||||
public ClientCollectionTests()
|
||||
static ClientCollectionTests()
|
||||
{
|
||||
_methods = new Dictionary<CollectionMethods, Func<Collection, object>>
|
||||
Methods = new Dictionary<CollectionMethods, Func<Collection, object>>
|
||||
{
|
||||
[CollectionMethods.Images] = collection => collection.Images
|
||||
};
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestCollectionsExtrasNone()
|
||||
public async Task TestCollectionsExtrasNone()
|
||||
{
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
IgnoreMissingJson(" / images", "parts[array] / media_type");
|
||||
|
||||
Collection collection = Config.Client.GetCollectionAsync(IdHelper.JamesBondCollection).Result;
|
||||
|
||||
Assert.NotNull(collection);
|
||||
Assert.Equal("James Bond Collection", collection.Name);
|
||||
Assert.NotNull(collection.Parts);
|
||||
Assert.True(collection.Parts.Count > 0);
|
||||
Collection collection = await TMDbClient.GetCollectionAsync(IdHelper.BackToTheFutureCollection);
|
||||
|
||||
// Test all extras, ensure none of them exist
|
||||
foreach (Func<Collection, object> selector in _methods.Values)
|
||||
{
|
||||
foreach (Func<Collection, object> selector in Methods.Values)
|
||||
Assert.Null(selector(collection));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestCollectionMissing()
|
||||
public async Task TestCollectionMissing()
|
||||
{
|
||||
Collection collection = Config.Client.GetCollectionAsync(IdHelper.MissingID).Result;
|
||||
Collection collection = await TMDbClient.GetCollectionAsync(IdHelper.MissingID);
|
||||
|
||||
Assert.Null(collection);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestCollectionsParts()
|
||||
public async Task TestCollectionsParts()
|
||||
{
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
IgnoreMissingJson(" / images", "parts[array] / media_type");
|
||||
Collection collection = await TMDbClient.GetCollectionAsync(IdHelper.BackToTheFutureCollection);
|
||||
|
||||
Collection collection = Config.Client.GetCollectionAsync(IdHelper.JamesBondCollection).Result;
|
||||
|
||||
Assert.NotNull(collection);
|
||||
Assert.Equal("James Bond Collection", collection.Name);
|
||||
|
||||
Assert.NotNull(collection.Parts);
|
||||
Assert.True(collection.Parts.Count > 0);
|
||||
|
||||
Assert.Contains(collection.Parts, movie => movie.Title == "Live and Let Die");
|
||||
Assert.Contains(collection.Parts, movie => movie.Title == "Dr. No");
|
||||
await Verify(collection);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestCollectionsExtrasExclusive()
|
||||
public async Task TestCollectionsExtrasExclusive()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("parts[array] / media_type");
|
||||
|
||||
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => Config.Client.GetCollectionAsync(id, extras).Result, IdHelper.JamesBondCollection);
|
||||
await TestMethodsHelper.TestGetExclusive(Methods, extras => TMDbClient.GetCollectionAsync(IdHelper.BackToTheFutureCollection, extras));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestCollectionsExtrasAll()
|
||||
public async Task TestCollectionsExtrasAll()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("parts[array] / media_type");
|
||||
|
||||
CollectionMethods combinedEnum = _methods.Keys.Aggregate((methods, movieMethods) => methods | movieMethods);
|
||||
Collection item = Config.Client.GetCollectionAsync(IdHelper.JamesBondCollection, combinedEnum).Result;
|
||||
|
||||
TestMethodsHelper.TestAllNotNull(_methods, item);
|
||||
await TestMethodsHelper.TestGetAll(Methods, combined => TMDbClient.GetCollectionAsync(IdHelper.BackToTheFutureCollection, combined), async collection => await Verify(collection));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestCollectionsImages()
|
||||
public async Task TestCollectionsImagesAsync()
|
||||
{
|
||||
// Get config
|
||||
Config.Client.GetConfigAsync().Sync();
|
||||
ImagesWithId images = await TMDbClient.GetCollectionImagesAsync(IdHelper.BackToTheFutureCollection);
|
||||
|
||||
// Test image url generator
|
||||
ImagesWithId images = Config.Client.GetCollectionImagesAsync(IdHelper.JamesBondCollection).Result;
|
||||
|
||||
Assert.Equal(IdHelper.JamesBondCollection, images.Id);
|
||||
TestImagesHelpers.TestImages(Config, images);
|
||||
TestImagesHelpers.TestImagePaths(images);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Companies;
|
||||
using TMDbLib.Objects.General;
|
||||
@ -12,83 +13,65 @@ namespace TMDbLibTests
|
||||
{
|
||||
public class ClientCompanyTests : TestBase
|
||||
{
|
||||
private static Dictionary<CompanyMethods, Func<Company, object>> _methods;
|
||||
private static readonly Dictionary<CompanyMethods, Func<Company, object>> Methods;
|
||||
|
||||
public ClientCompanyTests()
|
||||
static ClientCompanyTests()
|
||||
{
|
||||
_methods = new Dictionary<CompanyMethods, Func<Company, object>>
|
||||
Methods = new Dictionary<CompanyMethods, Func<Company, object>>
|
||||
{
|
||||
[CompanyMethods.Movies] = company => company.Movies
|
||||
};
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestCompaniesExtrasNone()
|
||||
public async Task TestCompaniesExtrasNoneAsync()
|
||||
{
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
IgnoreMissingJson(" / movies");
|
||||
|
||||
Company company = Config.Client.GetCompanyAsync(IdHelper.TwentiethCenturyFox).Result;
|
||||
|
||||
Assert.NotNull(company);
|
||||
|
||||
// TODO: Test all properties
|
||||
Assert.Equal("20th Century Fox", company.Name);
|
||||
Company company = await TMDbClient.GetCompanyAsync(IdHelper.TwentiethCenturyFox);
|
||||
|
||||
// Test all extras, ensure none of them exist
|
||||
foreach (Func<Company, object> selector in _methods.Values)
|
||||
foreach (Func<Company, object> selector in Methods.Values)
|
||||
{
|
||||
Assert.Null(selector(company));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestCompaniesExtrasExclusive()
|
||||
public async Task TestCompaniesExtrasExclusive()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("movies.results[array] / media_type");
|
||||
|
||||
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => Config.Client.GetCompanyAsync(id, extras).Result, IdHelper.TwentiethCenturyFox);
|
||||
await TestMethodsHelper.TestGetExclusive(Methods, extras => TMDbClient.GetCompanyAsync(IdHelper.TwentiethCenturyFox, extras));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestCompaniesExtrasAll()
|
||||
public async Task TestCompaniesExtrasAllAsync()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("movies.results[array] / media_type");
|
||||
await TestMethodsHelper.TestGetAll(Methods, combined => TMDbClient.GetCompanyAsync(IdHelper.TwentiethCenturyFox, combined), async company =>
|
||||
{
|
||||
// Reduce testdata
|
||||
company.Movies.Results = company.Movies.Results.OrderBy(s => s.Id).Take(1).ToList();
|
||||
|
||||
CompanyMethods combinedEnum = _methods.Keys.Aggregate((methods, movieMethods) => methods | movieMethods);
|
||||
Company item = Config.Client.GetCompanyAsync(IdHelper.TwentiethCenturyFox, combinedEnum).Result;
|
||||
|
||||
TestMethodsHelper.TestAllNotNull(_methods, item);
|
||||
await Verify(company, settings => settings.IgnoreProperty(nameof(company.Movies.TotalPages), nameof(company.Movies.TotalResults)));
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestCompanyMissing()
|
||||
public async Task TestCompanyMissingAsync()
|
||||
{
|
||||
Company company = Config.Client.GetCompanyAsync(IdHelper.MissingID).Result;
|
||||
Company company = await TMDbClient.GetCompanyAsync(IdHelper.MissingID);
|
||||
|
||||
Assert.Null(company);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestCompaniesGetters()
|
||||
public async Task TestCompaniesMoviesAsync()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
|
||||
//GetCompanyMoviesAsync(int id, string language, int page = -1)
|
||||
SearchContainerWithId<SearchMovie> resp = Config.Client.GetCompanyMoviesAsync(IdHelper.TwentiethCenturyFox).Result;
|
||||
SearchContainerWithId<SearchMovie> respPage2 = Config.Client.GetCompanyMoviesAsync(IdHelper.TwentiethCenturyFox, 2).Result;
|
||||
SearchContainerWithId<SearchMovie> respItalian = Config.Client.GetCompanyMoviesAsync(IdHelper.TwentiethCenturyFox, "it").Result;
|
||||
SearchContainerWithId<SearchMovie> resp = await TMDbClient.GetCompanyMoviesAsync(IdHelper.TwentiethCenturyFox);
|
||||
SearchContainerWithId<SearchMovie> respPage2 = await TMDbClient.GetCompanyMoviesAsync(IdHelper.TwentiethCenturyFox, 2);
|
||||
SearchContainerWithId<SearchMovie> respItalian = await TMDbClient.GetCompanyMoviesAsync(IdHelper.TwentiethCenturyFox, "it");
|
||||
|
||||
Assert.NotNull(resp);
|
||||
Assert.NotNull(respPage2);
|
||||
Assert.NotNull(respItalian);
|
||||
|
||||
Assert.True(resp.Results.Count > 0);
|
||||
Assert.True(respPage2.Results.Count > 0);
|
||||
Assert.True(respItalian.Results.Count > 0);
|
||||
Assert.NotEmpty(resp.Results);
|
||||
Assert.NotEmpty(respPage2.Results);
|
||||
Assert.NotEmpty(respItalian.Results);
|
||||
|
||||
bool allTitlesIdentical = true;
|
||||
for (int index = 0; index < resp.Results.Count; index++)
|
||||
@ -103,44 +86,22 @@ namespace TMDbLibTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestCompaniesImages()
|
||||
public async Task TestCompaniesImagesAsync()
|
||||
{
|
||||
IgnoreMissingJson(" / movies");
|
||||
|
||||
// Get config
|
||||
Config.Client.GetConfigAsync().Sync();
|
||||
await TMDbClient.GetConfigAsync();
|
||||
|
||||
// Test image url generator
|
||||
Company company = Config.Client.GetCompanyAsync(IdHelper.TwentiethCenturyFox).Result;
|
||||
Company company = await TMDbClient.GetCompanyAsync(IdHelper.TwentiethCenturyFox);
|
||||
|
||||
Uri url = Config.Client.GetImageUrl("original", company.LogoPath);
|
||||
Uri urlSecure = Config.Client.GetImageUrl("original", company.LogoPath, true);
|
||||
Uri url = TMDbClient.GetImageUrl("original", company.LogoPath);
|
||||
Uri urlSecure = TMDbClient.GetImageUrl("original", company.LogoPath, true);
|
||||
|
||||
Assert.True(TestHelpers.InternetUriExists(url));
|
||||
Assert.True(TestHelpers.InternetUriExists(urlSecure));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestCompaniesFull()
|
||||
await Verify(new
|
||||
{
|
||||
IgnoreMissingJson(" / movies");
|
||||
|
||||
Company company = Config.Client.GetCompanyAsync(IdHelper.ColumbiaPictures).Result;
|
||||
|
||||
Assert.NotNull(company);
|
||||
|
||||
Assert.Equal(IdHelper.ColumbiaPictures, company.Id);
|
||||
Assert.Equal("Columbia Pictures Industries, Inc. (CPII) is an American film production and distribution company. Columbia Pictures now forms part of the Columbia TriStar Motion Picture Group, owned by Sony Pictures Entertainment, a subsidiary of the Japanese conglomerate Sony. It is one of the leading film companies in the world, a member of the so-called Big Six. It was one of the so-called Little Three among the eight major film studios of Hollywood's Golden Age.", company.Description);
|
||||
Assert.Equal("Culver City, California", company.Headquarters);
|
||||
Assert.Equal("http://www.sonypictures.com/", company.Homepage);
|
||||
Assert.Equal("US", company.OriginCountry);
|
||||
Assert.Equal("/mjUSfXXUhMiLAA1Zq1TfStNSoLR.png", company.LogoPath);
|
||||
Assert.Equal("Columbia Pictures", company.Name);
|
||||
|
||||
Assert.NotNull(company.ParentCompany);
|
||||
Assert.Equal(5752, company.ParentCompany.Id);
|
||||
Assert.Equal("/sFg00KK0vVq3oqvkCxRQWApYB83.png", company.ParentCompany.LogoPath);
|
||||
Assert.Equal("Sony Pictures Entertainment", company.ParentCompany.Name);
|
||||
url,
|
||||
urlSecure
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TMDbLib.Objects.Configuration;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Timezones;
|
||||
using TMDbLibTests.Helpers;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
using TMDbLib.Objects.Countries;
|
||||
using TMDbLib.Objects.General;
|
||||
@ -14,72 +14,63 @@ namespace TMDbLibTests
|
||||
public class ClientConfigurationTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void TestConfiguration()
|
||||
public async Task TestConfigurationAsync()
|
||||
{
|
||||
APIConfiguration result = Config.Client.GetAPIConfiguration().Sync();
|
||||
APIConfiguration result = await TMDbClient.GetAPIConfiguration();
|
||||
|
||||
Assert.NotNull(result);
|
||||
|
||||
Assert.Contains(result.Images.BackdropSizes, c => c == "original");
|
||||
await Verify(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestPrimaryTranslations()
|
||||
public async Task TestPrimaryTranslationsAsync()
|
||||
{
|
||||
List<string> result = Config.Client.GetPrimaryTranslationsAsync().Sync();
|
||||
List<string> result = await TMDbClient.GetPrimaryTranslationsAsync();
|
||||
|
||||
Assert.NotNull(result);
|
||||
|
||||
Assert.Contains(result, c => c == "da-DK");
|
||||
Assert.Contains("da-DK", result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestCountryList()
|
||||
public async Task TestCountryListAsync()
|
||||
{
|
||||
List<Country> result = Config.Client.GetCountriesAsync().Sync();
|
||||
List<Country> result = await TMDbClient.GetCountriesAsync();
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.True(result.Count > 200);
|
||||
Assert.NotEmpty(result);
|
||||
Country single = result.Single(s => s.EnglishName == "Denmark");
|
||||
|
||||
Assert.Contains(result, c => c.EnglishName == "Denmark" && c.Iso_3166_1 == "DK");
|
||||
await Verify(single);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestLanguageList()
|
||||
public async Task TestLanguageListAsync()
|
||||
{
|
||||
List<Language> result = Config.Client.GetLanguagesAsync().Sync();
|
||||
List<Language> result = await TMDbClient.GetLanguagesAsync();
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.True(result.Count > 180);
|
||||
Assert.NotEmpty(result);
|
||||
Language single = result.Single(s => s.Name == "Dansk");
|
||||
|
||||
Assert.Contains(result, l => l.Name == "Dansk" && l.EnglishName == "Danish" && l.Iso_639_1 == "da");
|
||||
await Verify(single);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTimezonesList()
|
||||
public async Task TestTimezonesListAsync()
|
||||
{
|
||||
Timezones result = Config.Client.GetTimezonesAsync().Sync();
|
||||
Timezones result = await TMDbClient.GetTimezonesAsync();
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.True(result.List.Count > 200);
|
||||
Assert.NotEmpty(result.List);
|
||||
List<string> single = result.List["DK"];
|
||||
|
||||
List<string> item = result.List["DK"];
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal(1, item.Count);
|
||||
Assert.Equal("Europe/Copenhagen", item[0]);
|
||||
await Verify(single);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestJobList()
|
||||
public async Task TestJobListAsync()
|
||||
{
|
||||
List<Job> jobs = Config.Client.GetJobsAsync().Sync();
|
||||
List<Job> jobs = await TMDbClient.GetJobsAsync();
|
||||
|
||||
Assert.NotNull(jobs);
|
||||
Assert.True(jobs.Count > 0);
|
||||
Assert.NotEmpty(jobs);
|
||||
Job single = jobs.Single(s => s.Department == "Writing");
|
||||
|
||||
Assert.True(jobs.All(job => !string.IsNullOrEmpty(job.Department)));
|
||||
Assert.True(jobs.All(job => job.Jobs != null));
|
||||
Assert.True(jobs.All(job => job.Jobs.Count > 0));
|
||||
await Verify(single);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Credit;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLibTests.Helpers;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
|
||||
@ -11,71 +9,33 @@ namespace TMDbLibTests
|
||||
public class ClientCreditTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void TestGetCreditTv()
|
||||
public async Task TestGetCreditTv()
|
||||
{
|
||||
Credit result = Config.Client.GetCreditsAsync(IdHelper.BruceWillisMiamiVice).Result;
|
||||
Credit result = await TMDbClient.GetCreditsAsync(IdHelper.BruceWillisMiamiVice);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(CreditType.Cast, result.CreditType);
|
||||
Assert.Equal("Actors", result.Department);
|
||||
Assert.Equal("Actor", result.Job);
|
||||
Assert.Equal(MediaType.Tv, result.MediaType);
|
||||
Assert.Equal(IdHelper.BruceWillisMiamiVice, result.Id);
|
||||
// Episode must exist
|
||||
Assert.Contains(result.Media.Episodes, s => s.Name == "No Exit");
|
||||
|
||||
Assert.NotNull(result.Person);
|
||||
Assert.Equal("Bruce Willis", result.Person.Name);
|
||||
Assert.Equal(62, result.Person.Id);
|
||||
|
||||
Assert.NotNull(result.Media);
|
||||
Assert.Equal(1908, result.Media.Id);
|
||||
Assert.Equal("Miami Vice", result.Media.Name);
|
||||
Assert.Equal("Miami Vice", result.Media.OriginalName);
|
||||
Assert.Equal("", result.Media.Character);
|
||||
await Verify(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestMissingCredit()
|
||||
public async Task TestMissingCredit()
|
||||
{
|
||||
Credit result = Config.Client.GetCreditsAsync(IdHelper.MissingID.ToString()).Result;
|
||||
Credit result = await TMDbClient.GetCreditsAsync(IdHelper.MissingID.ToString());
|
||||
|
||||
Assert.Null(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestGetCreditEpisode()
|
||||
public async Task TestGetCreditSeasons()
|
||||
{
|
||||
Credit result = Config.Client.GetCreditsAsync(IdHelper.BruceWillisMiamiVice).Result;
|
||||
Credit result = await TMDbClient.GetCreditsAsync(IdHelper.HughLaurieHouse);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.Media);
|
||||
Assert.NotNull(result.Media.Episodes);
|
||||
// Season must exist
|
||||
Assert.Contains(result.Media.Seasons, s => s.SeasonNumber == 1);
|
||||
|
||||
CreditEpisode item = result.Media.Episodes.SingleOrDefault(s => s.Name == "No Exit");
|
||||
Assert.NotNull(item);
|
||||
|
||||
Assert.Equal(new DateTime(1984, 11, 9), item.AirDate);
|
||||
Assert.Equal(8, item.EpisodeNumber);
|
||||
Assert.Equal("No Exit", item.Name);
|
||||
Assert.Equal("Crockett attempts to help an old flame free herself from a racketeer, then is framed for taking bribes. Martin Castillo becomes the squad's new Lieutenant.", item.Overview);
|
||||
Assert.Equal(1, item.SeasonNumber);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.StillPath), "item.StillPath was not a valid image path, was: " + item.StillPath);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestGetCreditSeasons()
|
||||
{
|
||||
Credit result = Config.Client.GetCreditsAsync(IdHelper.HughLaurieHouse).Result;
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.Media);
|
||||
Assert.NotNull(result.Media.Seasons);
|
||||
|
||||
CreditSeason item = result.Media.Seasons.SingleOrDefault(s => s.SeasonNumber == 1);
|
||||
Assert.NotNull(item);
|
||||
|
||||
Assert.Equal(new DateTime(2004, 11, 16), item.AirDate);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
Assert.Equal(1, item.SeasonNumber);
|
||||
await Verify(result);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,112 +1,83 @@
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Discover;
|
||||
using TMDbLib.Objects.General;
|
||||
using System.Linq;
|
||||
using TMDbLib.Objects.Search;
|
||||
using TMDbLibTests.Helpers;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
public class ClientDiscoverTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void TestDiscoverTvShowsNoParams()
|
||||
public async Task TestDiscoverTvShowsNoParamsAsync()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
|
||||
TestHelpers.SearchPages(i => Config.Client.DiscoverTvShowsAsync().Query(i).Result);
|
||||
|
||||
SearchContainer<SearchTv> result = Config.Client.DiscoverTvShowsAsync().Query().Result;
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(1, result.Page);
|
||||
Assert.NotNull(result.Results);
|
||||
Assert.True(result.Results.Any());
|
||||
await TestHelpers.SearchPagesAsync(i => TMDbClient.DiscoverTvShowsAsync().Query(i));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestDiscoverTvShows()
|
||||
public async Task TestDiscoverMoviesNoParamsAsync()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
await TestHelpers.SearchPagesAsync(i => TMDbClient.DiscoverMoviesAsync().Query(i));
|
||||
}
|
||||
|
||||
DiscoverTv query = Config.Client.DiscoverTvShowsAsync()
|
||||
[Fact]
|
||||
public async Task TestDiscoverTvShowsAsync()
|
||||
{
|
||||
DiscoverTv query = TMDbClient.DiscoverTvShowsAsync()
|
||||
.WhereVoteCountIsAtLeast(100)
|
||||
.WhereVoteAverageIsAtLeast(2);
|
||||
|
||||
TestHelpers.SearchPages(i => query.Query(i).Result);
|
||||
await TestHelpers.SearchPagesAsync(i => query.Query(i));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestDiscoverMoviesNoParams()
|
||||
public async Task TestDiscoverMoviesAsync()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
|
||||
TestHelpers.SearchPages(i => Config.Client.DiscoverMoviesAsync().Query(i).Result);
|
||||
|
||||
SearchContainer<SearchMovie> result = Config.Client.DiscoverMoviesAsync().Query().Result;
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(1, result.Page);
|
||||
Assert.NotNull(result.Results);
|
||||
Assert.True(result.Results.Any());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestDiscoverMovies()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
|
||||
DiscoverMovie query = Config.Client.DiscoverMoviesAsync()
|
||||
DiscoverMovie query = TMDbClient.DiscoverMoviesAsync()
|
||||
.WhereVoteCountIsAtLeast(1000)
|
||||
.WhereVoteAverageIsAtLeast(2);
|
||||
|
||||
TestHelpers.SearchPages(i => query.Query(i).Result);
|
||||
await TestHelpers.SearchPagesAsync(i => query.Query(i));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestDiscoverMoviesRegion()
|
||||
public async Task TestDiscoverMoviesRegionAsync()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
DiscoverMovie query = TMDbClient.DiscoverMoviesAsync()
|
||||
.WhereReleaseDateIsInRegion("BR")
|
||||
.WherePrimaryReleaseDateIsAfter(new DateTime(2017, 01, 01));
|
||||
|
||||
DiscoverMovie query = Config.Client.DiscoverMoviesAsync().WhereReleaseDateIsInRegion("BR").WherePrimaryReleaseDateIsAfter(new DateTime(2017, 01, 01));
|
||||
|
||||
TestHelpers.SearchPages(i => query.Query(i).Result);
|
||||
await TestHelpers.SearchPagesAsync(i => query.Query(i));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestDiscoverMoviesLanguage()
|
||||
public async Task TestDiscoverMoviesLanguageAsync()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
SearchContainer<SearchMovie> query = await TMDbClient.DiscoverMoviesAsync()
|
||||
.WhereOriginalLanguageIs("en-US")
|
||||
.WherePrimaryReleaseDateIsAfter(new DateTime(2017, 01, 01))
|
||||
.Query();
|
||||
|
||||
DiscoverMovie query = Config.Client.DiscoverMoviesAsync().WhereLanguageIs("da-DK").WherePrimaryReleaseDateIsAfter(new DateTime(2017, 01, 01));
|
||||
SearchContainer<SearchMovie> queryDanish = await TMDbClient.DiscoverMoviesAsync()
|
||||
.WhereLanguageIs("da-DK")
|
||||
.WhereOriginalLanguageIs("en-US")
|
||||
.WherePrimaryReleaseDateIsAfter(new DateTime(2017, 01, 01))
|
||||
.Query();
|
||||
|
||||
Assert.Equal("Skønheden og Udyret", query.Query(0).Result.Results[11].Title);
|
||||
// Should be the same identities, but different titles
|
||||
Assert.Equal(query.TotalResults, queryDanish.TotalResults);
|
||||
|
||||
TestHelpers.SearchPages(i => query.Query(i).Result);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("ko")]
|
||||
[InlineData("zh")]
|
||||
public void TestDiscoverMoviesOriginalLanguage(string language)
|
||||
for (int i = 0; i < query.Results.Count; i++)
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
SearchMovie a = query.Results[i];
|
||||
SearchMovie b = queryDanish.Results[i];
|
||||
|
||||
DiscoverMovie query = Config.Client.DiscoverMoviesAsync().WhereOriginalLanguageIs(language);
|
||||
List<SearchMovie> results = query.Query(0).Result.Results;
|
||||
|
||||
Assert.NotEmpty(results);
|
||||
Assert.All(results, item => Assert.Contains(language, item.OriginalLanguage));
|
||||
Assert.Equal(a.Id, b.Id);
|
||||
Assert.NotEqual(a.Title, b.Title);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -9,65 +9,51 @@ namespace TMDbLibTests
|
||||
public class ClientFindTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void TestFindImdbMovie()
|
||||
public async Task TestFindImdbMovie()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("movie_results[array] / media_type", "movie_results[array] / popularity");
|
||||
FindContainer result = await TMDbClient.FindAsync(FindExternalSource.Imdb, IdHelper.ImdbTerminatorId);
|
||||
|
||||
Task<FindContainer> result = Config.Client.FindAsync(FindExternalSource.Imdb, IdHelper.ImdbTerminatorId);
|
||||
Assert.Equal(1, result.Result.MovieResults.Count);
|
||||
Assert.Equal(IdHelper.TmdbTerminatorId, result.Result.MovieResults[0].Id);
|
||||
await Verify(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestFindImdbPerson()
|
||||
public async Task TestFindImdbPerson()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("person_results[array] / media_type", " / popularity", "person_results[array] / popularity");
|
||||
FindContainer result = await TMDbClient.FindAsync(FindExternalSource.Imdb, IdHelper.ImdbBruceWillis);
|
||||
|
||||
Task<FindContainer> result = Config.Client.FindAsync(FindExternalSource.Imdb, IdHelper.ImdbBruceWillis);
|
||||
Assert.Equal(1, result.Result.PersonResults.Count);
|
||||
Assert.Equal(IdHelper.BruceWillis, result.Result.PersonResults[0].Id);
|
||||
await Verify(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestFindImdbTvShowEpisode()
|
||||
public async Task TestFindImdbTvShowEpisode()
|
||||
{
|
||||
Task<FindContainer> result = Config.Client.FindAsync(FindExternalSource.Imdb, IdHelper.ImdbBreakingBadSeason1Episode1Id);
|
||||
Assert.Equal(1, result.Result.TvEpisode.Count);
|
||||
Assert.Equal(IdHelper.BreakingBadSeason1Episode1Id, result.Result.TvEpisode[0].Id);
|
||||
FindContainer result = await TMDbClient.FindAsync(FindExternalSource.Imdb, IdHelper.ImdbBreakingBadSeason1Episode1Id);
|
||||
|
||||
await Verify(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestFindImdbTvShowSeason()
|
||||
public async Task TestFindImdbTvShowSeasonAsync()
|
||||
{
|
||||
Task<FindContainer> result = Config.Client.FindAsync(FindExternalSource.TvDb, IdHelper.TvdbBreakingBadSeason1Id);
|
||||
Assert.Equal(1, result.Result.TvEpisode.Count);
|
||||
FindContainer result = await TMDbClient.FindAsync(FindExternalSource.TvDb, IdHelper.TvdbBreakingBadSeason1Id);
|
||||
|
||||
Assert.Equal(1, result.Result.TvSeason.Count);
|
||||
Assert.Equal(IdHelper.BreakingBadSeason1Id, result.Result.TvSeason[0].Id);
|
||||
await Verify(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestFindTvdbTvShow()
|
||||
public async Task TestFindTvdbTvShowAsync()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("tv_results[array] / media_type", "tv_results[array] / popularity");
|
||||
FindContainer result = await TMDbClient.FindAsync(FindExternalSource.TvDb, IdHelper.TvdbBreakingBadId);
|
||||
|
||||
Task<FindContainer> result = Config.Client.FindAsync(FindExternalSource.TvDb, IdHelper.TvdbBreakingBadId);
|
||||
Assert.Equal(1, result.Result.TvResults.Count);
|
||||
Assert.Equal(IdHelper.TmdbBreakingBadId, result.Result.TvResults[0].Id);
|
||||
await Verify(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestFindImdbTvShow()
|
||||
public async Task TestFindImdbTvShowAsync()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("tv_results[array] / media_type", "tv_results[array] / popularity");
|
||||
FindContainer result = await TMDbClient.FindAsync(FindExternalSource.Imdb, IdHelper.ImdbBreakingBadId);
|
||||
|
||||
Task<FindContainer> result = Config.Client.FindAsync(FindExternalSource.Imdb, IdHelper.ImdbBreakingBadId);
|
||||
Assert.Equal(1, result.Result.TvResults.Count);
|
||||
Assert.Equal(IdHelper.TmdbBreakingBadId, result.Result.TvResults[0].Id);
|
||||
await Verify(result);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Search;
|
||||
@ -11,75 +12,57 @@ namespace TMDbLibTests
|
||||
public class ClientGenreTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void TestGenreTvList()
|
||||
public async Task TestGenreTvListAsync()
|
||||
{
|
||||
// Default language
|
||||
List<Genre> genres = Config.Client.GetTvGenresAsync().Sync();
|
||||
|
||||
Assert.NotNull(genres);
|
||||
Assert.True(genres.Count > 0);
|
||||
List<Genre> genres = await TMDbClient.GetTvGenresAsync();
|
||||
|
||||
// Another language
|
||||
List<Genre> genresDanish = Config.Client.GetTvGenresAsync("da").Result;
|
||||
List<Genre> genresDanish = await TMDbClient.GetTvGenresAsync("da");
|
||||
|
||||
Assert.NotNull(genresDanish);
|
||||
Assert.True(genresDanish.Count > 0);
|
||||
|
||||
Assert.Equal(genres.Count, genresDanish.Count);
|
||||
await Verify(new
|
||||
{
|
||||
genres,
|
||||
genresDanish
|
||||
});
|
||||
|
||||
// At least one should be different
|
||||
Assert.True(genres.Any(genre => genresDanish.First(danishGenre => danishGenre.Id == genre.Id).Name != genre.Name));
|
||||
Genre actionEn = genres.Single(s => s.Id == IdHelper.ActionAdventureTvGenre);
|
||||
Genre actionDa = genresDanish.Single(s => s.Id == IdHelper.ActionAdventureTvGenre);
|
||||
|
||||
Assert.NotEqual(actionEn.Name, actionDa.Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestGenreMovieList()
|
||||
public async Task TestGenreMovieListAsync()
|
||||
{
|
||||
// Default language
|
||||
List<Genre> genres = Config.Client.GetMovieGenresAsync().Sync();
|
||||
|
||||
Assert.NotNull(genres);
|
||||
Assert.True(genres.Count > 0);
|
||||
List<Genre> genres = await TMDbClient.GetMovieGenresAsync();
|
||||
|
||||
// Another language
|
||||
List<Genre> genresDanish = Config.Client.GetMovieGenresAsync("da").Result;
|
||||
List<Genre> genresDanish = await TMDbClient.GetMovieGenresAsync("da");
|
||||
|
||||
Assert.NotNull(genresDanish);
|
||||
Assert.True(genresDanish.Count > 0);
|
||||
|
||||
Assert.Equal(genres.Count, genresDanish.Count);
|
||||
await Verify(new
|
||||
{
|
||||
genres,
|
||||
genresDanish
|
||||
});
|
||||
|
||||
// At least one should be different
|
||||
Assert.True(genres.Any(genre => genresDanish.First(danishGenre => danishGenre.Id == genre.Id).Name != genre.Name));
|
||||
Genre actionEn = genres.Single(s => s.Id == IdHelper.AdventureMovieGenre);
|
||||
Genre actionDa = genresDanish.Single(s => s.Id == IdHelper.AdventureMovieGenre);
|
||||
|
||||
Assert.NotEqual(actionEn.Name, actionDa.Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestGenreMovies()
|
||||
public async Task TestGenreMoviesAsync()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
SearchContainerWithId<SearchMovie> movies = await TMDbClient.GetGenreMoviesAsync(IdHelper.AdventureMovieGenre);
|
||||
|
||||
// Get first genre
|
||||
Genre genre = Config.Client.GetMovieGenresAsync().Sync().First();
|
||||
|
||||
// Get movies
|
||||
SearchContainerWithId<SearchMovie> movies = Config.Client.GetGenreMoviesAsync(genre.Id).Result;
|
||||
SearchContainerWithId<SearchMovie> moviesPage2 = Config.Client.GetGenreMoviesAsync(genre.Id, "it", 2, includeAllMovies: false).Result;
|
||||
SearchContainerWithId<SearchMovie> moviesAll = Config.Client.GetGenreMoviesAsync(genre.Id, includeAllMovies: true).Result;
|
||||
|
||||
Assert.Equal(1, movies.Page);
|
||||
Assert.Equal(2, moviesPage2.Page);
|
||||
Assert.Equal(1, moviesAll.Page);
|
||||
|
||||
Assert.True(movies.Results.Count > 0);
|
||||
Assert.True(moviesPage2.Results.Count > 0);
|
||||
Assert.True(moviesAll.Results.Count > 0);
|
||||
|
||||
Assert.True(movies.Results.All(s => s != null));
|
||||
Assert.True(moviesPage2.Results.All(s => s != null));
|
||||
Assert.True(moviesAll.Results.All(s => s != null));
|
||||
|
||||
Assert.Equal(movies.TotalResults, moviesPage2.TotalResults); // Should be the same, despite the use of 'includeAllMovies' and Italian
|
||||
Assert.True(moviesAll.TotalResults >= movies.TotalResults);
|
||||
Assert.NotEmpty(movies.Results);
|
||||
Assert.Equal(IdHelper.AdventureMovieGenre, movies.Id);
|
||||
Assert.All(movies.Results, x => Assert.Contains(IdHelper.AdventureMovieGenre, x.GenreIds));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
using TMDbLib.Objects.General;
|
||||
@ -14,191 +12,69 @@ namespace TMDbLibTests
|
||||
public class ClientGuestSessionTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void TestTvEpisodeSetRatingGuestSession()
|
||||
public async Task TestTvEpisodeSetRatingGuestSessionAsync()
|
||||
{
|
||||
Config.Client.SetSessionInformation(Config.GuestTestSessionId, SessionType.GuestSession);
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.GuestTestSessionId, SessionType.GuestSession);
|
||||
|
||||
// Try changing the rating
|
||||
Assert.True(Config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 7.5).Result);
|
||||
await TestMethodsHelper.SetValidateRemoveTest(async () =>
|
||||
{
|
||||
Assert.True(await TMDbClient.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 7.5));
|
||||
}, async () =>
|
||||
{
|
||||
Assert.True(await TMDbClient.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 1));
|
||||
}, async shouldBeSet =>
|
||||
{
|
||||
SearchContainer<TvEpisodeWithRating> ratings = await TMDbClient.GetGuestSessionRatedTvEpisodesAsync();
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
SearchContainer<TvEpisodeWithRating> ratings = Config.Client.GetGuestSessionRatedTvEpisodesAsync().Sync();
|
||||
|
||||
Assert.False(true, "This test has been failing for some time - TMDb has been made aware, but have not responded");
|
||||
|
||||
//double tmpRating = ratings.Results.Single(s => s.ShowId == IdHelper.BreakingBad && s.SeasonNumber == 1 && s.EpisodeNumber == 1).Rating;
|
||||
//Assert.True(ratings.Results.Any(s => s.ShowId == IdHelper.BreakingBad && s.SeasonNumber == 1 && s.EpisodeNumber == 1));
|
||||
//Assert.True(Math.Abs(7.5 - tmpRating) < float.Epsilon);
|
||||
|
||||
//// Try changing it back to the previous rating
|
||||
//Assert.True(Config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 8).Result);
|
||||
|
||||
//// Allow TMDb to cache our changes
|
||||
//Thread.Sleep(2000);
|
||||
|
||||
//ratings = Config.Client.GetGuestSessionRatedTvEpisodesAsync().Sync();
|
||||
|
||||
//tmpRating = ratings.Results.Single(s => s.ShowId == IdHelper.BreakingBad && s.SeasonNumber == 1 && s.EpisodeNumber == 1).Rating;
|
||||
//Assert.True(ratings.Results.Any(s => s.ShowId == IdHelper.BreakingBad && s.SeasonNumber == 1 && s.EpisodeNumber == 1));
|
||||
//Assert.True(Math.Abs(8 - tmpRating) < float.Epsilon);
|
||||
|
||||
//// Try removing the rating
|
||||
//Assert.True(Config.Client.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 1).Result);
|
||||
|
||||
//// Allow TMDb to cache our changes
|
||||
//Thread.Sleep(2000);
|
||||
|
||||
//ratings = Config.Client.GetGuestSessionRatedTvEpisodesAsync().Sync();
|
||||
|
||||
//Assert.False(ratings.Results.Any(s => s.ShowId == IdHelper.BreakingBad && s.SeasonNumber == 1 && s.EpisodeNumber == 1));
|
||||
if (shouldBeSet)
|
||||
Assert.Contains(ratings.Results, x => x.ShowId == IdHelper.BreakingBad && x.SeasonNumber == 1 && x.EpisodeNumber == 1);
|
||||
else
|
||||
Assert.DoesNotContain(ratings.Results, x => x.ShowId == IdHelper.BreakingBad && x.SeasonNumber == 1 && x.EpisodeNumber == 1);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvSetRatingGuestSession()
|
||||
public async Task TestTvSetRatingGuestSessionAsync()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.GuestTestSessionId, SessionType.GuestSession);
|
||||
|
||||
Config.Client.SetSessionInformation(Config.GuestTestSessionId, SessionType.GuestSession);
|
||||
await TestMethodsHelper.SetValidateRemoveTest(async () =>
|
||||
{
|
||||
Assert.True(await TMDbClient.TvShowSetRatingAsync(IdHelper.House, 7.5));
|
||||
}, async () =>
|
||||
{
|
||||
Assert.True(await TMDbClient.TvShowRemoveRatingAsync(IdHelper.House));
|
||||
}, async shouldBeSet =>
|
||||
{
|
||||
SearchContainer<SearchTvShowWithRating> ratings = await TMDbClient.GetGuestSessionRatedTvAsync();
|
||||
|
||||
// Try changing the rating
|
||||
Assert.True(Config.Client.TvShowSetRatingAsync(IdHelper.House, 7.5).Result);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
SearchContainer<SearchTvShowWithRating> ratings = Config.Client.GetGuestSessionRatedTvAsync().Sync();
|
||||
|
||||
double tmpRating = ratings.Results.Single(s => s.Id == IdHelper.House).Rating;
|
||||
Assert.True(ratings.Results.Any(s => s.Id == IdHelper.House));
|
||||
Assert.True(Math.Abs(7.5 - tmpRating) < float.Epsilon);
|
||||
|
||||
// Try changing it back to the previous rating
|
||||
Assert.True(Config.Client.TvShowSetRatingAsync(IdHelper.House, 8).Result);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
ratings = Config.Client.GetGuestSessionRatedTvAsync().Sync();
|
||||
|
||||
tmpRating = ratings.Results.Single(s => s.Id == IdHelper.House).Rating;
|
||||
Assert.True(ratings.Results.Any(s => s.Id == IdHelper.House));
|
||||
Assert.True(Math.Abs(8 - tmpRating) < float.Epsilon);
|
||||
|
||||
// Try removing the rating
|
||||
Assert.True(Config.Client.TvShowRemoveRatingAsync(IdHelper.House).Result);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
ratings = Config.Client.GetGuestSessionRatedTvAsync().Sync();
|
||||
|
||||
Assert.False(ratings.Results.Any(s => s.Id == IdHelper.House));
|
||||
if (shouldBeSet)
|
||||
Assert.Contains(ratings.Results, x => x.Id == IdHelper.House);
|
||||
else
|
||||
Assert.DoesNotContain(ratings.Results, x => x.Id == IdHelper.House);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestMoviesSetRatingGuestSession()
|
||||
public async Task TestMoviesSetRatingGuestSessionAsync()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.GuestTestSessionId, SessionType.GuestSession);
|
||||
|
||||
Config.Client.SetSessionInformation(Config.GuestTestSessionId, SessionType.GuestSession);
|
||||
|
||||
// Try changing the rating
|
||||
Assert.True(Config.Client.MovieSetRatingAsync(IdHelper.Terminator, 7.5).Result);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
SearchContainer<SearchMovieWithRating> ratings = Config.Client.GetGuestSessionRatedMoviesAsync().Sync();
|
||||
|
||||
double tmpRating = ratings.Results.Single(s => s.Id == IdHelper.Terminator).Rating;
|
||||
Assert.True(ratings.Results.Any(s => s.Id == IdHelper.Terminator));
|
||||
Assert.True(Math.Abs(7.5 - tmpRating) < float.Epsilon);
|
||||
|
||||
// Try changing it back to the previous rating
|
||||
Assert.True(Config.Client.MovieSetRatingAsync(IdHelper.Terminator, 8).Result);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
ratings = Config.Client.GetGuestSessionRatedMoviesAsync().Sync();
|
||||
|
||||
tmpRating = ratings.Results.Single(s => s.Id == IdHelper.Terminator).Rating;
|
||||
Assert.True(ratings.Results.Any(s => s.Id == IdHelper.Terminator));
|
||||
Assert.True(Math.Abs(8 - tmpRating) < float.Epsilon);
|
||||
|
||||
// Try removing the rating
|
||||
Assert.True(Config.Client.MovieRemoveRatingAsync(IdHelper.Terminator).Result);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
ratings = Config.Client.GetGuestSessionRatedMoviesAsync().Sync();
|
||||
|
||||
Assert.False(ratings.Results.Any(s => s.Id == IdHelper.Terminator));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestGuestSessionGetRatedTvEpisodes()
|
||||
await TestMethodsHelper.SetValidateRemoveTest(async () =>
|
||||
{
|
||||
Config.Client.SetSessionInformation(Config.GuestTestSessionId, SessionType.GuestSession);
|
||||
|
||||
// Ensure we have a rating
|
||||
Assert.True(Config.Client.TvEpisodeSetRatingAsync(IdHelper.BigBangTheory, 1, 1, 7.5).Result);
|
||||
|
||||
// Test paging
|
||||
TestHelpers.SearchPages(i => Config.Client.GetGuestSessionRatedTvEpisodesAsync(i).Result);
|
||||
|
||||
// Fetch ratings
|
||||
SearchContainer<TvEpisodeWithRating> result = Config.Client.GetGuestSessionRatedTvEpisodesAsync().Sync();
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.Results);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestGuestSessionGetRatedTv()
|
||||
Assert.True(await TMDbClient.MovieSetRatingAsync(IdHelper.Terminator, 7.5));
|
||||
}, async () =>
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
|
||||
Config.Client.SetSessionInformation(Config.GuestTestSessionId, SessionType.GuestSession);
|
||||
|
||||
// Ensure we have a rating
|
||||
Assert.True(Config.Client.TvShowSetRatingAsync(IdHelper.BigBangTheory, 7.5).Result);
|
||||
|
||||
// Test paging
|
||||
TestHelpers.SearchPages(i => Config.Client.GetGuestSessionRatedTvAsync(i).Result);
|
||||
|
||||
// Fetch ratings
|
||||
SearchContainer<SearchTvShowWithRating> result = Config.Client.GetGuestSessionRatedTvAsync().Sync();
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.Results);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestGuestSessionGetRatedMovies()
|
||||
Assert.True(await TMDbClient.MovieRemoveRatingAsync(IdHelper.Terminator));
|
||||
}, async shouldBeSet =>
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
SearchContainer<SearchMovieWithRating> ratings = await TMDbClient.GetGuestSessionRatedMoviesAsync();
|
||||
|
||||
Config.Client.SetSessionInformation(Config.GuestTestSessionId, SessionType.GuestSession);
|
||||
|
||||
// Ensure we have a rating
|
||||
Assert.True(Config.Client.MovieSetRatingAsync(IdHelper.Terminator, 7.5).Result);
|
||||
|
||||
// Test paging
|
||||
TestHelpers.SearchPages(i => Config.Client.GetGuestSessionRatedMoviesAsync(i).Result);
|
||||
|
||||
// Fetch ratings
|
||||
SearchContainer<SearchMovieWithRating> result = Config.Client.GetGuestSessionRatedMoviesAsync().Sync();
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.Results);
|
||||
if (shouldBeSet)
|
||||
Assert.Contains(ratings.Results, x => x.Id == IdHelper.Terminator);
|
||||
else
|
||||
Assert.DoesNotContain(ratings.Results, x => x.Id == IdHelper.Terminator);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Movies;
|
||||
@ -11,86 +12,48 @@ namespace TMDbLibTests
|
||||
public class ClientKeywordTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void TestKeywordGet()
|
||||
public async Task TestGetMovieKeywordsAsync()
|
||||
{
|
||||
KeywordsContainer keywords = Config.Client.GetMovieKeywordsAsync(IdHelper.AGoodDayToDieHard).Result;
|
||||
KeywordsContainer keywords = await TMDbClient.GetMovieKeywordsAsync(IdHelper.AGoodDayToDieHard);
|
||||
|
||||
Assert.NotNull(keywords);
|
||||
Assert.NotNull(keywords.Keywords);
|
||||
Assert.True(keywords.Keywords.Count > 0);
|
||||
|
||||
// Try to get all keywords
|
||||
foreach (Keyword testKeyword in keywords.Keywords)
|
||||
{
|
||||
Keyword getKeyword = Config.Client.GetKeywordAsync(testKeyword.Id).Result;
|
||||
|
||||
Assert.NotNull(getKeyword);
|
||||
|
||||
Assert.Equal(testKeyword.Id, getKeyword.Id);
|
||||
Assert.Equal(testKeyword.Name, getKeyword.Name);
|
||||
}
|
||||
await Verify(keywords);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestKeywordsMissing()
|
||||
public async Task TestGetTvShowKeywordsAsync()
|
||||
{
|
||||
KeywordsContainer keywords = Config.Client.GetMovieKeywordsAsync(IdHelper.MissingID).Result;
|
||||
ResultContainer<Keyword> keywords = await TMDbClient.GetTvShowKeywordsAsync(IdHelper.BigBangTheory);
|
||||
|
||||
await Verify(keywords);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TestKeywordGetSingle()
|
||||
{
|
||||
Keyword keyword = await TMDbClient.GetKeywordAsync(IdHelper.AgentKeyword);
|
||||
|
||||
await Verify(keyword);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TestKeywordsMissing()
|
||||
{
|
||||
KeywordsContainer keywords = await TMDbClient.GetMovieKeywordsAsync(IdHelper.MissingID);
|
||||
|
||||
Assert.Null(keywords);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestKeywordMovies()
|
||||
public async Task TestKeywordMovies()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
SearchContainerWithId<SearchMovie> movies = await TMDbClient.GetKeywordMoviesAsync(IdHelper.AgentKeyword);
|
||||
|
||||
KeywordsContainer keywords = Config.Client.GetMovieKeywordsAsync(IdHelper.AGoodDayToDieHard).Result;
|
||||
Assert.Equal(IdHelper.AgentKeyword, movies.Id);
|
||||
Assert.NotEmpty(movies.Results);
|
||||
|
||||
Assert.NotNull(keywords);
|
||||
Assert.NotNull(keywords.Keywords);
|
||||
Assert.True(keywords.Keywords.Count > 0);
|
||||
KeywordsContainer movie = await TMDbClient.GetMovieKeywordsAsync(movies.Results.First().Id);
|
||||
|
||||
// Get first keyword
|
||||
Keyword testKeyword = keywords.Keywords.First();
|
||||
|
||||
// Get movies
|
||||
SearchContainerWithId<SearchMovie> movies = Config.Client.GetKeywordMoviesAsync(testKeyword.Id).Result;
|
||||
SearchContainerWithId<SearchMovie> moviesItalian = Config.Client.GetKeywordMoviesAsync(testKeyword.Id, "it").Result;
|
||||
SearchContainerWithId<SearchMovie> moviesPage2 = Config.Client.GetKeywordMoviesAsync(testKeyword.Id, 2).Result;
|
||||
|
||||
Assert.NotNull(movies);
|
||||
Assert.NotNull(moviesItalian);
|
||||
Assert.NotNull(moviesPage2);
|
||||
|
||||
Assert.Equal(testKeyword.Id, movies.Id);
|
||||
Assert.Equal(testKeyword.Id, moviesItalian.Id);
|
||||
Assert.Equal(testKeyword.Id, moviesPage2.Id);
|
||||
|
||||
Assert.True(movies.Results.Count > 0);
|
||||
Assert.True(moviesItalian.Results.Count > 0);
|
||||
|
||||
if (movies.TotalResults > movies.Results.Count)
|
||||
Assert.True(moviesPage2.Results.Count > 0);
|
||||
else
|
||||
Assert.Equal(0, moviesPage2.Results.Count);
|
||||
|
||||
Assert.Equal(1, movies.Page);
|
||||
Assert.Equal(1, moviesItalian.Page);
|
||||
Assert.Equal(2, moviesPage2.Page);
|
||||
|
||||
// All titles on page 1 must be the same
|
||||
bool allTitlesIdentical = true;
|
||||
for (int index = 0; index < movies.Results.Count; index++)
|
||||
{
|
||||
Assert.Equal(movies.Results[index].Id, moviesItalian.Results[index].Id);
|
||||
|
||||
// At least one title must differ in title
|
||||
if (movies.Results[index].Title != moviesItalian.Results[index].Title)
|
||||
allTitlesIdentical = false;
|
||||
}
|
||||
|
||||
Assert.False(allTitlesIdentical);
|
||||
Assert.Contains(movie.Keywords, x => IdHelper.AgentKeyword == x.Id);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,154 +1,119 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TMDbLib.Client;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Lists;
|
||||
using TMDbLib.Objects.Movies;
|
||||
using TMDbLib.Objects.Search;
|
||||
using TMDbLibTests.Helpers;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
[Collection(nameof(ListFixturesCollection))]
|
||||
public class ClientListsTests : TestBase
|
||||
{
|
||||
private const string TestListId = "528349d419c2954bd21ca0a8";
|
||||
private const string EphemeralListPrefix = "TestListTMDbLib-";
|
||||
|
||||
[Fact]
|
||||
public void TestList()
|
||||
public async Task TestGetListAsync()
|
||||
{
|
||||
// Get list
|
||||
GenericList list = Config.Client.GetListAsync(TestListId).Result;
|
||||
GenericList list = await TMDbClient.GetListAsync(TestListId);
|
||||
|
||||
Assert.NotNull(list);
|
||||
Assert.Equal(TestListId, list.Id);
|
||||
Assert.Equal(list.ItemCount, list.Items.Count);
|
||||
|
||||
foreach (SearchMovie movieResult in list.Items)
|
||||
{
|
||||
Assert.NotNull(movieResult);
|
||||
|
||||
// Ensure all movies point to this list
|
||||
int page = 1;
|
||||
SearchContainer<ListResult> movieLists = Config.Client.GetMovieListsAsync(movieResult.Id).Result;
|
||||
while (movieLists != null)
|
||||
{
|
||||
// Check if the current result page contains the relevant list
|
||||
if (movieLists.Results.Any(s => s.Id == TestListId))
|
||||
{
|
||||
movieLists = null;
|
||||
continue;
|
||||
}
|
||||
|
||||
// See if there is an other page we could try, if not the test fails
|
||||
if (movieLists.Page < movieLists.TotalPages)
|
||||
movieLists = Config.Client.GetMovieListsAsync(movieResult.Id, ++page).Result;
|
||||
else
|
||||
throw new Exception($"Movie '{movieResult.Title}' was not linked to the test list");
|
||||
}
|
||||
}
|
||||
await Verify(list);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestListMissing()
|
||||
public async Task TestListAsync()
|
||||
{
|
||||
GenericList list = Config.Client.GetListAsync(IdHelper.MissingID.ToString()).Result;
|
||||
SearchContainer<ListResult> movieLists = await TMDbClient.GetMovieListsAsync(IdHelper.Avatar);
|
||||
|
||||
Assert.NotEmpty(movieLists.Results);
|
||||
Assert.All(movieLists.Results, x => Assert.Equal(MediaType.Movie, x.ListType));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TestListMissingAsync()
|
||||
{
|
||||
GenericList list = await TMDbClient.GetListAsync(IdHelper.MissingID.ToString());
|
||||
|
||||
Assert.Null(list);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestListIsMoviePresentFailure()
|
||||
public async Task TestListCreateAddClearAndDeleteAsync()
|
||||
{
|
||||
Assert.False(Config.Client.GetListIsMoviePresentAsync(TestListId, IdHelper.Terminator).Result);
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
string listName = EphemeralListPrefix + DateTime.UtcNow.ToString("O");
|
||||
|
||||
// Clear list
|
||||
Assert.True(Config.Client.ListClearAsync(TestListId).Result);
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Verify Avatar is not present
|
||||
Assert.False(Config.Client.GetListIsMoviePresentAsync(TestListId, IdHelper.Avatar).Result);
|
||||
string listId = await TMDbClient.ListCreateAsync(listName);
|
||||
|
||||
// Add Avatar
|
||||
Assert.True(Config.Client.ListAddMovieAsync(TestListId, IdHelper.Avatar).Result);
|
||||
Assert.False(string.IsNullOrWhiteSpace(listId));
|
||||
|
||||
// Verify Avatar is present
|
||||
Assert.True(Config.Client.GetListIsMoviePresentAsync(TestListId, IdHelper.Avatar).Result);
|
||||
}
|
||||
GenericList newlyAddedList = await TMDbClient.GetListAsync(listId);
|
||||
|
||||
[Fact]
|
||||
public void TestListCreateAndDelete()
|
||||
{
|
||||
const string listName = "Test List 123";
|
||||
await Verify(newlyAddedList, settings => settings.IgnoreProperty<GenericList>(x => x.Id, x => x.Name));
|
||||
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
string newListId = Config.Client.ListCreateAsync(listName).Result;
|
||||
// Add a movie
|
||||
await TMDbClient.ListAddMovieAsync(listId, IdHelper.Avatar);
|
||||
await TMDbClient.ListAddMovieAsync(listId, IdHelper.AGoodDayToDieHard);
|
||||
|
||||
Assert.False(string.IsNullOrWhiteSpace(newListId));
|
||||
Assert.True(await TMDbClient.GetListIsMoviePresentAsync(listId, IdHelper.Avatar));
|
||||
|
||||
GenericList newlyAddedList = Config.Client.GetListAsync(newListId).Result;
|
||||
Assert.NotNull(newlyAddedList);
|
||||
Assert.Equal(listName, newlyAddedList.Name);
|
||||
Assert.Equal("", newlyAddedList.Description); // "" is the default value
|
||||
Assert.Equal("en", newlyAddedList.Iso_639_1); // en is the default value
|
||||
Assert.Equal(0, newlyAddedList.ItemCount);
|
||||
Assert.Equal(0, newlyAddedList.Items.Count);
|
||||
Assert.False(string.IsNullOrWhiteSpace(newlyAddedList.CreatedBy));
|
||||
// Remove a movie
|
||||
await TMDbClient.ListRemoveMovieAsync(listId, IdHelper.Avatar);
|
||||
|
||||
Assert.True(Config.Client.ListDeleteAsync(newListId).Result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestListDeleteFailure()
|
||||
{
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Try removing a list with an incorrect id
|
||||
Assert.False(Config.Client.ListDeleteAsync("bla").Result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestListAddAndRemoveMovie()
|
||||
{
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Add a new movie to the list
|
||||
Assert.True(Config.Client.ListAddMovieAsync(TestListId, IdHelper.EvanAlmighty).Result);
|
||||
|
||||
// Try again, this time it should fail since the list already contains this movie
|
||||
Assert.False(Config.Client.ListAddMovieAsync(TestListId, IdHelper.EvanAlmighty).Result);
|
||||
|
||||
// Get list and check if the item was added
|
||||
GenericList listAfterAdd = Config.Client.GetListAsync(TestListId).Result;
|
||||
Assert.True(listAfterAdd.Items.Any(m => m.Id == IdHelper.EvanAlmighty));
|
||||
|
||||
// Remove the previously added movie from the list
|
||||
Assert.True(Config.Client.ListRemoveMovieAsync(TestListId, IdHelper.EvanAlmighty).Result);
|
||||
|
||||
// Get list and check if the item was removed
|
||||
GenericList listAfterRemove = Config.Client.GetListAsync(TestListId).Result;
|
||||
Assert.False(listAfterRemove.Items.Any(m => m.Id == IdHelper.EvanAlmighty));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestListClear()
|
||||
{
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Add a new movie to the list
|
||||
Assert.True(Config.Client.ListAddMovieAsync(TestListId, IdHelper.MadMaxFuryRoad).Result);
|
||||
|
||||
// Get list and check if the item was added
|
||||
GenericList listAfterAdd = Config.Client.GetListAsync(TestListId).Result;
|
||||
Assert.True(listAfterAdd.Items.Any(m => m.Id == IdHelper.MadMaxFuryRoad));
|
||||
Assert.False(await TMDbClient.GetListIsMoviePresentAsync(listId, IdHelper.Avatar));
|
||||
|
||||
// Clear the list
|
||||
Assert.True(Config.Client.ListClearAsync(TestListId).Result);
|
||||
await TMDbClient.ListClearAsync(listId);
|
||||
|
||||
// Get list and check that all items were removed
|
||||
GenericList listAfterRemove = Config.Client.GetListAsync(TestListId).Result;
|
||||
Assert.False(listAfterRemove.Items.Any());
|
||||
Assert.False(await TMDbClient.GetListIsMoviePresentAsync(listId, IdHelper.AGoodDayToDieHard));
|
||||
|
||||
// Delete the list
|
||||
Assert.True(await TMDbClient.ListDeleteAsync(listId));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TestListDeleteFailureAsync()
|
||||
{
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Try removing a list with an incorrect id
|
||||
Assert.False(await TMDbClient.ListDeleteAsync("invalid_id"));
|
||||
}
|
||||
|
||||
private class ListCleanupFixture : IDisposable
|
||||
{
|
||||
public void Dispose()
|
||||
{
|
||||
TestConfig config = new TestConfig();
|
||||
TMDbClient client = config.Client;
|
||||
|
||||
client.SetSessionInformationAsync(config.UserSessionId, SessionType.UserSession).GetAwaiter().GetResult();
|
||||
|
||||
// Yes, this is only the first page, but that's fine.
|
||||
// Eventually we'll delete all remaining lists
|
||||
SearchContainer<AccountList> lists = client.AccountGetListsAsync().GetAwaiter().GetResult();
|
||||
|
||||
foreach (AccountList list in lists.Results.Where(s => s.Name.StartsWith(EphemeralListPrefix)))
|
||||
{
|
||||
client.ListDeleteAsync(list.Id.ToString()).GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CollectionDefinition(nameof(ListFixturesCollection))]
|
||||
public class ListFixturesCollection : ICollectionFixture<ListCleanupFixture>
|
||||
{
|
||||
// This class has no code, and is never created. Its purpose is simply
|
||||
// to be the place to apply [CollectionDefinition] and all the
|
||||
// ICollectionFixture<> interfaces.
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,5 @@
|
||||
using TMDbLib.Objects.General;
|
||||
using System.Threading.Tasks;
|
||||
using TMDbLib.Objects.General;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.TvShows;
|
||||
using TMDbLibTests.Helpers;
|
||||
@ -9,44 +10,33 @@ namespace TMDbLibTests
|
||||
public class ClientNetworkTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void TestNetworkGetById()
|
||||
public async Task TestNetworkGetByIdAsync()
|
||||
{
|
||||
Network network = Config.Client.GetNetworkAsync(IdHelper.Netflix).Result;
|
||||
Network network = await TMDbClient.GetNetworkAsync(IdHelper.Netflix);
|
||||
|
||||
Assert.NotNull(network);
|
||||
Assert.Equal("Netflix", network.Name);
|
||||
Assert.Equal(IdHelper.Netflix, network.Id);
|
||||
Assert.Equal("http://www.netflix.com", network.Homepage);
|
||||
Assert.Equal("Los Gatos, California, United States", network.Headquarters);
|
||||
await Verify(network);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestNetworkImages()
|
||||
public async Task TestNetworkImagesAsync()
|
||||
{
|
||||
IgnoreMissingCSharp("logos[array].file_type / file_type", "logos[array].id / id");
|
||||
IgnoreMissingJson("logos[array] / iso_639_1");
|
||||
NetworkLogos logos = Config.Client.GetNetworkImagesAsync(IdHelper.Netflix).Result;
|
||||
NetworkLogos logos = await TMDbClient.GetNetworkImagesAsync(IdHelper.Netflix);
|
||||
|
||||
Assert.NotNull(logos);
|
||||
Assert.Equal(IdHelper.Netflix, logos.Id);
|
||||
Assert.Equal("/wwemzKWzjKYJFfCeiB57q3r4Bcm.png", logos.Logos[0].FilePath);
|
||||
await Verify(logos);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestNetworkAlternativeNames()
|
||||
public async Task TestNetworkAlternativeNamesAsync()
|
||||
{
|
||||
AlternativeNames names = Config.Client.GetNetworkAlternativeNamesAsync(IdHelper.AMC).Result;
|
||||
AlternativeNames names = await TMDbClient.GetNetworkAlternativeNamesAsync(IdHelper.AMC);
|
||||
|
||||
Assert.NotNull(names);
|
||||
Assert.Equal(IdHelper.AMC, names.Id);
|
||||
Assert.Equal("American Movie Classics", names.Results[0].Name);
|
||||
Assert.Equal("1984–2002", names.Results[0].Type);
|
||||
await Verify(names);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestNetworkMissing()
|
||||
public async Task TestNetworkMissingAsync()
|
||||
{
|
||||
Network network = Config.Client.GetNetworkAsync(IdHelper.MissingID).Result;
|
||||
Network network = await TMDbClient.GetNetworkAsync(IdHelper.MissingID);
|
||||
|
||||
Assert.Null(network);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Changes;
|
||||
using TMDbLib.Objects.People;
|
||||
@ -13,11 +14,11 @@ namespace TMDbLibTests
|
||||
{
|
||||
public class ClientPersonTests : TestBase
|
||||
{
|
||||
private static Dictionary<PersonMethods, Func<Person, object>> _methods;
|
||||
private static readonly Dictionary<PersonMethods, Func<Person, object>> Methods;
|
||||
|
||||
public ClientPersonTests()
|
||||
static ClientPersonTests()
|
||||
{
|
||||
_methods = new Dictionary<PersonMethods, Func<Person, object>>
|
||||
Methods = new Dictionary<PersonMethods, Func<Person, object>>
|
||||
{
|
||||
[PersonMethods.MovieCredits] = person => person.MovieCredits,
|
||||
[PersonMethods.TvCredits] = person => person.TvCredits,
|
||||
@ -29,377 +30,142 @@ namespace TMDbLibTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestPersonsExtrasNone()
|
||||
public async Task TestPersonsExtrasNoneAsync()
|
||||
{
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
IgnoreMissingJson(" / changes", " / external_ids", " / images", " / movie_credits", " / tagged_images", " / tv_credits");
|
||||
|
||||
Person person = Config.Client.GetPersonAsync(IdHelper.BruceWillis).Result;
|
||||
|
||||
Assert.NotNull(person);
|
||||
|
||||
Assert.Equal("Bruce Willis", person.Name);
|
||||
Person person = await TMDbClient.GetPersonAsync(IdHelper.BruceWillis);
|
||||
|
||||
// Test all extras, ensure none of them exist
|
||||
foreach (Func<Person, object> selector in _methods.Values)
|
||||
{
|
||||
foreach (Func<Person, object> selector in Methods.Values)
|
||||
Assert.Null(selector(person));
|
||||
}
|
||||
|
||||
await Verify(person);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestPersonsExtrasExclusive()
|
||||
public async Task TestPersonsExtrasExclusive()
|
||||
{
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
IgnoreMissingJson(" / changes", " / external_ids", " / images", " / movie_credits", " / tagged_images", " / tv_credits", "external_ids / id", "images / id", "movie_credits / id", "tv_credits / id");
|
||||
|
||||
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => Config.Client.GetPersonAsync(id, extras).Result, IdHelper.BruceWillis);
|
||||
await TestMethodsHelper.TestGetExclusive(Methods, extras => TMDbClient.GetPersonAsync(IdHelper.BruceWillis, extras));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestPersonsExtrasAll()
|
||||
public async Task TestPersonsExtrasAllAsync()
|
||||
{
|
||||
IgnoreMissingJson("external_ids / id", "images / id", "movie_credits / id", "tv_credits / id");
|
||||
|
||||
PersonMethods combinedEnum = _methods.Keys.Aggregate((methods, movieMethods) => methods | movieMethods);
|
||||
Person item = Config.Client.GetPersonAsync(IdHelper.BruceWillis, combinedEnum).Result;
|
||||
|
||||
TestMethodsHelper.TestAllNotNull(_methods, item);
|
||||
await TestMethodsHelper.TestGetAll(Methods, combined => TMDbClient.GetPersonAsync(IdHelper.FrankSinatra, combined), async person => await Verify(person));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestPersonsGetWithPartialDate()
|
||||
public async Task TestPersonMissingAsync()
|
||||
{
|
||||
IgnoreMissingJson(" / changes", " / external_ids", " / images", " / movie_credits", " / tagged_images", " / tv_credits");
|
||||
|
||||
Person item = Config.Client.GetPersonAsync(IdHelper.PersonPartialDate).Result;
|
||||
|
||||
Assert.NotNull(item);
|
||||
Assert.Null(item.Birthday);
|
||||
Assert.Null(item.Deathday);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestPersonMissing()
|
||||
{
|
||||
Person person = Config.Client.GetPersonAsync(IdHelper.MissingID).Result;
|
||||
Person person = await TMDbClient.GetPersonAsync(IdHelper.MissingID);
|
||||
|
||||
Assert.Null(person);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestPersonsGet()
|
||||
public async Task TestPersonsGetPersonTvCreditsAsync()
|
||||
{
|
||||
IgnoreMissingJson(" / changes", " / external_ids", " / images", " / movie_credits", " / tagged_images", " / tv_credits");
|
||||
|
||||
Person item = Config.Client.GetPersonAsync(IdHelper.BruceWillis).Result;
|
||||
TvCredits item = await TMDbClient.GetPersonTvCreditsAsync(IdHelper.BruceWillis);
|
||||
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal(false, item.Adult);
|
||||
Assert.NotNull(item.Biography);
|
||||
Assert.Equal(PersonGender.Male, item.Gender);
|
||||
Assert.Equal(new DateTime(1955, 3, 19), item.Birthday);
|
||||
Assert.False(item.Deathday.HasValue);
|
||||
Assert.Equal("http://www.b-willis.com/", item.Homepage);
|
||||
Assert.Equal(62, item.Id);
|
||||
Assert.Equal("nm0000246", item.ImdbId);
|
||||
Assert.Equal("Bruce Willis", item.Name);
|
||||
Assert.Equal("Idar-Oberstein, Germany", item.PlaceOfBirth);
|
||||
Assert.True(item.Popularity > 0);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.ProfilePath), "item.ProfilePath was not a valid image path, was: " + item.ProfilePath);
|
||||
Assert.NotEmpty(item.Cast);
|
||||
Assert.NotEmpty(item.Crew);
|
||||
|
||||
Assert.NotNull(item.AlsoKnownAs);
|
||||
Assert.Equal(2, item.AlsoKnownAs.Count);
|
||||
Assert.True(item.AlsoKnownAs.Contains("Брюс Уиллис"));
|
||||
Assert.True(item.AlsoKnownAs.Contains("브루스 윌리스"));
|
||||
TvRole cast = item.Cast.Single(s => s.CreditId == "52571e7f19c2957114107d48");
|
||||
TvJob crew = item.Crew.Single(s => s.CreditId == "525826eb760ee36aaa81b23b");
|
||||
|
||||
await Verify(new
|
||||
{
|
||||
cast,
|
||||
crew
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestPersonsGetPersonTvCredits()
|
||||
public async Task TestGetPersonMovieCreditsAsync()
|
||||
{
|
||||
TvCredits item = Config.Client.GetPersonTvCreditsAsync(IdHelper.BruceWillis).Result;
|
||||
MovieCredits item = await TMDbClient.GetPersonMovieCreditsAsync(IdHelper.BruceWillis);
|
||||
|
||||
Assert.NotNull(item);
|
||||
Assert.NotNull(item.Cast);
|
||||
Assert.NotNull(item.Crew);
|
||||
Assert.NotEmpty(item.Cast);
|
||||
Assert.NotEmpty(item.Crew);
|
||||
|
||||
Assert.Equal(IdHelper.BruceWillis, item.Id);
|
||||
MovieRole cast = item.Cast.Single(s => s.CreditId == "52fe4329c3a36847f803f193");
|
||||
MovieJob crew = item.Crew.Single(s => s.CreditId == "52fe432ec3a36847f8040603");
|
||||
|
||||
TvRole cast = item.Cast.SingleOrDefault(s => s.Character == "David Addison Jr.");
|
||||
Assert.NotNull(cast);
|
||||
Assert.Equal("David Addison Jr.", cast.Character);
|
||||
Assert.Equal("52571e7f19c2957114107d48", cast.CreditId);
|
||||
Assert.Equal(71, cast.EpisodeCount);
|
||||
Assert.Equal(new DateTime(1985, 3, 3), cast.FirstAirDate);
|
||||
Assert.Equal(1998, cast.Id);
|
||||
Assert.Equal("Moonlighting", cast.Name);
|
||||
Assert.Equal("Moonlighting", cast.OriginalName);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(cast.PosterPath), "cast.PosterPath was not a valid image path, was: " + cast.PosterPath);
|
||||
|
||||
TvJob job = item.Crew.SingleOrDefault(s => s.CreditId == "525826eb760ee36aaa81b23b");
|
||||
Assert.NotNull(job);
|
||||
Assert.Equal("525826eb760ee36aaa81b23b", job.CreditId);
|
||||
Assert.Equal("Production", job.Department);
|
||||
Assert.Equal(37, job.EpisodeCount);
|
||||
Assert.Equal(new DateTime(1996, 9, 23), job.FirstAirDate);
|
||||
Assert.Equal(13297, job.Id);
|
||||
Assert.Equal("Producer", job.Job);
|
||||
Assert.Equal("Bruno the Kid", job.Name);
|
||||
Assert.Equal("Bruno the Kid", job.OriginalName);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(job.PosterPath), "job.PosterPath was not a valid image path, was: " + job.PosterPath);
|
||||
await Verify(new
|
||||
{
|
||||
cast,
|
||||
crew
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestPersonsGetPersonMovieCredits()
|
||||
public async Task TestGetPersonExternalIdsAsync()
|
||||
{
|
||||
MovieCredits item = Config.Client.GetPersonMovieCreditsAsync(IdHelper.BruceWillis).Result;
|
||||
ExternalIdsPerson item = await TMDbClient.GetPersonExternalIdsAsync(IdHelper.BruceWillis);
|
||||
|
||||
Assert.NotNull(item);
|
||||
Assert.NotNull(item.Cast);
|
||||
Assert.NotNull(item.Crew);
|
||||
|
||||
Assert.Equal(IdHelper.BruceWillis, item.Id);
|
||||
|
||||
MovieRole cast = item.Cast.SingleOrDefault(s => s.CreditId == "52fe4329c3a36847f803f193");
|
||||
Assert.NotNull(cast);
|
||||
Assert.Equal(false, cast.Adult);
|
||||
Assert.Equal("Lieutenant Muldoon", cast.Character);
|
||||
Assert.Equal("52fe4329c3a36847f803f193", cast.CreditId);
|
||||
Assert.Equal(1992, cast.Id);
|
||||
Assert.Equal("Planet Terror", cast.OriginalTitle);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(cast.PosterPath), "cast.PosterPath was not a valid image path, was: " + cast.PosterPath);
|
||||
Assert.Equal(new DateTime(2007, 4, 6), cast.ReleaseDate);
|
||||
Assert.Equal("Planet Terror", cast.Title);
|
||||
|
||||
MovieJob job = item.Crew.SingleOrDefault(s => s.CreditId == "52fe432ec3a36847f8040603");
|
||||
Assert.NotNull(job);
|
||||
Assert.Equal(false, job.Adult);
|
||||
Assert.Equal("52fe432ec3a36847f8040603", job.CreditId);
|
||||
Assert.Equal("Production", job.Department);
|
||||
Assert.Equal(2026, job.Id);
|
||||
Assert.Equal("Producer", job.Job);
|
||||
Assert.Equal(new DateTime(2005, 3, 9), job.ReleaseDate);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(job.PosterPath), "job.PosterPath was not a valid image path, was: " + job.PosterPath);
|
||||
Assert.Equal("Hostage", job.Title);
|
||||
Assert.Equal("Hostage", job.OriginalTitle);
|
||||
await Verify(item);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestPersonsGetPersonExternalIds()
|
||||
public async Task TestGetChangesPeopleAsync()
|
||||
{
|
||||
ExternalIdsPerson item = Config.Client.GetPersonExternalIdsAsync(IdHelper.BruceWillis).Result;
|
||||
SearchContainer<ChangesListItem> latestChanges = await TMDbClient.GetPeopleChangesAsync();
|
||||
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal(IdHelper.BruceWillis, item.Id);
|
||||
Assert.Equal("nm0000246", item.ImdbId);
|
||||
Assert.Equal("/m/0h7pj", item.FreebaseMid);
|
||||
Assert.Equal("/en/bruce_willis", item.FreebaseId);
|
||||
Assert.Equal("10183", item.TvrageId);
|
||||
Assert.Null(item.FacebookId);
|
||||
|
||||
item = Config.Client.GetPersonExternalIdsAsync(IdHelper.JoshACagan).Result;
|
||||
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal(IdHelper.JoshACagan, item.Id);
|
||||
Assert.Null(item.FacebookId);
|
||||
Assert.Equal("joshacagan", item.TwitterId);
|
||||
Assert.Equal("joshacagan", item.InstagramId);
|
||||
Assert.NotEmpty(latestChanges.Results);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestPersonsGetPersonCredits()
|
||||
public async Task TestGetPersonImagesAsync()
|
||||
{
|
||||
//GetPersonCredits(int id, string language)
|
||||
MovieCredits resp = Config.Client.GetPersonMovieCreditsAsync(IdHelper.BruceWillis).Result;
|
||||
Assert.NotNull(resp);
|
||||
ProfileImages images = await TMDbClient.GetPersonImagesAsync(IdHelper.BruceWillis);
|
||||
|
||||
MovieCredits respItalian = Config.Client.GetPersonMovieCreditsAsync(IdHelper.BruceWillis, "it").Result;
|
||||
Assert.NotNull(respItalian);
|
||||
ImageData image = images.Profiles.Single(s => s.FilePath == "/cPP5y15p6iU83MxQ3tEcbr5hqNR.jpg");
|
||||
await Verify(image);
|
||||
|
||||
Assert.Equal(resp.Cast.Count, respItalian.Cast.Count);
|
||||
Assert.Equal(resp.Crew.Count, respItalian.Crew.Count);
|
||||
Assert.Equal(resp.Id, respItalian.Id);
|
||||
|
||||
// There must be at least one movie with a different title
|
||||
bool allTitlesIdentical = true;
|
||||
for (int index = 0; index < resp.Cast.Count; index++)
|
||||
{
|
||||
Assert.Equal(resp.Cast[index].Id, respItalian.Cast[index].Id);
|
||||
Assert.Equal(resp.Cast[index].OriginalTitle, respItalian.Cast[index].OriginalTitle);
|
||||
|
||||
if (resp.Cast[index].Title != respItalian.Cast[index].Title)
|
||||
allTitlesIdentical = false;
|
||||
}
|
||||
|
||||
for (int index = 0; index < resp.Crew.Count; index++)
|
||||
{
|
||||
Assert.Equal(resp.Crew[index].Id, respItalian.Crew[index].Id);
|
||||
Assert.Equal(resp.Crew[index].OriginalTitle, respItalian.Crew[index].OriginalTitle);
|
||||
|
||||
if (resp.Crew[index].Title != respItalian.Crew[index].Title)
|
||||
allTitlesIdentical = false;
|
||||
}
|
||||
|
||||
Assert.False(allTitlesIdentical);
|
||||
TestImagesHelpers.TestImagePaths(images.Profiles);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestPersonsGetPersonChanges()
|
||||
public async Task TestPersonsTaggedImagesAsync()
|
||||
{
|
||||
// Not all ChangeItem's have an iso_639_1
|
||||
IgnoreMissingJson(" / iso_639_1", " / value");
|
||||
SearchContainer<TaggedImage> images = await TMDbClient.GetPersonTaggedImagesAsync(IdHelper.BruceWillis, 1);
|
||||
|
||||
// FindAsync latest changed person
|
||||
SearchContainer<ChangesListItem> latestChanges = Config.Client.GetChangesPeopleAsync().Sync();
|
||||
int latestChanged = latestChanges.Results.Last().Id;
|
||||
Assert.NotEmpty(images.Results);
|
||||
|
||||
// Fetch changelog
|
||||
DateTime lower = DateTime.UtcNow.AddDays(-14);
|
||||
DateTime higher = DateTime.UtcNow;
|
||||
List<Change> respRange = Config.Client.GetPersonChangesAsync(latestChanged, lower, higher).Result;
|
||||
TestImagesHelpers.TestImagePaths(images.Results);
|
||||
|
||||
Assert.NotNull(respRange);
|
||||
Assert.True(respRange.Count > 0);
|
||||
TaggedImage image = images.Results.Single(s => s.FilePath == "/svIDTNUoajS8dLEo7EosxvyAsgJ.jpg");
|
||||
|
||||
// As TMDb works in days, we need to adjust our values also
|
||||
lower = lower.AddDays(-1);
|
||||
higher = higher.AddDays(1);
|
||||
|
||||
foreach (Change change in respRange)
|
||||
foreach (ChangeItemBase changeItem in change.Items)
|
||||
{
|
||||
DateTime date = changeItem.Time;
|
||||
Assert.True(lower <= date);
|
||||
Assert.True(date <= higher);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestPersonsImages()
|
||||
{
|
||||
// Get config
|
||||
Config.Client.GetConfigAsync().Sync();
|
||||
|
||||
// Get images
|
||||
ProfileImages images = Config.Client.GetPersonImagesAsync(IdHelper.BruceWillis).Result;
|
||||
|
||||
Assert.NotNull(images);
|
||||
Assert.NotNull(images.Profiles);
|
||||
Assert.Equal(IdHelper.BruceWillis, images.Id);
|
||||
|
||||
// Test image url generator
|
||||
TestImagesHelpers.TestImages(Config, images);
|
||||
|
||||
ImageData image = images.Profiles.SingleOrDefault(s => s.FilePath == "/kI1OluWhLJk3pnR19VjOfABpnTY.jpg");
|
||||
|
||||
Assert.NotNull(image);
|
||||
Assert.True(Math.Abs(0.666666666666667 - image.AspectRatio) < double.Epsilon);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(image.FilePath), "image.FilePath was not a valid image path, was: " + image.FilePath);
|
||||
Assert.Equal(1500, image.Height);
|
||||
Assert.Null(image.Iso_639_1);
|
||||
Assert.Equal(1000, image.Width);
|
||||
Assert.True(image.VoteAverage > 0);
|
||||
Assert.True(image.VoteCount > 0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestPersonsTaggedImages()
|
||||
{
|
||||
// Get config
|
||||
Config.Client.GetConfigAsync().Sync();
|
||||
|
||||
// Get images
|
||||
TestHelpers.SearchPages(i => Config.Client.GetPersonTaggedImagesAsync(IdHelper.BruceWillis, i).Result);
|
||||
|
||||
SearchContainer<TaggedImage> images = Config.Client.GetPersonTaggedImagesAsync(IdHelper.BruceWillis, 1).Result;
|
||||
|
||||
Assert.NotNull(images);
|
||||
Assert.NotNull(images.Results);
|
||||
|
||||
TaggedImage image = images.Results.SingleOrDefault(s => s.FilePath == "/my81Hjt7NpZhaMX9bHi4wVhFy0v.jpg");
|
||||
|
||||
Assert.NotNull(image);
|
||||
Assert.True(Math.Abs(1.77777777777778 - image.AspectRatio) < double.Epsilon);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(image.FilePath), "image.FilePath was not a valid image path, was: " + image.FilePath);
|
||||
Assert.Equal(1080, image.Height);
|
||||
Assert.Equal("4ea5d0792c058837cb000431", image.Id);
|
||||
Assert.Null(image.Iso_639_1);
|
||||
Assert.True(image.VoteAverage > 0);
|
||||
Assert.True(image.VoteCount > 0);
|
||||
Assert.Equal(1920, image.Width);
|
||||
Assert.Equal("backdrop", image.ImageType);
|
||||
Assert.Equal(MediaType.Movie, image.MediaType);
|
||||
|
||||
Assert.NotNull(image.Media);
|
||||
Assert.IsType<SearchMovie>(image.Media);
|
||||
|
||||
SearchMovie mediaBase = (SearchMovie)image.Media;
|
||||
Assert.Equal(false, mediaBase.Adult);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(mediaBase.BackdropPath), "image.Media.BackdropPath was not a valid image path, was: " + mediaBase.BackdropPath);
|
||||
Assert.Equal(187, mediaBase.Id);
|
||||
Assert.Equal("en", mediaBase.OriginalLanguage);
|
||||
Assert.Equal("Sin City", mediaBase.OriginalTitle);
|
||||
Assert.Equal("Welcome to Sin City. This town beckons to the tough, the corrupt, the brokenhearted. Some call it dark… Hard-boiled. Then there are those who call it home — Crooked cops, sexy dames, desperate vigilantes. Some are seeking revenge, others lust after redemption, and then there are those hoping for a little of both. A universe of unlikely and reluctant heroes still trying to do the right thing in a city that refuses to care.", mediaBase.Overview);
|
||||
Assert.Equal(new DateTime(2005, 3, 31), mediaBase.ReleaseDate);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(mediaBase.PosterPath), "image.Media.PosterPath was not a valid image path, was: " + mediaBase.PosterPath);
|
||||
Assert.True(mediaBase.Popularity > 0);
|
||||
Assert.Equal("Sin City", mediaBase.Title);
|
||||
Assert.Equal(false, mediaBase.Video);
|
||||
Assert.True(mediaBase.VoteAverage > 0);
|
||||
Assert.True(mediaBase.VoteCount > 0);
|
||||
|
||||
Assert.NotNull(mediaBase.GenreIds);
|
||||
Assert.Equal(3, mediaBase.GenreIds.Count);
|
||||
Assert.True(mediaBase.GenreIds.Contains(28));
|
||||
Assert.True(mediaBase.GenreIds.Contains(53));
|
||||
Assert.True(mediaBase.GenreIds.Contains(80));
|
||||
await Verify(image);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestPersonsList()
|
||||
public async Task TestPersonsListAsync()
|
||||
{
|
||||
foreach (PersonListType type in Enum.GetValues(typeof(PersonListType)).OfType<PersonListType>())
|
||||
{
|
||||
SearchContainer<PersonResult> list = Config.Client.GetPersonListAsync(type).Result;
|
||||
SearchContainer<PersonResult> list = await TMDbClient.GetPersonListAsync(type);
|
||||
|
||||
Assert.NotNull(list);
|
||||
Assert.True(list.Results.Count > 0);
|
||||
Assert.Equal(1, list.Page);
|
||||
|
||||
SearchContainer<PersonResult> listPage2 = Config.Client.GetPersonListAsync(type, 2).Result;
|
||||
|
||||
Assert.NotNull(listPage2);
|
||||
Assert.True(listPage2.Results.Count > 0);
|
||||
Assert.Equal(2, listPage2.Page);
|
||||
|
||||
SearchContainer<PersonResult> list2 = Config.Client.GetPersonListAsync(type).Result;
|
||||
|
||||
Assert.NotNull(list2);
|
||||
Assert.True(list2.Results.Count > 0);
|
||||
Assert.Equal(1, list2.Page);
|
||||
|
||||
// At least one person should differ
|
||||
Assert.True(list.Results.Any(s => list2.Results.Any(x => x.Name != s.Name)));
|
||||
Assert.NotEmpty(list.Results);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestGetLatestPerson()
|
||||
public async Task TestGetLatestPersonAsync()
|
||||
{
|
||||
IgnoreMissingJson(" / changes", " / external_ids", " / images", " / movie_credits", " / tagged_images", " / tv_credits");
|
||||
Person item = await TMDbClient.GetLatestPersonAsync();
|
||||
|
||||
Person item = Config.Client.GetLatestPersonAsync().Sync();
|
||||
Assert.NotNull(item);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestGetTranslatedPerson()
|
||||
public async Task TestGetTranslatedPersonAsync()
|
||||
{
|
||||
IgnoreMissingCSharp("known_for_department / known_for_department");
|
||||
IgnoreMissingJson(" / changes", " / external_ids", " / images", " / movie_credits", " / tagged_images", " / tv_credits");
|
||||
Person person = Config.Client.GetPersonAsync(1019, "da").Result;
|
||||
Assert.NotNull(person);
|
||||
Assert.Equal("Mads Dittmann Mikkelsen, der er søn af fuldmægtig Henning Mikkelsen og hustru sygehjælper Bente Christiansen, voksede op på Nørrebro i København. I 11 år var han gymnast og gymnastikinstruktør i Gymnastikforeningen Gefion. Efter studentereksamen tilmeldte han sig et dansekursus for arbejdsløse. Det blev siden til otte års professionelt engagement i danseensemblet Mikado og han var to gange på Martha Grahams sommerskole i New York. Senere blev han også vikar for Vicky Leander på Daghøjskolen for dansk, drama og musik. Han blev skuespilleruddannet fra Århus Teaterskole i 1996 og debuterede som førsteelsker i \"Kunst\" på Århus Teater. Mads Mikkelsen har bl.a. stået på scenen i \"Paradis\" (1997), \"Længe siden\" (1999) og \"Fiaskospiralen\" (1999) på Dr. Dante’s Aveny samt \"Romeo og Julie\" (1998) på Østre Gasværk. Han filmdebuterede allerede i 1995 med en af hovedrollerne i novellefilmen \"Blomsterfangen\" I 1996 fik han sit store kunstneriske filmgennembrud som den kronragede slyngel Tonny i den banebrydende og meget rå film \"Pusher\". Han havde den ene af hovedrollerne i den danske film \"Vildspor\", rollen som Lenny i \"Bleeder\" og huskes som den våbengale Arne i Anders Thomas Jensens første spillefilm \"Blinkende Lygter\" (2000), der blev det helt store biografhit. I 2001 fik han også fænomenal succes i Hella Joofs biograffilm \"En kort, en lang\", hvor han spillede bøssen Jacob over for Troels Lyby. Siden 2005 har han haft international succes i film som \"King Arthur\" og især som storskurken Le Chiffre i James Bond- filmen \"Casino Royale\" fra 2006. I DR\'s politiserie \"Rejseholdet\" fik han sit folkelige gennembrud som politimanden Allan Fischer. Han er bror til skuespilleren Lars Mikkelsen. Mads Mikkelsen blev den 2. december 2000 gift med danserinde og koreograf Hanne Jacobsen (13-01-1961) og sammen har de to børn.", person.Biography);
|
||||
Person person = await TMDbClient.GetPersonAsync(IdHelper.BruceWillis, "da");
|
||||
|
||||
await Verify(person);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
using Xunit;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Reviews;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLibTests.Helpers;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
|
||||
@ -9,25 +9,17 @@ namespace TMDbLibTests
|
||||
public class ClientReviewTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void TestReviewFullDetails()
|
||||
public async Task TestReviewFullDetails()
|
||||
{
|
||||
Review review = Config.Client.GetReviewAsync(IdHelper.TheDarkKnightRisesReviewId).Result;
|
||||
Review review = await TMDbClient.GetReviewAsync(IdHelper.TheDarkKnightRisesReviewId);
|
||||
|
||||
Assert.NotNull(review);
|
||||
|
||||
Assert.Equal(IdHelper.TheDarkKnightRisesReviewId, review.Id);
|
||||
Assert.Equal(49026, review.MediaId);
|
||||
Assert.Equal("The Dark Knight Rises", review.MediaTitle);
|
||||
Assert.Equal("Travis Bell", review.Author);
|
||||
Assert.Equal("en", review.Iso_639_1);
|
||||
Assert.Equal("https://www.themoviedb.org/review/5010553819c2952d1b000451", review.Url);
|
||||
Assert.Equal(MediaType.Movie, review.MediaType);
|
||||
await Verify(review);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestReviewMissing()
|
||||
public async Task TestReviewMissing()
|
||||
{
|
||||
Review review = Config.Client.GetReviewAsync(IdHelper.MissingID.ToString()).Result;
|
||||
Review review = await TMDbClient.GetReviewAsync(IdHelper.MissingID.ToString());
|
||||
|
||||
Assert.Null(review);
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using Xunit;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Search;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TMDbLibTests.Helpers;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
|
||||
@ -11,194 +11,94 @@ namespace TMDbLibTests
|
||||
public class ClientSearchTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void TestSearchMovie()
|
||||
public async Task TestSearchMovieAsync()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
|
||||
TestHelpers.SearchPages(i => Config.Client.SearchMovieAsync("007", i).Result);
|
||||
await TestHelpers.SearchPagesAsync(i => TMDbClient.SearchMovieAsync("007", i));
|
||||
|
||||
// Search pr. Year
|
||||
// 1962: First James Bond movie, "Dr. No"
|
||||
SearchContainer<SearchMovie> result = Config.Client.SearchMovieAsync("007", year: 1962).Result;
|
||||
SearchContainer<SearchMovie> result = await TMDbClient.SearchMovieAsync("007", year: 1962);
|
||||
SearchMovie item = result.Results.Single(s => s.Id == 646);
|
||||
|
||||
Assert.True(result.Results.Any());
|
||||
SearchMovie item = result.Results.SingleOrDefault(s => s.Id == 646);
|
||||
await Verify(item);
|
||||
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal(646, item.Id);
|
||||
Assert.Equal(false, item.Adult);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.BackdropPath), "item.BackdropPath was not a valid image path, was: " + item.BackdropPath);
|
||||
Assert.Equal("en", item.OriginalLanguage);
|
||||
Assert.Equal("Dr. No", item.OriginalTitle);
|
||||
Assert.Equal("In the film that launched the James Bond saga, Agent 007 battles mysterious Dr. No, a scientific genius bent on destroying the U.S. space program. As the countdown to disaster begins, Bond must go to Jamaica, where he encounters beautiful Honey Ryder, to confront a megalomaniacal villain in his massive island headquarters.", item.Overview);
|
||||
Assert.Equal(false, item.Video);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
Assert.Equal(new DateTime(1962, 10, 4), item.ReleaseDate);
|
||||
Assert.Equal("Dr. No", item.Title);
|
||||
Assert.True(item.Popularity > 0);
|
||||
Assert.True(item.VoteAverage > 0);
|
||||
Assert.True(item.VoteCount > 0);
|
||||
|
||||
Assert.NotNull(item.GenreIds);
|
||||
Assert.True(item.GenreIds.Contains(12));
|
||||
Assert.True(item.GenreIds.Contains(28));
|
||||
Assert.True(item.GenreIds.Contains(53));
|
||||
TestImagesHelpers.TestImagePaths(new[] { item.BackdropPath, item.PosterPath });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestSearchCollection()
|
||||
public async Task TestSearchCollectionAsync()
|
||||
{
|
||||
TestHelpers.SearchPages(i => Config.Client.SearchCollectionAsync("007", i).Result);
|
||||
await TestHelpers.SearchPagesAsync(i => TMDbClient.SearchCollectionAsync("007", i));
|
||||
|
||||
SearchContainer<SearchCollection> result = Config.Client.SearchCollectionAsync("James Bond").Result;
|
||||
SearchContainer<SearchCollection> result = await TMDbClient.SearchCollectionAsync("James Bond");
|
||||
SearchCollection item = result.Results.Single(s => s.Id == 645);
|
||||
|
||||
Assert.True(result.Results.Any());
|
||||
SearchCollection item = result.Results.SingleOrDefault(s => s.Id == 645);
|
||||
await Verify(item);
|
||||
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal(645, item.Id);
|
||||
Assert.Equal("James Bond Collection", item.Name);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.BackdropPath), "item.BackdropPath was not a valid image path, was: " + item.BackdropPath);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
TestImagesHelpers.TestImagePaths(new[] { item.BackdropPath, item.PosterPath });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestSearchPerson()
|
||||
public async Task TestSearchPersonAsync()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
await TestHelpers.SearchPagesAsync(i => TMDbClient.SearchPersonAsync("Willis", i));
|
||||
|
||||
TestHelpers.SearchPages(i => Config.Client.SearchPersonAsync("Willis", i).Result);
|
||||
SearchContainer<SearchPerson> result = await TMDbClient.SearchPersonAsync("Willis");
|
||||
SearchPerson item = result.Results.Single(s => s.Id == 62);
|
||||
|
||||
SearchContainer<SearchPerson> result = Config.Client.SearchPersonAsync("Willis").Result;
|
||||
await Verify(item);
|
||||
|
||||
Assert.True(result.Results.Any());
|
||||
SearchPerson item = result.Results.SingleOrDefault(s => s.Id == 62);
|
||||
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal(62, item.Id);
|
||||
Assert.Equal("Bruce Willis", item.Name);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.ProfilePath), "item.ProfilePath was not a valid image path, was: " + item.ProfilePath);
|
||||
Assert.Equal(false, item.Adult);
|
||||
Assert.True(item.Popularity > 0);
|
||||
|
||||
Assert.NotNull(item.KnownFor);
|
||||
Assert.True(item.KnownFor.Any(s => s.Id == 680));
|
||||
TestImagesHelpers.TestImagePaths(new[] { item.ProfilePath });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestSearchList()
|
||||
public async Task TestSearchCompanyAsync()
|
||||
{
|
||||
TestHelpers.SearchPages(i => Config.Client.SearchListAsync("to watch", i).Result);
|
||||
await TestHelpers.SearchPagesAsync(i => TMDbClient.SearchCompanyAsync("20th", i));
|
||||
|
||||
SearchContainer<SearchList> result = Config.Client.SearchListAsync("to watch").Result;
|
||||
SearchContainer<SearchCompany> result = await TMDbClient.SearchCompanyAsync("20th");
|
||||
SearchCompany item = result.Results.Single(s => s.Id == 25);
|
||||
|
||||
Assert.True(result.Results.Any());
|
||||
SearchList item = result.Results.SingleOrDefault(s => s.Id == "54a5c0ceaed56c28c300013a");
|
||||
await Verify(item);
|
||||
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal("to watch", item.Description);
|
||||
Assert.Equal("54a5c0ceaed56c28c300013a", item.Id);
|
||||
Assert.Equal("en", item.Iso_639_1);
|
||||
Assert.Equal("movie", item.ListType);
|
||||
Assert.Equal("Movies", item.Name);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
Assert.True(item.FavoriteCount > 0);
|
||||
Assert.True(item.ItemCount > 0);
|
||||
TestImagesHelpers.TestImagePaths(new[] { item.LogoPath });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestSearchCompany()
|
||||
public async Task TestSearchKeywordAsync()
|
||||
{
|
||||
TestHelpers.SearchPages(i => Config.Client.SearchCompanyAsync("20th", i).Result);
|
||||
await TestHelpers.SearchPagesAsync(i => TMDbClient.SearchKeywordAsync("plot", i));
|
||||
|
||||
SearchContainer<SearchCompany> result = Config.Client.SearchCompanyAsync("20th").Result;
|
||||
SearchContainer<SearchKeyword> result = await TMDbClient.SearchKeywordAsync("plot");
|
||||
SearchKeyword item = result.Results.Single(s => s.Id == 11121);
|
||||
|
||||
Assert.True(result.Results.Any());
|
||||
SearchCompany item = result.Results.SingleOrDefault(s => s.Id == 25);
|
||||
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal(25, item.Id);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.LogoPath), "item.LogoPath was not a valid image path, was: " + item.LogoPath);
|
||||
Assert.Equal("20th Century Fox", item.Name);
|
||||
await Verify(item);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestSearchKeyword()
|
||||
public async Task TestSearchTvShowAsync()
|
||||
{
|
||||
TestHelpers.SearchPages(i => Config.Client.SearchKeywordAsync("plot", i).Result);
|
||||
await TestHelpers.SearchPagesAsync(i => TMDbClient.SearchTvShowAsync("Breaking Bad", i));
|
||||
|
||||
SearchContainer<SearchKeyword> result = Config.Client.SearchKeywordAsync("plot").Result;
|
||||
SearchContainer<SearchTv> result = await TMDbClient.SearchTvShowAsync("Breaking Bad");
|
||||
SearchTv item = result.Results.Single(s => s.Id == 1396);
|
||||
|
||||
Assert.True(result.Results.Any());
|
||||
SearchKeyword item = result.Results.SingleOrDefault(s => s.Id == 11121);
|
||||
await Verify(item);
|
||||
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal(11121, item.Id);
|
||||
Assert.Equal("plot", item.Name);
|
||||
TestImagesHelpers.TestImagePaths(new[] { item.BackdropPath, item.PosterPath });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestSearchTvShow()
|
||||
public async Task TestSearchMultiAsync()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
await TestHelpers.SearchPagesAsync(i => TMDbClient.SearchMultiAsync("Arrow", i));
|
||||
|
||||
TestHelpers.SearchPages(i => Config.Client.SearchTvShowAsync("Breaking Bad", i).Result);
|
||||
SearchContainer<SearchBase> result = await TMDbClient.SearchMultiAsync("Arrow");
|
||||
SearchTv item = result.Results.OfType<SearchTv>().Single(s => s.Id == 1412);
|
||||
|
||||
SearchContainer<SearchTv> result = Config.Client.SearchTvShowAsync("Breaking Bad").Result;
|
||||
await Verify(item);
|
||||
|
||||
Assert.True(result.Results.Any());
|
||||
SearchTv item = result.Results.SingleOrDefault(s => s.Id == 1396);
|
||||
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal(1396, item.Id);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.BackdropPath), "item.BackdropPath was not a valid image path, was: " + item.BackdropPath);
|
||||
Assert.Equal(new DateTime(2008, 1, 19), item.FirstAirDate);
|
||||
Assert.Equal("Breaking Bad", item.Name);
|
||||
Assert.Equal("Breaking Bad", item.OriginalName);
|
||||
Assert.Equal("en", item.OriginalLanguage);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
Assert.Equal("Breaking Bad is an American crime drama television series created and produced by Vince Gilligan. Set and produced in Albuquerque, New Mexico, Breaking Bad is the story of Walter White, a struggling high school chemistry teacher who is diagnosed with inoperable lung cancer at the beginning of the series. He turns to a life of crime, producing and selling methamphetamine, in order to secure his family's financial future before he dies, teaming with his former student, Jesse Pinkman. Heavily serialized, the series is known for positioning its characters in seemingly inextricable corners and has been labeled a contemporary western by its creator.", item.Overview);
|
||||
Assert.True(item.Popularity > 0);
|
||||
Assert.True(item.VoteAverage > 0);
|
||||
Assert.True(item.VoteCount > 0);
|
||||
|
||||
Assert.NotNull(item.GenreIds);
|
||||
Assert.Equal(1, item.GenreIds.Count);
|
||||
Assert.Equal(18, item.GenreIds[0]);
|
||||
|
||||
Assert.NotNull(item.OriginCountry);
|
||||
Assert.Equal(1, item.OriginCountry.Count);
|
||||
Assert.Equal("US", item.OriginCountry[0]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestSearchMulti()
|
||||
{
|
||||
TestHelpers.SearchPages(i => Config.Client.SearchMultiAsync("Arrow", i).Result);
|
||||
|
||||
SearchContainer<SearchBase> result = Config.Client.SearchMultiAsync("Arrow").Result;
|
||||
|
||||
Assert.True(result.Results.Any());
|
||||
SearchTv item = result.Results.OfType<SearchTv>().SingleOrDefault(s => s.Id == 1412);
|
||||
|
||||
Assert.NotNull(item);
|
||||
Assert.Equal(1412, item.Id);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.BackdropPath), "item.BackdropPath was not a valid image path, was: " + item.BackdropPath);
|
||||
Assert.Equal(new DateTime(2012, 10, 10), item.FirstAirDate);
|
||||
Assert.Equal(MediaType.Tv, item.MediaType);
|
||||
Assert.Equal("Arrow", item.Name);
|
||||
Assert.Equal("Arrow", item.OriginalName);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
Assert.True(item.Popularity > 0);
|
||||
Assert.True(item.VoteAverage > 0);
|
||||
Assert.True(item.VoteCount > 0);
|
||||
|
||||
Assert.NotNull(item.OriginCountry);
|
||||
Assert.Equal(1, item.OriginCountry.Count);
|
||||
Assert.True(item.OriginCountry.Contains("US"));
|
||||
TestImagesHelpers.TestImagePaths(new[] { item.BackdropPath, item.PosterPath });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,31 +13,31 @@ namespace TMDbLibTests
|
||||
public class ClientTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void GetConfigTest()
|
||||
public async Task GetConfigTest()
|
||||
{
|
||||
Assert.False(Config.Client.HasConfig);
|
||||
Config.Client.GetConfigAsync().Sync();
|
||||
Assert.True(Config.Client.HasConfig);
|
||||
Assert.False(TMDbClient.HasConfig);
|
||||
await TMDbClient.GetConfigAsync();
|
||||
Assert.True(TMDbClient.HasConfig);
|
||||
|
||||
Assert.NotNull(Config.Client.Config);
|
||||
await Verify(TMDbClient.Config);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetConfigSslTest()
|
||||
public async Task GetConfigSslTest()
|
||||
{
|
||||
TestConfig config = new TestConfig(true);
|
||||
|
||||
Assert.False(config.Client.HasConfig);
|
||||
config.Client.GetConfigAsync().Sync();
|
||||
await config.Client.GetConfigAsync();
|
||||
Assert.True(config.Client.HasConfig);
|
||||
|
||||
Assert.NotNull(config.Client.Config);
|
||||
await Verify(config.Client.Config);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetConfigFailTest()
|
||||
{
|
||||
Assert.Throws<InvalidOperationException>(() => Config.Client.Config);
|
||||
Assert.Throws<InvalidOperationException>(() => TMDbClient.Config);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -49,53 +49,65 @@ namespace TMDbLibTests
|
||||
config.Images = new ConfigImageTypes();
|
||||
config.Images.BaseUrl = " ..";
|
||||
|
||||
Assert.False(Config.Client.HasConfig);
|
||||
Config.Client.SetConfig(config);
|
||||
Assert.True(Config.Client.HasConfig);
|
||||
Assert.False(TMDbClient.HasConfig);
|
||||
TMDbClient.SetConfig(config);
|
||||
Assert.True(TMDbClient.HasConfig);
|
||||
|
||||
Assert.Same(config, Config.Client.Config);
|
||||
Assert.Same(config, TMDbClient.Config);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ClientConstructorUrlTest()
|
||||
public async Task ClientConstructorUrlTest()
|
||||
{
|
||||
TMDbClient clientA = new TMDbClient(TestConfig.APIKey, false, "http://api.themoviedb.org") { MaxRetryCount = 2 };
|
||||
clientA.GetConfigAsync().Sync();
|
||||
await clientA.GetConfigAsync();
|
||||
|
||||
TMDbClient clientB = new TMDbClient(TestConfig.APIKey, true, "http://api.themoviedb.org") { MaxRetryCount = 2 };
|
||||
clientB.GetConfigAsync().Sync();
|
||||
await clientB.GetConfigAsync();
|
||||
|
||||
TMDbClient clientC = new TMDbClient(TestConfig.APIKey, false, "https://api.themoviedb.org") { MaxRetryCount = 2 };
|
||||
clientC.GetConfigAsync().Sync();
|
||||
await clientC.GetConfigAsync();
|
||||
|
||||
TMDbClient clientD = new TMDbClient(TestConfig.APIKey, true, "https://api.themoviedb.org") { MaxRetryCount = 2 };
|
||||
clientD.GetConfigAsync().Sync();
|
||||
await clientD.GetConfigAsync();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ClientSetBadMaxRetryValue()
|
||||
{
|
||||
TMDbClient client = new TMDbClient(TestConfig.APIKey);
|
||||
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => client.MaxRetryCount = -1);
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => TMDbClient.MaxRetryCount = -1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ClientRateLimitTest()
|
||||
public async Task ClientTestUrlGenerator()
|
||||
{
|
||||
const int id = IdHelper.AGoodDayToDieHard;
|
||||
await TMDbClient.GetConfigAsync();
|
||||
|
||||
TMDbClient client = new TMDbClient(TestConfig.APIKey);
|
||||
Uri uri = TMDbClient.GetImageUrl("w92", "/2B7RySy2WMVJKKEFN2XA3IFb8w0.jpg");
|
||||
Uri uriSsl = TMDbClient.GetImageUrl("w92", "/2B7RySy2WMVJKKEFN2XA3IFb8w0.jpg", true);
|
||||
|
||||
await Verify(new
|
||||
{
|
||||
uri,
|
||||
uriSsl
|
||||
});
|
||||
}
|
||||
|
||||
[Fact(Skip = "Disabled till we can consistently reproduce a rate limit")]
|
||||
public async Task ClientRateLimitTest()
|
||||
{
|
||||
TMDbClient client = TMDbClient;
|
||||
client.MaxRetryCount = 0;
|
||||
|
||||
Assert.Throws<RequestLimitExceededException>(() =>
|
||||
await Assert.ThrowsAsync<RequestLimitExceededException>(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
Parallel.For(0, 100, i =>
|
||||
{
|
||||
client.GetMovieAsync(id).Sync();
|
||||
});
|
||||
List<Task> tasks = new List<Task>(100);
|
||||
for (int i = 0; i < 100; i++)
|
||||
tasks.Add(client.GetMovieAsync(IdHelper.AGoodDayToDieHard));
|
||||
|
||||
await Task.WhenAll(tasks);
|
||||
}
|
||||
catch (AggregateException ex)
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Search;
|
||||
using TMDbLib.Objects.Trending;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
using Xunit;
|
||||
@ -10,31 +10,24 @@ namespace TMDbLibTests
|
||||
public class ClientTrendingTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void TestTrendingMovies()
|
||||
public async Task TestTrendingMoviesAsync()
|
||||
{
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
|
||||
var movies = Config.Client.GetTrendingMoviesAsync(TimeWindow.Week).Result;
|
||||
Assert.True(movies.Results.Count > 0);
|
||||
SearchContainer<SearchMovie> movies = await TMDbClient.GetTrendingMoviesAsync(TimeWindow.Week);
|
||||
Assert.NotEmpty(movies.Results);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTrendingTv()
|
||||
public async Task TestTrendingTvAsync()
|
||||
{
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
|
||||
var tv = Config.Client.GetTrendingTvAsync(TimeWindow.Week).Result;
|
||||
Assert.True(tv.Results.Count > 0);
|
||||
SearchContainer<SearchTv> tv = await TMDbClient.GetTrendingTvAsync(TimeWindow.Week);
|
||||
Assert.NotEmpty(tv.Results);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTrendingPeople()
|
||||
public async Task TestTrendingPeopleAsync()
|
||||
{
|
||||
IgnoreMissingCSharp("results[array].gender / gender", "results[array].known_for_department / known_for_department");
|
||||
IgnoreMissingJson(" / popularity", "results[array] / media_type");
|
||||
|
||||
var people = Config.Client.GetTrendingPeopleAsync(TimeWindow.Week).Result;
|
||||
Assert.True(people.Results.Count > 0);
|
||||
SearchContainer<SearchPerson> people = await TMDbClient.GetTrendingPeopleAsync(TimeWindow.Week);
|
||||
Assert.NotEmpty(people.Results);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using TMDbLib.Objects.TvShows;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
using Xunit;
|
||||
@ -8,20 +8,11 @@ namespace TMDbLibTests
|
||||
public class ClientTvEpisodeGroupTests : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void TestTvEpisodeGroups()
|
||||
public async Task TestTvEpisodeGroups()
|
||||
{
|
||||
var group = Config.Client.GetTvEpisodeGroupsAsync("5acf93e60e0a26346d0000ce");
|
||||
TvGroupCollection group = await TMDbClient.GetTvEpisodeGroupsAsync("5acf93e60e0a26346d0000ce");
|
||||
|
||||
Assert.Equal("5acf93e60e0a26346d0000ce", group.Result.Id);
|
||||
Assert.Equal("Netflix Collections", group.Result.Name);
|
||||
Assert.Equal("Netflix", group.Result.Network.Name);
|
||||
Assert.Equal("Comedians in Cars organized in Netflix's collections.", group.Result.Description);
|
||||
Assert.Equal(71, group.Result.EpisodeCount);
|
||||
Assert.Equal(5, group.Result.GroupCount);
|
||||
Assert.Equal(TvGroupType.Digital, group.Result.Type);
|
||||
|
||||
Assert.Equal("5acf93efc3a368739a0000a9", group.Result.Groups.First().Id);
|
||||
Assert.Equal(1078262, group.Result.Groups.First().Episodes.First().Id);
|
||||
await Verify(group);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
using TMDbLib.Objects.Changes;
|
||||
@ -15,11 +15,11 @@ namespace TMDbLibTests
|
||||
{
|
||||
public class ClientTvEpisodeTests : TestBase
|
||||
{
|
||||
private static Dictionary<TvEpisodeMethods, Func<TvEpisode, object>> _methods;
|
||||
private static readonly Dictionary<TvEpisodeMethods, Func<TvEpisode, object>> Methods;
|
||||
|
||||
public ClientTvEpisodeTests()
|
||||
static ClientTvEpisodeTests()
|
||||
{
|
||||
_methods = new Dictionary<TvEpisodeMethods, Func<TvEpisode, object>>
|
||||
Methods = new Dictionary<TvEpisodeMethods, Func<TvEpisode, object>>
|
||||
{
|
||||
[TvEpisodeMethods.Credits] = tvEpisode => tvEpisode.Credits,
|
||||
[TvEpisodeMethods.Images] = tvEpisode => tvEpisode.Images,
|
||||
@ -30,258 +30,181 @@ namespace TMDbLibTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvEpisodeExtrasNone()
|
||||
public async Task TestTvEpisodeExtrasNoneAsync()
|
||||
{
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
IgnoreMissingJson(" / account_states", " / credits", " / external_ids", " / images", " / videos");
|
||||
TvEpisode tvEpisode = await TMDbClient.GetTvEpisodeAsync(IdHelper.BreakingBad, 1, 1);
|
||||
|
||||
TvEpisode tvEpisode = Config.Client.GetTvEpisodeAsync(IdHelper.BreakingBad, 1, 1).Result;
|
||||
|
||||
TestBreakingBadSeasonOneEpisodeOneBaseProperties(tvEpisode);
|
||||
await Verify(tvEpisode);
|
||||
|
||||
// Test all extras, ensure none of them are populated
|
||||
foreach (Func<TvEpisode, object> selector in _methods.Values)
|
||||
foreach (Func<TvEpisode, object> selector in Methods.Values)
|
||||
{
|
||||
Assert.Null(selector(tvEpisode));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvEpisodeExtrasAccountState()
|
||||
public async Task TestTvEpisodeExtrasAccountState()
|
||||
{
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
IgnoreMissingJson(" / credits", " / external_ids", " / images", " / videos");
|
||||
|
||||
// Test the custom parsing code for Account State rating
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
TvEpisode episode = Config.Client.GetTvEpisodeAsync(IdHelper.BigBangTheory, 1, 1, TvEpisodeMethods.AccountStates).Result;
|
||||
TvEpisode episode = await TMDbClient.GetTvEpisodeAsync(IdHelper.BigBangTheory, 1, 1, TvEpisodeMethods.AccountStates);
|
||||
if (episode.AccountStates == null || !episode.AccountStates.Rating.HasValue)
|
||||
{
|
||||
Config.Client.TvEpisodeSetRatingAsync(IdHelper.BigBangTheory, 1, 1, 5).Sync();
|
||||
await TMDbClient.TvEpisodeSetRatingAsync(IdHelper.BigBangTheory, 1, 1, 5);
|
||||
|
||||
// Allow TMDb to update cache
|
||||
Thread.Sleep(2000);
|
||||
await Task.Delay(2000);
|
||||
|
||||
episode = Config.Client.GetTvEpisodeAsync(IdHelper.BigBangTheory, 1, 1, TvEpisodeMethods.AccountStates).Result;
|
||||
episode = await TMDbClient.GetTvEpisodeAsync(IdHelper.BigBangTheory, 1, 1, TvEpisodeMethods.AccountStates);
|
||||
}
|
||||
|
||||
Assert.NotNull(episode.AccountStates);
|
||||
Assert.True(episode.AccountStates.Rating.HasValue);
|
||||
Assert.True(Math.Abs(episode.AccountStates.Rating.Value - 5) < double.Epsilon);
|
||||
await Verify(episode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvEpisodeExtrasAll()
|
||||
public async Task TestTvEpisodeExtrasAll()
|
||||
{
|
||||
IgnoreMissingJson("credits / id", "external_ids / id", "images / id", "videos / id");
|
||||
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Account states will only show up if we've done something
|
||||
Config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 5).Sync();
|
||||
await TMDbClient.TvEpisodeSetRatingAsync(IdHelper.FullerHouse, 1, 1, 5);
|
||||
|
||||
TvEpisodeMethods combinedEnum = _methods.Keys.Aggregate((methods, tvEpisodeMethods) => methods | tvEpisodeMethods);
|
||||
TvEpisode tvEpisode = Config.Client.GetTvEpisodeAsync(IdHelper.BreakingBad, 1, 1, combinedEnum).Result;
|
||||
|
||||
TestBreakingBadSeasonOneEpisodeOneBaseProperties(tvEpisode);
|
||||
|
||||
Assert.NotNull(tvEpisode.Images);
|
||||
Assert.NotNull(tvEpisode.Images.Stills);
|
||||
Assert.True(tvEpisode.Images.Stills.Count > 0);
|
||||
|
||||
TestMethodsHelper.TestAllNotNull(_methods, tvEpisode);
|
||||
await TestMethodsHelper.TestGetAll(Methods, combined => TMDbClient.GetTvEpisodeAsync(IdHelper.FullerHouse, 1, 1, combined), async tvEpisode =>
|
||||
{
|
||||
await Verify(tvEpisode);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvEpisodeExtrasExclusive()
|
||||
public async Task TestTvEpisodeExtrasExclusiveAsync()
|
||||
{
|
||||
IgnoreMissingJson(" / account_states", " / credits", " / external_ids", " / images", " / videos", "credits / id", "external_ids / id", "images / id", "videos / id");
|
||||
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => Config.Client.GetTvEpisodeAsync(id, 1, 1, extras).Result, IdHelper.BreakingBad);
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
await TestMethodsHelper.TestGetExclusive(Methods, extras => TMDbClient.GetTvEpisodeAsync(IdHelper.BreakingBad, 1, 1, extras));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvEpisodeSeparateExtrasCredits()
|
||||
public async Task TestTvEpisodeSeparateExtrasCreditsAsync()
|
||||
{
|
||||
CreditsWithGuestStars credits = Config.Client.GetTvEpisodeCreditsAsync(IdHelper.BreakingBad, 1, 1).Result;
|
||||
CreditsWithGuestStars credits = await TMDbClient.GetTvEpisodeCreditsAsync(IdHelper.BreakingBad, 1, 1);
|
||||
Assert.NotNull(credits);
|
||||
|
||||
Cast guestStarItem = credits.GuestStars.FirstOrDefault(s => s.Id == 92495);
|
||||
Assert.Equal(92495, guestStarItem.Id);
|
||||
Assert.Equal("Emilio Koyama", guestStarItem.Character);
|
||||
Assert.Equal("52542273760ee3132800068e", guestStarItem.CreditId);
|
||||
Assert.Equal("John Koyama", guestStarItem.Name);
|
||||
Assert.NotNull(guestStarItem.ProfilePath);
|
||||
Assert.Equal(1, guestStarItem.Order);
|
||||
|
||||
Cast castItem = credits.Cast.FirstOrDefault(s => s.Id == 17419);
|
||||
Assert.Equal(17419, castItem.Id);
|
||||
Assert.Equal("Walter White", castItem.Character);
|
||||
Assert.Equal("52542282760ee313280017f9", castItem.CreditId);
|
||||
Assert.Equal("Bryan Cranston", castItem.Name);
|
||||
Assert.NotNull(castItem.ProfilePath);
|
||||
Assert.Equal(0, castItem.Order);
|
||||
|
||||
Crew crewItem = credits.Crew.FirstOrDefault(s => s.Id == 1280071);
|
||||
Assert.NotNull(crewItem);
|
||||
Assert.Equal(1280071, crewItem.Id);
|
||||
Assert.Equal("Editing", crewItem.Department);
|
||||
Assert.Equal("Lynne Willingham", crewItem.Name);
|
||||
Assert.Equal("Editor", crewItem.Job);
|
||||
Assert.Null(crewItem.ProfilePath);
|
||||
|
||||
await Verify(new
|
||||
{
|
||||
guestStarItem,
|
||||
castItem,
|
||||
crewItem
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvEpisodeSeparateExtrasExternalIds()
|
||||
public async Task TestTvEpisodeSeparateExtrasExternalIdsAsync()
|
||||
{
|
||||
ExternalIdsTvEpisode externalIds = Config.Client.GetTvEpisodeExternalIdsAsync(IdHelper.BreakingBad, 1, 1).Result;
|
||||
ExternalIdsTvEpisode externalIds = await TMDbClient.GetTvEpisodeExternalIdsAsync(IdHelper.BreakingBad, 1, 1);
|
||||
|
||||
Assert.NotNull(externalIds);
|
||||
Assert.True(string.IsNullOrEmpty(externalIds.FreebaseId));
|
||||
Assert.Equal(62085, externalIds.Id);
|
||||
Assert.Equal("/m/03mb620", externalIds.FreebaseMid);
|
||||
Assert.Equal("tt0959621", externalIds.ImdbId);
|
||||
Assert.Equal("637041", externalIds.TvrageId);
|
||||
Assert.Equal("349232", externalIds.TvdbId);
|
||||
await Verify(externalIds);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvEpisodeSeparateExtrasImages()
|
||||
public async Task TestTvEpisodeSeparateExtrasImagesAsync()
|
||||
{
|
||||
StillImages images = Config.Client.GetTvEpisodeImagesAsync(IdHelper.BreakingBad, 1, 1).Result;
|
||||
Assert.NotNull(images);
|
||||
Assert.NotNull(images.Stills);
|
||||
StillImages images = await TMDbClient.GetTvEpisodeImagesAsync(IdHelper.BreakingBad, 1, 1);
|
||||
|
||||
await Verify(images);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvEpisodeSeparateExtrasVideos()
|
||||
public async Task TestTvEpisodeSeparateExtrasVideosAsync()
|
||||
{
|
||||
ResultContainer<Video> images = Config.Client.GetTvEpisodeVideosAsync(IdHelper.BreakingBad, 1, 1).Result;
|
||||
Assert.NotNull(images);
|
||||
Assert.NotNull(images.Results);
|
||||
ResultContainer<Video> images = await TMDbClient.GetTvEpisodeVideosAsync(IdHelper.BreakingBad, 1, 1);
|
||||
|
||||
await Verify(images);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvEpisodeAccountStateRatingSet()
|
||||
public async Task TestTvEpisodeAccountStateRatingSetAsync()
|
||||
{
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
TvEpisodeAccountState accountState = Config.Client.GetTvEpisodeAccountStateAsync(IdHelper.BreakingBad, 1, 1).Result;
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
TvEpisodeAccountState accountState = await TMDbClient.GetTvEpisodeAccountStateAsync(IdHelper.BreakingBad, 1, 1);
|
||||
|
||||
// Remove the rating
|
||||
if (accountState.Rating.HasValue)
|
||||
{
|
||||
Assert.True(Config.Client.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 1).Result);
|
||||
Assert.True(await TMDbClient.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 1));
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
await Task.Delay(2000);
|
||||
}
|
||||
|
||||
// Test that the episode is NOT rated
|
||||
accountState = Config.Client.GetTvEpisodeAccountStateAsync(IdHelper.BreakingBad, 1, 1).Result;
|
||||
accountState = await TMDbClient.GetTvEpisodeAccountStateAsync(IdHelper.BreakingBad, 1, 1);
|
||||
|
||||
Assert.Equal(IdHelper.BreakingBadSeason1Episode1Id, accountState.Id);
|
||||
Assert.False(accountState.Rating.HasValue);
|
||||
|
||||
// Rate the episode
|
||||
Assert.True(Config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 5).Result);
|
||||
Assert.True(await TMDbClient.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 5));
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
await Task.Delay(2000);
|
||||
|
||||
// Test that the episode IS rated
|
||||
accountState = Config.Client.GetTvEpisodeAccountStateAsync(IdHelper.BreakingBad, 1, 1).Result;
|
||||
accountState = await TMDbClient.GetTvEpisodeAccountStateAsync(IdHelper.BreakingBad, 1, 1);
|
||||
Assert.Equal(IdHelper.BreakingBadSeason1Episode1Id, accountState.Id);
|
||||
Assert.True(accountState.Rating.HasValue);
|
||||
|
||||
// Remove the rating
|
||||
Assert.True(Config.Client.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 1).Result);
|
||||
Assert.True(await TMDbClient.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvEpisodeRateBad()
|
||||
public async Task TestTvEpisodeRateBadAsync()
|
||||
{
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
Assert.False(Config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, -1).Result);
|
||||
Assert.False(Config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 0).Result);
|
||||
Assert.False(Config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 10.5).Result);
|
||||
Assert.False(await TMDbClient.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, -1));
|
||||
Assert.False(await TMDbClient.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 0));
|
||||
Assert.False(await TMDbClient.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 10.5));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvEpisodeGetChanges()
|
||||
public async Task TestTvEpisodeGetChangesAsync()
|
||||
{
|
||||
ChangesContainer changes = Config.Client.GetTvEpisodeChangesAsync(IdHelper.BreakingBadSeason1Episode1Id).Result;
|
||||
IList<Change> changes = await TMDbClient.GetTvEpisodeChangesAsync(IdHelper.BreakingBadSeason1Episode1Id);
|
||||
|
||||
Assert.NotNull(changes);
|
||||
Assert.NotNull(changes.Changes);
|
||||
}
|
||||
Assert.NotEmpty(changes);
|
||||
|
||||
private void TestBreakingBadSeasonOneEpisodeOneBaseProperties(TvEpisode tvEpisode)
|
||||
{
|
||||
Assert.Equal(62085, tvEpisode.Id);
|
||||
Assert.True(tvEpisode.AirDate.HasValue);
|
||||
Assert.Equal(new DateTime(2008, 1, 19), tvEpisode.AirDate.Value.Date);
|
||||
Assert.Equal(1, tvEpisode.EpisodeNumber);
|
||||
Assert.Equal("Pilot", tvEpisode.Name);
|
||||
Assert.NotNull(tvEpisode.Overview);
|
||||
Assert.Null(tvEpisode.ProductionCode);
|
||||
Assert.Equal(1, tvEpisode.SeasonNumber);
|
||||
Assert.NotNull(tvEpisode.StillPath);
|
||||
|
||||
Assert.NotNull(tvEpisode.Crew);
|
||||
Crew crew = tvEpisode.Crew.SingleOrDefault(s => s.CreditId == "52542275760ee313280006ce");
|
||||
Assert.NotNull(crew);
|
||||
|
||||
Assert.Equal(66633, crew.Id);
|
||||
Assert.Equal("52542275760ee313280006ce", crew.CreditId);
|
||||
Assert.Equal("Vince Gilligan", crew.Name);
|
||||
Assert.Equal("Writing", crew.Department);
|
||||
Assert.Equal("Writer", crew.Job);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(crew.ProfilePath), "crew.ProfilePath was not a valid image path, was: " + crew.ProfilePath);
|
||||
|
||||
Assert.NotNull(tvEpisode.GuestStars);
|
||||
Cast star = tvEpisode.GuestStars.SingleOrDefault(s => s.CreditId == "52542273760ee3132800068e");
|
||||
Assert.NotNull(star);
|
||||
|
||||
Assert.Equal(92495, star.Id);
|
||||
Assert.Equal("John Koyama", star.Name);
|
||||
Assert.Equal("52542273760ee3132800068e", star.CreditId);
|
||||
Assert.Equal("Emilio Koyama", star.Character);
|
||||
Assert.Equal(1, star.Order);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(star.ProfilePath), "star.ProfilePath was not a valid image path, was: " + star.ProfilePath);
|
||||
await Verify(changes);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvEpisodeMissing()
|
||||
public async Task TestTvEpisodeMissingAsync()
|
||||
{
|
||||
TvEpisode tvEpisode = Config.Client.GetTvEpisodeAsync(IdHelper.MissingID, 1, 1).Result;
|
||||
TvEpisode tvEpisode = await TMDbClient.GetTvEpisodeAsync(IdHelper.MissingID, 1, 1);
|
||||
|
||||
Assert.Null(tvEpisode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvEpisodesScreenedTheatrically()
|
||||
public async Task TestTvEpisodesScreenedTheatricallyAsync()
|
||||
{
|
||||
ResultContainer<TvEpisodeInfo> results = Config.Client.GetTvEpisodesScreenedTheatricallyAsync(IdHelper.GameOfThrones).Result;
|
||||
ResultContainer<TvEpisodeInfo> results = await TMDbClient.GetTvEpisodesScreenedTheatricallyAsync(IdHelper.GameOfThrones);
|
||||
TvEpisodeInfo single = results.Results.Single(s => s.Id == IdHelper.GameOfThronesSeason4Episode10);
|
||||
|
||||
Assert.Equal(IdHelper.GameOfThrones, results.Id);
|
||||
|
||||
TvEpisodeInfo single = results.Results.FirstOrDefault(s => s.Id == 63103);
|
||||
Assert.NotNull(single);
|
||||
Assert.Equal(4, single.SeasonNumber);
|
||||
Assert.Equal(10, single.EpisodeNumber);
|
||||
await Verify(single);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvEpisodeGetTvEpisodeWithImageLanguage()
|
||||
public async Task TestTvEpisodeGetTvEpisodeWithImageLanguageAsync()
|
||||
{
|
||||
IgnoreMissingJson(" / account_states", " / alternative_titles", " / changes", " / credits", " / content_ratings", " / genre_ids", "images / id", " / keywords", " / lists", " / release_dates", " / releases", " / reviews", " / show_id", " / similar", " / translations", " / videos", " / recommendations", " / external_ids");
|
||||
TvEpisode resp = await TMDbClient.GetTvEpisodeAsync(IdHelper.BreakingBad, 1, 1, language: "en-US", includeImageLanguage: "en", extraMethods: TvEpisodeMethods.Images);
|
||||
|
||||
TvEpisode resp = Config.Client.GetTvEpisodeAsync(IdHelper.BreakingBad, 1, 1, language: "en-US", includeImageLanguage: "en", extraMethods: TvEpisodeMethods.Images).Result;
|
||||
|
||||
Assert.True(resp.Images.Stills.Count > 0);
|
||||
await Verify(resp.Images);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
using TMDbLib.Objects.Changes;
|
||||
@ -15,11 +15,11 @@ namespace TMDbLibTests
|
||||
{
|
||||
public class ClientTvSeasonTests : TestBase
|
||||
{
|
||||
private static Dictionary<TvSeasonMethods, Func<TvSeason, object>> _methods;
|
||||
private static readonly Dictionary<TvSeasonMethods, Func<TvSeason, object>> Methods;
|
||||
|
||||
public ClientTvSeasonTests()
|
||||
static ClientTvSeasonTests()
|
||||
{
|
||||
_methods = new Dictionary<TvSeasonMethods, Func<TvSeason, object>>
|
||||
Methods = new Dictionary<TvSeasonMethods, Func<TvSeason, object>>
|
||||
{
|
||||
[TvSeasonMethods.Credits] = tvSeason => tvSeason.Credits,
|
||||
[TvSeasonMethods.Images] = tvSeason => tvSeason.Images,
|
||||
@ -31,46 +31,32 @@ namespace TMDbLibTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvSeasonExtrasNone()
|
||||
public async Task TestTvSeasonExtrasNoneAsync()
|
||||
{
|
||||
// TMDb is sending an extra property
|
||||
IgnoreMissingCSharp("_id / _id");
|
||||
TvSeason tvSeason = await TMDbClient.GetTvSeasonAsync(IdHelper.BreakingBad, 1);
|
||||
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
IgnoreMissingJson(" / images", " / account_states", " / credits", " / external_ids", " / images", " / videos");
|
||||
|
||||
TvSeason tvSeason = Config.Client.GetTvSeasonAsync(IdHelper.BreakingBad, 1).Result;
|
||||
|
||||
TestBreakingBadBaseProperties(tvSeason);
|
||||
await Verify(tvSeason);
|
||||
|
||||
// Test all extras, ensure none of them are populated
|
||||
foreach (Func<TvSeason, object> selector in _methods.Values)
|
||||
{
|
||||
foreach (Func<TvSeason, object> selector in Methods.Values)
|
||||
Assert.Null(selector(tvSeason));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvSeasonExtrasAccountState()
|
||||
public async Task TestTvSeasonExtrasAccountState()
|
||||
{
|
||||
// TMDb is sending an extra property
|
||||
IgnoreMissingCSharp("_id / _id");
|
||||
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
IgnoreMissingJson(" / credits", " / external_ids", " / images", " / videos", "account_states / id");
|
||||
|
||||
// Test the custom parsing code for Account State rating
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
TvSeason season = Config.Client.GetTvSeasonAsync(IdHelper.BigBangTheory, 1, TvSeasonMethods.AccountStates).Result;
|
||||
TvSeason season = await TMDbClient.GetTvSeasonAsync(IdHelper.BigBangTheory, 1, TvSeasonMethods.AccountStates);
|
||||
if (season.AccountStates == null || season.AccountStates.Results.All(s => s.EpisodeNumber != 1))
|
||||
{
|
||||
Config.Client.TvEpisodeSetRatingAsync(IdHelper.BigBangTheory, 1, 1, 5).Sync();
|
||||
await TMDbClient.TvEpisodeSetRatingAsync(IdHelper.BigBangTheory, 1, 1, 5);
|
||||
|
||||
// Allow TMDb to update cache
|
||||
Thread.Sleep(2000);
|
||||
await Task.Delay(2000);
|
||||
|
||||
season = Config.Client.GetTvSeasonAsync(IdHelper.BigBangTheory, 1, TvSeasonMethods.AccountStates).Result;
|
||||
season = await TMDbClient.GetTvSeasonAsync(IdHelper.BigBangTheory, 1, TvSeasonMethods.AccountStates);
|
||||
}
|
||||
|
||||
Assert.NotNull(season.AccountStates);
|
||||
@ -79,179 +65,103 @@ namespace TMDbLibTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvSeasonExtrasAll()
|
||||
public async Task TestTvSeasonExtrasAllAsync()
|
||||
{
|
||||
// TMDb is sending an extra property
|
||||
IgnoreMissingCSharp("_id / _id");
|
||||
|
||||
IgnoreMissingJson("images / id", "account_states / id", "credits / id", "external_ids / id", "videos / id");
|
||||
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Account states will only show up if we've done something
|
||||
Config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 5).Sync();
|
||||
await TMDbClient.TvEpisodeSetRatingAsync(IdHelper.FullerHouse, 1, 1, 5);
|
||||
|
||||
TvSeasonMethods combinedEnum = _methods.Keys.Aggregate((methods, tvSeasonMethods) => methods | tvSeasonMethods);
|
||||
TvSeason tvSeason = Config.Client.GetTvSeasonAsync(IdHelper.BreakingBad, 1, combinedEnum).Result;
|
||||
|
||||
TestBreakingBadBaseProperties(tvSeason);
|
||||
|
||||
TestMethodsHelper.TestAllNotNull(_methods, tvSeason);
|
||||
await TestMethodsHelper.TestGetAll(Methods, combined => TMDbClient.GetTvSeasonAsync(IdHelper.FullerHouse, 1, combined), season => Verify(season));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvSeasonExtrasExclusive()
|
||||
public async Task TestTvSeasonExtrasExclusiveAsync()
|
||||
{
|
||||
// TMDb is sending an extra property
|
||||
IgnoreMissingCSharp("_id / _id");
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
IgnoreMissingJson(" / images", " / account_states", " / external_ids", " / images", " / videos", " / credits", "images / id", "external_ids / id", "videos / id", "credits / id", "account_states / id");
|
||||
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => Config.Client.GetTvSeasonAsync(id, 1, extras).Result, IdHelper.BreakingBad);
|
||||
await TestMethodsHelper.TestGetExclusive(Methods, extras => TMDbClient.GetTvSeasonAsync(IdHelper.BreakingBad, 1, extras));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvSeasonSeparateExtrasCredits()
|
||||
public async Task TestTvSeasonSeparateExtrasCreditsAsync()
|
||||
{
|
||||
Credits credits = Config.Client.GetTvSeasonCreditsAsync(IdHelper.BreakingBad, 1).Result;
|
||||
Assert.NotNull(credits);
|
||||
Assert.NotNull(credits.Cast);
|
||||
Assert.Equal("Walter White", credits.Cast[0].Character);
|
||||
Assert.Equal("52542282760ee313280017f9", credits.Cast[0].CreditId);
|
||||
Assert.Equal(17419, credits.Cast[0].Id);
|
||||
Assert.Equal("Bryan Cranston", credits.Cast[0].Name);
|
||||
Assert.NotNull(credits.Cast[0].ProfilePath);
|
||||
Assert.Equal(0, credits.Cast[0].Order);
|
||||
Assert.True(credits.Cast[0].Popularity > 0);
|
||||
Assert.Equal("Acting", credits.Cast[0].KnownForDepartment);
|
||||
Assert.Equal("Bryan Cranston", credits.Cast[0].OriginalName);
|
||||
Credits credits = await TMDbClient.GetTvSeasonCreditsAsync(IdHelper.BreakingBad, 1);
|
||||
|
||||
Crew crewPersonId = credits.Crew.FirstOrDefault(s => s.Id == 1223202);
|
||||
Assert.NotNull(crewPersonId);
|
||||
|
||||
Assert.Equal(1223202, crewPersonId.Id);
|
||||
Assert.Equal("Production", crewPersonId.Department);
|
||||
Assert.Equal("Diane Mercer", crewPersonId.Name);
|
||||
Assert.Equal("Producer", crewPersonId.Job);
|
||||
Assert.Null(crewPersonId.ProfilePath);
|
||||
await Verify(credits);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvSeasonSeparateExtrasExternalIds()
|
||||
public async Task TestTvSeasonSeparateExtrasExternalIdsAsync()
|
||||
{
|
||||
ExternalIdsTvSeason externalIds = Config.Client.GetTvSeasonExternalIdsAsync(IdHelper.BreakingBad, 1).Result;
|
||||
ExternalIdsTvSeason externalIds = await TMDbClient.GetTvSeasonExternalIdsAsync(IdHelper.BreakingBad, 1);
|
||||
|
||||
Assert.NotNull(externalIds);
|
||||
Assert.Equal(3572, externalIds.Id);
|
||||
Assert.Equal("/en/breaking_bad_season_1", externalIds.FreebaseId);
|
||||
Assert.Equal("/m/05yy27m", externalIds.FreebaseMid);
|
||||
Assert.Null(externalIds.TvrageId);
|
||||
Assert.Equal("30272", externalIds.TvdbId);
|
||||
await Verify(externalIds);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvSeasonSeparateExtrasImages()
|
||||
public async Task TestTvSeasonSeparateExtrasImagesAsync()
|
||||
{
|
||||
PosterImages images = Config.Client.GetTvSeasonImagesAsync(IdHelper.BreakingBad, 1).Result;
|
||||
Assert.NotNull(images);
|
||||
Assert.NotNull(images.Posters);
|
||||
PosterImages images = await TMDbClient.GetTvSeasonImagesAsync(IdHelper.BreakingBad, 1);
|
||||
|
||||
Assert.NotEmpty(images.Posters);
|
||||
TestImagesHelpers.TestImagePaths(images.Posters);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvSeasonSeparateExtrasVideos()
|
||||
public async Task TestTvSeasonSeparateExtrasVideosAsync()
|
||||
{
|
||||
ResultContainer<Video> videos = Config.Client.GetTvSeasonVideosAsync(IdHelper.BreakingBad, 1).Result;
|
||||
Assert.NotNull(videos);
|
||||
Assert.NotNull(videos.Results);
|
||||
ResultContainer<Video> videos = await TMDbClient.GetTvSeasonVideosAsync(IdHelper.GameOfThrones, 1);
|
||||
Video single = videos.Results.Single(s => s.Id == "5c9b7e95c3a36841a341b9c6");
|
||||
|
||||
await Verify(single);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvSeasonAccountStateRatingSet()
|
||||
public async Task TestTvSeasonAccountStateRatingSetAsync()
|
||||
{
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Rate episode 1, 2 and 3 of BreakingBad
|
||||
Assert.True(Config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 1, 5).Result);
|
||||
Assert.True(Config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 2, 7).Result);
|
||||
Assert.True(Config.Client.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 3, 3).Result);
|
||||
await TestMethodsHelper.SetValidateRemoveTest(
|
||||
() => TMDbClient.TvEpisodeSetRatingAsync(IdHelper.BreakingBad, 1, 3, 5),
|
||||
() => TMDbClient.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 3),
|
||||
async shouldBeSet =>
|
||||
{
|
||||
ResultContainer<TvEpisodeAccountStateWithNumber> state = await TMDbClient.GetTvSeasonAccountStateAsync(IdHelper.BreakingBad, 1);
|
||||
|
||||
// Wait for TMDb to un-cache our value
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// Fetch out the seasons state
|
||||
ResultContainer<TvEpisodeAccountStateWithNumber> state = Config.Client.GetTvSeasonAccountStateAsync(IdHelper.BreakingBad, 1).Result;
|
||||
Assert.NotNull(state);
|
||||
|
||||
Assert.True(Math.Abs(5 - (state.Results.Single(s => s.EpisodeNumber == 1).Rating ?? 0)) < double.Epsilon);
|
||||
Assert.True(Math.Abs(7 - (state.Results.Single(s => s.EpisodeNumber == 2).Rating ?? 0)) < double.Epsilon);
|
||||
Assert.True(Math.Abs(3 - (state.Results.Single(s => s.EpisodeNumber == 3).Rating ?? 0)) < double.Epsilon);
|
||||
|
||||
// Test deleting Ratings
|
||||
Assert.True(Config.Client.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 1).Result);
|
||||
Assert.True(Config.Client.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 2).Result);
|
||||
Assert.True(Config.Client.TvEpisodeRemoveRatingAsync(IdHelper.BreakingBad, 1, 3).Result);
|
||||
|
||||
// Wait for TMDb to un-cache our value
|
||||
Thread.Sleep(2000);
|
||||
|
||||
state = Config.Client.GetTvSeasonAccountStateAsync(IdHelper.BreakingBad, 1).Result;
|
||||
Assert.NotNull(state);
|
||||
|
||||
Assert.Null(state.Results.Single(s => s.EpisodeNumber == 1).Rating);
|
||||
Assert.Null(state.Results.Single(s => s.EpisodeNumber == 2).Rating);
|
||||
Assert.Null(state.Results.Single(s => s.EpisodeNumber == 3).Rating);
|
||||
if (shouldBeSet)
|
||||
Assert.Contains(state.Results, x => x.EpisodeNumber == 3 && x.Rating.HasValue);
|
||||
else
|
||||
Assert.Contains(state.Results, x => x.EpisodeNumber == 3 && !x.Rating.HasValue);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvSeasonGetChanges()
|
||||
public async Task TestTvSeasonGetChangesAsync()
|
||||
{
|
||||
ChangesContainer changes = Config.Client.GetTvSeasonChangesAsync(IdHelper.BreakingBadSeason1Id).Result;
|
||||
Assert.NotNull(changes);
|
||||
Assert.NotNull(changes.Changes);
|
||||
}
|
||||
TvShow latestTvShow = await TMDbClient.GetLatestTvShowAsync();
|
||||
int latestSeasonId = latestTvShow.Seasons.Max(s => s.Id);
|
||||
IList<Change> changes = await TMDbClient.GetTvSeasonChangesAsync(latestSeasonId);
|
||||
|
||||
private void TestBreakingBadBaseProperties(TvSeason tvSeason)
|
||||
{
|
||||
Assert.NotNull(tvSeason);
|
||||
Assert.NotNull(tvSeason.Id);
|
||||
Assert.Equal(1, tvSeason.SeasonNumber);
|
||||
Assert.Equal("Season 1", tvSeason.Name);
|
||||
Assert.NotNull(tvSeason.AirDate);
|
||||
Assert.NotNull(tvSeason.Overview);
|
||||
Assert.NotNull(tvSeason.PosterPath);
|
||||
|
||||
Assert.NotNull(tvSeason.Episodes);
|
||||
Assert.Equal(7, tvSeason.Episodes.Count);
|
||||
Assert.NotNull(tvSeason.Episodes[0].Id);
|
||||
Assert.Equal(1, tvSeason.Episodes[0].EpisodeNumber);
|
||||
Assert.Equal("Pilot", tvSeason.Episodes[0].Name);
|
||||
Assert.NotNull(tvSeason.Episodes[0].Overview);
|
||||
Assert.Null(tvSeason.Episodes[0].ProductionCode);
|
||||
Assert.Equal(1, tvSeason.Episodes[0].SeasonNumber);
|
||||
Assert.NotNull(tvSeason.Episodes[0].StillPath);
|
||||
Assert.NotEmpty(changes);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvSeasonMissing()
|
||||
public async Task TestTvSeasonMissingAsync()
|
||||
{
|
||||
TvSeason tvSeason = Config.Client.GetTvSeasonAsync(IdHelper.MissingID, 1).Result;
|
||||
TvSeason tvSeason = await TMDbClient.GetTvSeasonAsync(IdHelper.MissingID, 1);
|
||||
|
||||
Assert.Null(tvSeason);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvSeasonGetTvSeasonWithImageLanguage()
|
||||
public async Task TestTvSeasonGetTvSeasonWithImageLanguageAsync()
|
||||
{
|
||||
// TMDb is sending an extra property
|
||||
IgnoreMissingCSharp("_id / _id", "episodes[array].show_id / show_id");
|
||||
IgnoreMissingJson(" / account_states", " / alternative_titles", " / changes", " / credits", " / content_ratings", " / genre_ids", "images / id", " / keywords", " / lists", " / release_dates", " / releases", " / reviews", " / similar", " / translations", " / videos", " / recommendations", " / external_ids");
|
||||
TvSeason resp = await TMDbClient.GetTvSeasonAsync(IdHelper.BreakingBad, 1, language: "en-US", includeImageLanguage: "en", extraMethods: TvSeasonMethods.Images);
|
||||
|
||||
TvSeason resp = Config.Client.GetTvSeasonAsync(IdHelper.BreakingBad, 1, language: "en-US", includeImageLanguage: "en", extraMethods: TvSeasonMethods.Images).Result;
|
||||
ImageData poster = resp.Images.Posters.Single(s => s.FilePath == "/uFh3OrBvkwKSU3N5y0XnXOhqBJz.jpg");
|
||||
|
||||
Assert.True(resp.Images.Posters.Count > 0);
|
||||
Assert.True(resp.Images.Posters.All(p => p.Iso_639_1.Equals("en", StringComparison.OrdinalIgnoreCase)));
|
||||
await Verify(poster);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,26 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Reviews;
|
||||
using TMDbLib.Objects.Search;
|
||||
using TMDbLib.Objects.TvShows;
|
||||
using TMDbLibTests.Helpers;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
using Cast = TMDbLib.Objects.TvShows.Cast;
|
||||
using Credits = TMDbLib.Objects.TvShows.Credits;
|
||||
|
||||
namespace TMDbLibTests
|
||||
{
|
||||
public class ClientTvShowTests : TestBase
|
||||
{
|
||||
private static Dictionary<TvShowMethods, Func<TvShow, object>> _methods;
|
||||
private static readonly Dictionary<TvShowMethods, Func<TvShow, object>> Methods;
|
||||
|
||||
public ClientTvShowTests()
|
||||
static ClientTvShowTests()
|
||||
{
|
||||
_methods = new Dictionary<TvShowMethods, Func<TvShow, object>>
|
||||
Methods = new Dictionary<TvShowMethods, Func<TvShow, object>>
|
||||
{
|
||||
[TvShowMethods.Credits] = tvShow => tvShow.Credits,
|
||||
[TvShowMethods.Images] = tvShow => tvShow.Images,
|
||||
@ -37,175 +37,105 @@ namespace TMDbLibTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowExtrasNone()
|
||||
public async Task TestTvShowExtrasNoneAsync()
|
||||
{
|
||||
// We will intentionally ignore errors reg. missing JSON as we do not request it
|
||||
IgnoreMissingJson(" / known_for", " / account_states", " / alternative_titles", " / changes", " / content_ratings", " / credits", " / external_ids", " / images", " / keywords", " / similar", " / translations", " / videos", " / genre_ids", " / recommendations");
|
||||
TvShow tvShow = await TMDbClient.GetTvShowAsync(IdHelper.BreakingBad);
|
||||
|
||||
TvShow tvShow = Config.Client.GetTvShowAsync(IdHelper.BreakingBad).Result;
|
||||
|
||||
TestBreakingBadBaseProperties(tvShow);
|
||||
await Verify(tvShow);
|
||||
|
||||
// Test all extras, ensure none of them are populated
|
||||
foreach (Func<TvShow, object> selector in _methods.Values)
|
||||
foreach (Func<TvShow, object> selector in Methods.Values)
|
||||
Assert.Null(selector(tvShow));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowExtrasAll()
|
||||
public async Task TestTvShowExtrasAllAsync()
|
||||
{
|
||||
IgnoreMissingJson(" / id");
|
||||
IgnoreMissingJson(" / genre_ids", " / known_for", " / similar", " / translations", " / videos", "alternative_titles / id", "content_ratings / id", "credits / id", "external_ids / id", "keywords / id", " / recommendations");
|
||||
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Account states will only show up if we've done something
|
||||
Config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 5).Sync();
|
||||
await TMDbClient.TvShowSetRatingAsync(IdHelper.KeepingUpAppearances, 5);
|
||||
|
||||
TvShowMethods combinedEnum = _methods.Keys.Aggregate((methods, tvShowMethods) => methods | tvShowMethods);
|
||||
TvShow tvShow = Config.Client.GetTvShowAsync(IdHelper.BreakingBad, combinedEnum).Result;
|
||||
|
||||
TestBreakingBadBaseProperties(tvShow);
|
||||
|
||||
TestMethodsHelper.TestAllNotNull(_methods, tvShow);
|
||||
await TestMethodsHelper.TestGetAll(Methods, combined => TMDbClient.GetTvShowAsync(IdHelper.KeepingUpAppearances, combined), show => Verify(show));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowSeparateExtrasCredits()
|
||||
public async Task TestTvShowSeparateExtrasCreditsAsync()
|
||||
{
|
||||
Credits credits = Config.Client.GetTvShowCreditsAsync(IdHelper.BreakingBad).Result;
|
||||
Credits credits = await TMDbClient.GetTvShowCreditsAsync(IdHelper.BreakingBad);
|
||||
|
||||
Assert.NotNull(credits);
|
||||
Assert.NotNull(credits.Cast);
|
||||
Assert.Equal(IdHelper.BreakingBad, credits.Id);
|
||||
|
||||
Cast castPerson = credits.Cast[0];
|
||||
Assert.Equal("Walter White", castPerson.Character);
|
||||
Assert.Equal("52542282760ee313280017f9", castPerson.CreditId);
|
||||
Assert.Equal(17419, castPerson.Id);
|
||||
Assert.Equal("Bryan Cranston", castPerson.Name);
|
||||
Assert.NotNull(castPerson.ProfilePath);
|
||||
Assert.Equal(0, castPerson.Order);
|
||||
Assert.True(castPerson.Popularity > 0);
|
||||
Assert.Equal("Acting", castPerson.KnownForDepartment);
|
||||
Assert.Equal("Bryan Cranston", castPerson.OriginalName);
|
||||
|
||||
Assert.NotNull(credits.Crew);
|
||||
|
||||
Crew crewPerson = credits.Crew.FirstOrDefault(s => s.Id == 66633);
|
||||
Assert.NotNull(crewPerson);
|
||||
|
||||
Assert.Equal(66633, crewPerson.Id);
|
||||
Assert.Equal("52542287760ee31328001af1", crewPerson.CreditId);
|
||||
Assert.Equal("Production", crewPerson.Department);
|
||||
Assert.Equal("Vince Gilligan", crewPerson.Name);
|
||||
Assert.Equal("Executive Producer", crewPerson.Job);
|
||||
Assert.NotNull(crewPerson.ProfilePath);
|
||||
await Verify(credits);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowSeparateExtrasExternalIds()
|
||||
public async Task TestTvShowSeparateExtrasExternalIdsAsync()
|
||||
{
|
||||
ExternalIdsTvShow externalIds = Config.Client.GetTvShowExternalIdsAsync(IdHelper.GameOfThrones).Result;
|
||||
ExternalIdsTvShow externalIds = await TMDbClient.GetTvShowExternalIdsAsync(IdHelper.GameOfThrones);
|
||||
|
||||
Assert.NotNull(externalIds);
|
||||
Assert.Equal(1399, externalIds.Id);
|
||||
Assert.Equal("/en/game_of_thrones", externalIds.FreebaseId);
|
||||
Assert.Equal("/m/0524b41", externalIds.FreebaseMid);
|
||||
Assert.Equal("tt0944947", externalIds.ImdbId);
|
||||
Assert.Equal("24493", externalIds.TvrageId);
|
||||
Assert.Equal("121361", externalIds.TvdbId);
|
||||
Assert.Equal("GameOfThrones", externalIds.FacebookId);
|
||||
Assert.Equal("GameOfThrones", externalIds.TwitterId);
|
||||
Assert.Equal("gameofthrones", externalIds.InstagramId);
|
||||
await Verify(externalIds);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowSeparateExtrasContentRatings()
|
||||
public async Task TestTvShowSeparateExtrasContentRatingsAsync()
|
||||
{
|
||||
ResultContainer<ContentRating> contentRatings = Config.Client.GetTvShowContentRatingsAsync(IdHelper.BreakingBad).Result;
|
||||
Assert.NotNull(contentRatings);
|
||||
Assert.Equal(IdHelper.BreakingBad, contentRatings.Id);
|
||||
ResultContainer<ContentRating> contentRatings = await TMDbClient.GetTvShowContentRatingsAsync(IdHelper.BreakingBad);
|
||||
|
||||
ContentRating contentRating = contentRatings.Results.FirstOrDefault(r => r.Iso_3166_1.Equals("US"));
|
||||
Assert.NotNull(contentRating);
|
||||
Assert.Equal("TV-MA", contentRating.Rating);
|
||||
await Verify(contentRatings);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowSeparateExtrasAlternativeTitles()
|
||||
public async Task TestTvShowSeparateExtrasAlternativeTitlesAsync()
|
||||
{
|
||||
ResultContainer<AlternativeTitle> alternativeTitles = Config.Client.GetTvShowAlternativeTitlesAsync(IdHelper.BreakingBad).Result;
|
||||
Assert.NotNull(alternativeTitles);
|
||||
Assert.Equal(IdHelper.BreakingBad, alternativeTitles.Id);
|
||||
ResultContainer<AlternativeTitle> alternativeTitles = await TMDbClient.GetTvShowAlternativeTitlesAsync(IdHelper.BreakingBad);
|
||||
|
||||
AlternativeTitle alternativeTitle = alternativeTitles.Results.FirstOrDefault(r => r.Iso_3166_1.Equals("IT"));
|
||||
Assert.NotNull(alternativeTitle);
|
||||
Assert.Equal("Breaking Bad - Reazioni collaterali", alternativeTitle.Title);
|
||||
await Verify(alternativeTitles);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowSeparateExtrasKeywords()
|
||||
public async Task TestTvShowSeparateExtrasKeywordsAsync()
|
||||
{
|
||||
ResultContainer<Keyword> keywords = Config.Client.GetTvShowKeywordsAsync(IdHelper.BreakingBad).Result;
|
||||
Assert.NotNull(keywords);
|
||||
Assert.Equal(IdHelper.BreakingBad, keywords.Id);
|
||||
ResultContainer<Keyword> keywords = await TMDbClient.GetTvShowKeywordsAsync(IdHelper.BreakingBad);
|
||||
|
||||
Keyword keyword = keywords.Results.FirstOrDefault(r => r.Id == 41525);
|
||||
Assert.NotNull(keyword);
|
||||
Assert.Equal("high school teacher", keyword.Name);
|
||||
Keyword single = keywords.Results.Single(s => s.Id == 15484);
|
||||
|
||||
await Verify(single);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowSeparateExtrasTranslations()
|
||||
public async Task TestTvShowSeparateExtrasTranslationsAsync()
|
||||
{
|
||||
TranslationsContainerTv translations = Config.Client.GetTvShowTranslationsAsync(IdHelper.BreakingBad).Result;
|
||||
Assert.NotNull(translations);
|
||||
Assert.Equal(IdHelper.BreakingBad, translations.Id);
|
||||
TranslationsContainerTv translations = await TMDbClient.GetTvShowTranslationsAsync(IdHelper.BreakingBad);
|
||||
|
||||
Translation translation = translations.Translations.FirstOrDefault(r => r.Iso_639_1 == "hr");
|
||||
Assert.NotNull(translation);
|
||||
Assert.Equal("Croatian", translation.EnglishName);
|
||||
Assert.Equal("hr", translation.Iso_639_1);
|
||||
Assert.Equal("Hrvatski", translation.Name);
|
||||
Translation single = translations.Translations.Single(s => s.Iso_3166_1 == "DK");
|
||||
|
||||
await Verify(single);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowSeparateExtrasVideos()
|
||||
public async Task TestTvShowSeparateExtrasVideosAsync()
|
||||
{
|
||||
ResultContainer<Video> videos = Config.Client.GetTvShowVideosAsync(IdHelper.BreakingBad).Result;
|
||||
Assert.NotNull(videos);
|
||||
Assert.Equal(IdHelper.BreakingBad, videos.Id);
|
||||
ResultContainer<Video> videos = await TMDbClient.GetTvShowVideosAsync(IdHelper.BreakingBad);
|
||||
|
||||
Video video = videos.Results.FirstOrDefault(r => r.Id == "5759db2fc3a3683e7c003df7");
|
||||
Assert.NotNull(video);
|
||||
Video single = videos.Results.Single(s => s.Id == "5759db2fc3a3683e7c003df7");
|
||||
|
||||
Assert.Equal("5759db2fc3a3683e7c003df7", video.Id);
|
||||
Assert.Equal("en", video.Iso_639_1);
|
||||
Assert.Equal("XZ8daibM3AE", video.Key);
|
||||
Assert.Equal("Trailer", video.Name);
|
||||
Assert.Equal("YouTube", video.Site);
|
||||
Assert.Equal(720, video.Size);
|
||||
Assert.Equal("Trailer", video.Type);
|
||||
await Verify(single);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowSeparateExtrasAccountState()
|
||||
public async Task TestTvShowSeparateExtrasAccountStateAsync()
|
||||
{
|
||||
IgnoreMissingJson(" / id", " / alternative_titles", " / changes", " / content_ratings", " / credits", " / external_ids", " / genre_ids", " / images", " / keywords", " / known_for", " / similar", " / translations", " / videos", " / recommendations");
|
||||
|
||||
// Test the custom parsing code for Account State rating
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
TvShow show = Config.Client.GetTvShowAsync(IdHelper.BigBangTheory, TvShowMethods.AccountStates).Result;
|
||||
TvShow show = await TMDbClient.GetTvShowAsync(IdHelper.BigBangTheory, TvShowMethods.AccountStates);
|
||||
if (show.AccountStates == null || !show.AccountStates.Rating.HasValue)
|
||||
{
|
||||
Config.Client.TvShowSetRatingAsync(IdHelper.BigBangTheory, 5).Sync();
|
||||
await TMDbClient.TvShowSetRatingAsync(IdHelper.BigBangTheory, 5);
|
||||
|
||||
// Allow TMDb to update cache
|
||||
Thread.Sleep(2000);
|
||||
await Task.Delay(2000);
|
||||
|
||||
show = Config.Client.GetTvShowAsync(IdHelper.BigBangTheory, TvShowMethods.AccountStates).Result;
|
||||
show = await TMDbClient.GetTvShowAsync(IdHelper.BigBangTheory, TvShowMethods.AccountStates);
|
||||
}
|
||||
|
||||
Assert.NotNull(show.AccountStates);
|
||||
@ -214,110 +144,64 @@ namespace TMDbLibTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowSeparateExtrasImages()
|
||||
public async Task TestTvShowSeparateExtrasImagesAsync()
|
||||
{
|
||||
ImagesWithId images = Config.Client.GetTvShowImagesAsync(IdHelper.BreakingBad).Result;
|
||||
Assert.NotNull(images);
|
||||
Assert.NotNull(images.Backdrops);
|
||||
Assert.NotNull(images.Posters);
|
||||
ImagesWithId images = await TMDbClient.GetTvShowImagesAsync(IdHelper.BreakingBad);
|
||||
|
||||
TestImagesHelpers.TestImagePaths(images);
|
||||
|
||||
ImageData backdrop = images.Backdrops.Single(s => s.FilePath == "/tsRy63Mu5cu8etL1X7ZLyf7UP1M.jpg");
|
||||
ImageData poster = images.Posters.Single(s => s.FilePath == "/ggFHVNu6YYI5L9pCfOacjizRGt.jpg");
|
||||
|
||||
await Verify(new
|
||||
{
|
||||
backdrop,
|
||||
poster
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowGetImagesWithImageLanguage()
|
||||
public async Task TestTvShowGetImagesWithImageLanguageAsync()
|
||||
{
|
||||
ImagesWithId resp = Config.Client.GetTvShowImagesAsync(IdHelper.BreakingBad, language: "en-US", includeImageLanguage: "en").Result;
|
||||
ImagesWithId images = await TMDbClient.GetTvShowImagesAsync(IdHelper.BreakingBad, "en-US", "en");
|
||||
|
||||
Assert.True(resp.Backdrops.Count > 0);
|
||||
Assert.True(resp.Posters.Count > 0);
|
||||
TestImagesHelpers.TestImagePaths(images);
|
||||
|
||||
ImageData backdrop = images.Backdrops.Single(s => s.FilePath == "/otCnAN1edreRudT5E2OHk8beiDu.jpg");
|
||||
ImageData poster = images.Posters.Single(s => s.FilePath == "/ggFHVNu6YYI5L9pCfOacjizRGt.jpg");
|
||||
|
||||
await Verify(new
|
||||
{
|
||||
backdrop,
|
||||
poster
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowGetTvShowWithImageLanguage()
|
||||
public async Task TestTvShowGetTvShowWithImageLanguageAsync()
|
||||
{
|
||||
IgnoreMissingJson(" / account_states", " / alternative_titles", " / changes", " / credits", " / content_ratings", " / genre_ids", " / keywords", " / lists", " / release_dates", " / releases", " / reviews", " / similar", " / translations", " / videos", " / recommendations", " / external_ids");
|
||||
TvShow resp = await TMDbClient.GetTvShowAsync(IdHelper.BreakingBad, includeImageLanguage: "pt", extraMethods: TvShowMethods.Images);
|
||||
|
||||
TvShow resp = Config.Client.GetTvShowAsync(IdHelper.BreakingBad, language: "en-US", includeImageLanguage: "en", extraMethods: TvShowMethods.Images).Result;
|
||||
TestImagesHelpers.TestImagePaths(resp.Images);
|
||||
|
||||
Assert.True(resp.Images.Backdrops.Count > 0);
|
||||
Assert.True(resp.Images.Backdrops.All(b => b.Iso_639_1.Equals("en", StringComparison.OrdinalIgnoreCase)));
|
||||
Assert.True(resp.Images.Posters.Count > 0);
|
||||
Assert.True(resp.Images.Posters.All(p => p.Iso_639_1.Equals("en", StringComparison.OrdinalIgnoreCase)));
|
||||
}
|
||||
ImageData backdrop = null;
|
||||
ImageData poster = resp.Images.Posters.Single(s => s.FilePath == "/30erzlzIOtOK3k3T3BAl1GiVMP1.jpg");
|
||||
|
||||
private void TestBreakingBadBaseProperties(TvShow tvShow)
|
||||
await Verify(new
|
||||
{
|
||||
Assert.NotNull(tvShow);
|
||||
Assert.Equal("Breaking Bad", tvShow.Name);
|
||||
Assert.Equal("Breaking Bad", tvShow.OriginalName);
|
||||
Assert.NotNull(tvShow.Overview);
|
||||
Assert.NotNull(tvShow.Homepage);
|
||||
Assert.Equal(new DateTime(2008, 01, 19), tvShow.FirstAirDate);
|
||||
Assert.Equal(new DateTime(2013, 9, 29), tvShow.LastAirDate);
|
||||
Assert.Equal(false, tvShow.InProduction);
|
||||
Assert.Equal("Ended", tvShow.Status);
|
||||
Assert.Equal("Scripted", tvShow.Type);
|
||||
Assert.Equal("en", tvShow.OriginalLanguage);
|
||||
|
||||
Assert.NotNull(tvShow.ProductionCompanies);
|
||||
Assert.Equal(3, tvShow.ProductionCompanies.Count);
|
||||
Assert.Equal(2605, tvShow.ProductionCompanies[0].Id);
|
||||
Assert.Equal("Gran Via Productions", tvShow.ProductionCompanies[0].Name);
|
||||
|
||||
Assert.NotNull(tvShow.CreatedBy);
|
||||
Assert.Equal(1, tvShow.CreatedBy.Count);
|
||||
Assert.Equal(66633, tvShow.CreatedBy[0].Id);
|
||||
Assert.Equal("Vince Gilligan", tvShow.CreatedBy[0].Name);
|
||||
|
||||
Assert.NotNull(tvShow.EpisodeRunTime);
|
||||
Assert.Equal(2, tvShow.EpisodeRunTime.Count);
|
||||
|
||||
Assert.NotNull(tvShow.Genres);
|
||||
Assert.Equal(18, tvShow.Genres[0].Id);
|
||||
Assert.Equal("Drama", tvShow.Genres[0].Name);
|
||||
|
||||
Assert.NotNull(tvShow.Languages);
|
||||
Assert.Equal("en", tvShow.Languages[0]);
|
||||
|
||||
Assert.Null(tvShow.NextEpisodeToAir);
|
||||
|
||||
Assert.NotNull(tvShow.LastEpisodeToAir);
|
||||
Assert.Equal(62161, tvShow.LastEpisodeToAir.Id);
|
||||
|
||||
Assert.NotNull(tvShow.Networks);
|
||||
Assert.Equal(1, tvShow.Networks.Count);
|
||||
Assert.Equal(174, tvShow.Networks[0].Id);
|
||||
Assert.Equal("AMC", tvShow.Networks[0].Name);
|
||||
|
||||
Assert.NotNull(tvShow.OriginCountry);
|
||||
Assert.Equal(1, tvShow.OriginCountry.Count);
|
||||
Assert.Equal("US", tvShow.OriginCountry[0]);
|
||||
|
||||
Assert.NotNull(tvShow.Seasons);
|
||||
Assert.Equal(6, tvShow.Seasons.Count);
|
||||
Assert.Equal(0, tvShow.Seasons[0].SeasonNumber);
|
||||
Assert.Equal(1, tvShow.Seasons[1].SeasonNumber);
|
||||
|
||||
Assert.Equal(62, tvShow.NumberOfEpisodes);
|
||||
Assert.Equal(5, tvShow.NumberOfSeasons);
|
||||
|
||||
Assert.NotNull(tvShow.PosterPath);
|
||||
Assert.NotNull(tvShow.BackdropPath);
|
||||
|
||||
Assert.NotEqual(0, tvShow.Popularity);
|
||||
Assert.NotEqual(0, tvShow.VoteAverage);
|
||||
Assert.NotEqual(0, tvShow.VoteAverage);
|
||||
backdrop,
|
||||
poster
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowPopular()
|
||||
public async Task TestTvShowPopular()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
await TestHelpers.SearchPagesAsync(i => TMDbClient.GetTvShowPopularAsync(i));
|
||||
|
||||
TestHelpers.SearchPages(i => Config.Client.GetTvShowPopularAsync(i).Result);
|
||||
SearchContainer<SearchTv> result = await TMDbClient.GetTvShowPopularAsync();
|
||||
|
||||
SearchContainer<SearchTv> result = Config.Client.GetTvShowPopularAsync().Sync();
|
||||
Assert.NotNull(result.Results[0].Id);
|
||||
Assert.NotEmpty(result.Results);
|
||||
Assert.NotNull(result.Results[0].Name);
|
||||
Assert.NotNull(result.Results[0].OriginalName);
|
||||
Assert.NotNull(result.Results[0].FirstAirDate);
|
||||
@ -326,37 +210,26 @@ namespace TMDbLibTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowSeasonCount()
|
||||
public async Task TestTvShowSeasonCountAsync()
|
||||
{
|
||||
IgnoreMissingJson(" / account_states", " / alternative_titles", " / changes", " / content_ratings", " / credits", " / external_ids", " / genre_ids", " / images", " / keywords", " / known_for", " / similar", " / translations", " / videos", " / recommendations");
|
||||
// TODO: Is this test obsolete?
|
||||
TvShow tvShow = await TMDbClient.GetTvShowAsync(1668);
|
||||
|
||||
TvShow tvShow = Config.Client.GetTvShowAsync(1668).Result;
|
||||
Assert.Equal(tvShow.Seasons[1].EpisodeCount, 24);
|
||||
await Verify(tvShow);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowVideos()
|
||||
public async Task TestTvShowVideosAsync()
|
||||
{
|
||||
IgnoreMissingJson(" / account_states", " / alternative_titles", " / changes", " / content_ratings", " / credits", " / external_ids", " / genre_ids", " / images", " / keywords", " / known_for", " / similar", " / translations", "videos / id", " / recommendations");
|
||||
TvShow tvShow = await TMDbClient.GetTvShowAsync(1668, TvShowMethods.Videos);
|
||||
|
||||
TvShow tvShow = Config.Client.GetTvShowAsync(1668, TvShowMethods.Videos).Result;
|
||||
Assert.NotNull(tvShow.Videos);
|
||||
Assert.NotNull(tvShow.Videos.Results);
|
||||
Assert.NotNull(tvShow.Videos.Results[0]);
|
||||
|
||||
Assert.Equal("552e1b53c3a3686c4e00207b", tvShow.Videos.Results[0].Id);
|
||||
Assert.Equal("en", tvShow.Videos.Results[0].Iso_639_1);
|
||||
Assert.Equal("lGTOru7pwL8", tvShow.Videos.Results[0].Key);
|
||||
Assert.Equal("Friends - Opening", tvShow.Videos.Results[0].Name);
|
||||
Assert.Equal("YouTube", tvShow.Videos.Results[0].Site);
|
||||
Assert.Equal(360, tvShow.Videos.Results[0].Size);
|
||||
Assert.Equal("Opening Credits", tvShow.Videos.Results[0].Type);
|
||||
await Verify(tvShow);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowGetMovieWatchProviders()
|
||||
public async Task TestTvShowGetMovieWatchProviders()
|
||||
{
|
||||
SingleResultContainer<Dictionary<string, WatchProviders>> resp = Config.Client.GetTvShowWatchProvidersAsync(IdHelper.GameOfThrones).Result;
|
||||
SingleResultContainer<Dictionary<string, WatchProviders>> resp = await TMDbClient.GetTvShowWatchProvidersAsync(IdHelper.GameOfThrones);
|
||||
|
||||
Assert.NotNull(resp);
|
||||
|
||||
@ -367,303 +240,186 @@ namespace TMDbLibTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowTranslations()
|
||||
public async Task TestTvShowTranslationsAsync()
|
||||
{
|
||||
TranslationsContainerTv translations = Config.Client.GetTvShowTranslationsAsync(1668).Result;
|
||||
TranslationsContainerTv translations = await TMDbClient.GetTvShowTranslationsAsync(IdHelper.BreakingBad);
|
||||
|
||||
Assert.Equal(1668, translations.Id);
|
||||
Translation translation = translations.Translations.SingleOrDefault(s => s.Iso_639_1 == "hr");
|
||||
Assert.NotNull(translation);
|
||||
|
||||
Assert.Equal("Croatian", translation.EnglishName);
|
||||
Assert.Equal("hr", translation.Iso_639_1);
|
||||
Assert.Equal("Hrvatski", translation.Name);
|
||||
await Verify(translations);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowSimilars()
|
||||
public async Task TestTvShowSimilarsAsync()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
SearchContainer<SearchTv> tvShows = await TMDbClient.GetTvShowSimilarAsync(IdHelper.BreakingBad);
|
||||
|
||||
SearchContainer<SearchTv> tvShow = Config.Client.GetTvShowSimilarAsync(1668).Result;
|
||||
Assert.NotEmpty(tvShows.Results);
|
||||
|
||||
Assert.NotNull(tvShow);
|
||||
Assert.NotNull(tvShow.Results);
|
||||
SearchTv tvShow = tvShows.Results.Single(s => s.Id == 63351);
|
||||
|
||||
SearchTv item = tvShow.Results.SingleOrDefault(s => s.Id == 1100);
|
||||
Assert.NotNull(item);
|
||||
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.BackdropPath),
|
||||
"item.BackdropPath was not a valid image path, was: " + item.BackdropPath);
|
||||
Assert.Equal(1100, item.Id);
|
||||
Assert.Equal("How I Met Your Mother", item.OriginalName);
|
||||
Assert.Equal(new DateTime(2005, 09, 19), item.FirstAirDate);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.PosterPath),
|
||||
"item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
Assert.True(item.Popularity > 0);
|
||||
Assert.Equal("How I Met Your Mother", item.Name);
|
||||
Assert.True(item.VoteAverage > 0);
|
||||
Assert.True(item.VoteCount > 0);
|
||||
|
||||
Assert.NotNull(item.OriginCountry);
|
||||
Assert.Equal(1, item.OriginCountry.Count);
|
||||
Assert.True(item.OriginCountry.Contains("US"));
|
||||
await Verify(tvShow);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowRecommendations()
|
||||
public async Task TestTvShowRecommendationsAsync()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type", "results[array] / popularity");
|
||||
SearchContainer<SearchTv> tvShows = await TMDbClient.GetTvShowRecommendationsAsync(IdHelper.BreakingBad);
|
||||
|
||||
SearchContainer<SearchTv> tvShow = Config.Client.GetTvShowRecommendationsAsync(1668).Result;
|
||||
Assert.NotEmpty(tvShows.Results);
|
||||
|
||||
Assert.NotNull(tvShow);
|
||||
Assert.NotNull(tvShow.Results);
|
||||
SearchTv tvShow = tvShows.Results.Single(s => s.Id == 63351);
|
||||
|
||||
SearchTv item = tvShow.Results.SingleOrDefault(s => s.Id == 1100);
|
||||
Assert.NotNull(item);
|
||||
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.BackdropPath), "item.BackdropPath was not a valid image path, was: " + item.BackdropPath);
|
||||
Assert.Equal(1100, item.Id);
|
||||
Assert.Equal("How I Met Your Mother", item.OriginalName);
|
||||
Assert.Equal(new DateTime(2005, 09, 19), item.FirstAirDate);
|
||||
Assert.True(TestImagesHelpers.TestImagePath(item.PosterPath), "item.PosterPath was not a valid image path, was: " + item.PosterPath);
|
||||
Assert.Equal("How I Met Your Mother", item.Name);
|
||||
Assert.True(item.VoteAverage > 0);
|
||||
Assert.True(item.VoteCount > 0);
|
||||
|
||||
Assert.NotNull(item.OriginCountry);
|
||||
Assert.Equal(1, item.OriginCountry.Count);
|
||||
Assert.True(item.OriginCountry.Contains("US"));
|
||||
await Verify(tvShow);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowTopRated()
|
||||
public async Task TestTvShowTopRated()
|
||||
{
|
||||
// Ignore missing json
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
await TestHelpers.SearchPagesAsync(i => TMDbClient.GetTvShowTopRatedAsync(i));
|
||||
|
||||
// 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.
|
||||
TestHelpers.SearchPages(i => Config.Client.GetTvShowTopRatedAsync(i).Result);
|
||||
|
||||
SearchContainer<SearchTv> result = Config.Client.GetTvShowTopRatedAsync().Sync();
|
||||
Assert.NotNull(result.Results[0].Id);
|
||||
SearchContainer<SearchTv> result = await TMDbClient.GetTvShowTopRatedAsync();
|
||||
Assert.NotNull(result.Results[0].Name);
|
||||
Assert.NotNull(result.Results[0].OriginalName);
|
||||
Assert.NotNull(result.Results[0].FirstAirDate);
|
||||
Assert.NotNull(result.Results[0].PosterPath);
|
||||
Assert.NotNull(result.Results[0].BackdropPath);
|
||||
Assert.NotNull(result.Results[0].PosterPath ?? result.Results[0].BackdropPath);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowLatest()
|
||||
public async Task TestTvShowLatest()
|
||||
{
|
||||
IgnoreMissingJson(" / account_states", " / alternative_titles", " / changes", " / content_ratings", " / credits", " / external_ids", " / genre_ids", " / images", " / keywords", " / similar", " / translations", " / videos", " / recommendations");
|
||||
|
||||
TvShow tvShow = Config.Client.GetLatestTvShowAsync().Sync();
|
||||
TvShow tvShow = await TMDbClient.GetLatestTvShowAsync();
|
||||
|
||||
Assert.NotNull(tvShow);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowReviews()
|
||||
public async Task TestTvShowReviews()
|
||||
{
|
||||
TestHelpers.SearchPages(i => Config.Client.GetTvShowReviewsAsync(IdHelper.BreakingBad, page: i).Result);
|
||||
await TestHelpers.SearchPagesAsync<SearchContainerWithId<ReviewBase>, ReviewBase>(i => TMDbClient.GetTvShowReviewsAsync(IdHelper.BreakingBad, page: i));
|
||||
|
||||
SearchContainerWithId<ReviewBase> reviews = await TMDbClient.GetTvShowReviewsAsync(IdHelper.BreakingBad);
|
||||
|
||||
ReviewBase single = reviews.Results.Single(s => s.Id == "5accdbe6c3a3687e2702d058");
|
||||
|
||||
await Verify(single);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowLists()
|
||||
public async Task TestTvShowLists()
|
||||
{
|
||||
IgnoreMissingJson(" / account_states", " / alternative_titles", " / changes", " / content_ratings", " / created_by", " / credits", " / external_ids", " / genres", " / images", " / in_production", " / keywords", " / languages", " / networks", " / production_companies", " / seasons", " / similar", " / translations", " / videos", "results[array] / media_type", " / recommendations");
|
||||
|
||||
foreach (TvShowListType type in Enum.GetValues(typeof(TvShowListType)).OfType<TvShowListType>())
|
||||
{
|
||||
TestHelpers.SearchPages(i => Config.Client.GetTvShowListAsync(type, i).Result);
|
||||
await TestHelpers.SearchPagesAsync(i => TMDbClient.GetTvShowListAsync(type, i));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowAccountStateFavoriteSet()
|
||||
public async Task TestTvShowAccountStateFavoriteSet()
|
||||
{
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
AccountState accountState = Config.Client.GetTvShowAccountStateAsync(IdHelper.BreakingBad).Result;
|
||||
|
||||
// Remove the favourite
|
||||
if (accountState.Favorite)
|
||||
Config.Client.AccountChangeFavoriteStatusAsync(MediaType.Tv, IdHelper.BreakingBad, false).Sync();
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// Test that the movie is NOT favourited
|
||||
accountState = Config.Client.GetTvShowAccountStateAsync(IdHelper.BreakingBad).Result;
|
||||
|
||||
Assert.Equal(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.False(accountState.Favorite);
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
await TestMethodsHelper.SetValidateRemoveTest(async () =>
|
||||
{
|
||||
// Favourite the movie
|
||||
Config.Client.AccountChangeFavoriteStatusAsync(MediaType.Tv, IdHelper.BreakingBad, true).Sync();
|
||||
await TMDbClient.AccountChangeFavoriteStatusAsync(MediaType.Tv, IdHelper.BreakingBad, true);
|
||||
}, async () =>
|
||||
{
|
||||
// Un-favorite the movie
|
||||
await TMDbClient.AccountChangeFavoriteStatusAsync(MediaType.Tv, IdHelper.BreakingBad, false);
|
||||
}, async shouldBe =>
|
||||
{
|
||||
AccountState accountState = await TMDbClient.GetTvShowAccountStateAsync(IdHelper.BreakingBad);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// Test that the movie IS favourited
|
||||
accountState = Config.Client.GetTvShowAccountStateAsync(IdHelper.BreakingBad).Result;
|
||||
Assert.Equal(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.True(accountState.Favorite);
|
||||
Assert.Equal(shouldBe, accountState.Favorite);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowAccountStateWatchlistSet()
|
||||
public async Task TestTvShowAccountStateWatchlistSet()
|
||||
{
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
AccountState accountState = Config.Client.GetTvShowAccountStateAsync(IdHelper.BreakingBad).Result;
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Remove the watchlist
|
||||
if (accountState.Watchlist)
|
||||
Config.Client.AccountChangeWatchlistStatusAsync(MediaType.Tv, IdHelper.BreakingBad, false).Sync();
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// Test that the movie is NOT watchlisted
|
||||
accountState = Config.Client.GetTvShowAccountStateAsync(IdHelper.BreakingBad).Result;
|
||||
await TestMethodsHelper.SetValidateRemoveTest(async () =>
|
||||
{
|
||||
// Add to watchlist
|
||||
await TMDbClient.AccountChangeWatchlistStatusAsync(MediaType.Tv, IdHelper.BreakingBad, true);
|
||||
}, async () =>
|
||||
{
|
||||
// Remove from watchlist
|
||||
await TMDbClient.AccountChangeWatchlistStatusAsync(MediaType.Tv, IdHelper.BreakingBad, false);
|
||||
}, async shouldBe =>
|
||||
{
|
||||
AccountState accountState = await TMDbClient.GetTvShowAccountStateAsync(IdHelper.BreakingBad);
|
||||
|
||||
Assert.Equal(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.False(accountState.Watchlist);
|
||||
|
||||
// Watchlist the movie
|
||||
Config.Client.AccountChangeWatchlistStatusAsync(MediaType.Tv, IdHelper.BreakingBad, true).Sync();
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// Test that the movie IS watchlisted
|
||||
accountState = Config.Client.GetTvShowAccountStateAsync(IdHelper.BreakingBad).Result;
|
||||
Assert.Equal(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.True(accountState.Watchlist);
|
||||
Assert.Equal(shouldBe, accountState.Watchlist);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowAccountStateRatingSet()
|
||||
public async Task TestTvShowAccountStateRatingSet()
|
||||
{
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
AccountState accountState = Config.Client.GetTvShowAccountStateAsync(IdHelper.BreakingBad).Result;
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Remove the rating
|
||||
if (accountState.Rating.HasValue)
|
||||
await TestMethodsHelper.SetValidateRemoveTest(async () =>
|
||||
{
|
||||
Assert.True(Config.Client.TvShowRemoveRatingAsync(IdHelper.BreakingBad).Result);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// Test that the movie is NOT rated
|
||||
accountState = Config.Client.GetTvShowAccountStateAsync(IdHelper.BreakingBad).Result;
|
||||
// Rate
|
||||
await TMDbClient.TvShowSetRatingAsync(IdHelper.BreakingBad, 5);
|
||||
}, async () =>
|
||||
{
|
||||
// Un-rate
|
||||
Assert.True(await TMDbClient.TvShowRemoveRatingAsync(IdHelper.BreakingBad));
|
||||
}, async shouldBe =>
|
||||
{
|
||||
AccountState accountState = await TMDbClient.GetTvShowAccountStateAsync(IdHelper.BreakingBad);
|
||||
|
||||
Assert.Equal(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.False(accountState.Rating.HasValue);
|
||||
|
||||
// Rate the movie
|
||||
Config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 5).Sync();
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// Test that the movie IS rated
|
||||
accountState = Config.Client.GetTvShowAccountStateAsync(IdHelper.BreakingBad).Result;
|
||||
Assert.Equal(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.True(accountState.Rating.HasValue);
|
||||
|
||||
// Remove the rating
|
||||
Assert.True(Config.Client.TvShowRemoveRatingAsync(IdHelper.BreakingBad).Result);
|
||||
if (shouldBe)
|
||||
{
|
||||
Assert.NotNull(accountState.Rating);
|
||||
Assert.Equal(5, accountState.Rating.Value);
|
||||
}
|
||||
else
|
||||
Assert.Null(accountState.Rating);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowSetRatingBadRating()
|
||||
public async Task TestTvShowSetRating()
|
||||
{
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
Assert.False(Config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 7.1).Result);
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
|
||||
Assert.False(await TMDbClient.TvShowSetRatingAsync(IdHelper.BreakingBad, 10.5));
|
||||
|
||||
Assert.True(await TMDbClient.TvShowSetRatingAsync(IdHelper.BreakingBad, 7.0));
|
||||
|
||||
Assert.False(await TMDbClient.TvShowSetRatingAsync(IdHelper.BreakingBad, 7.1));
|
||||
|
||||
Assert.True(await TMDbClient.TvShowSetRatingAsync(IdHelper.BreakingBad, 7.5));
|
||||
|
||||
Assert.False(await TMDbClient.TvShowSetRatingAsync(IdHelper.BreakingBad, 0));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowSetRatingRatingOutOfBounds()
|
||||
{
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
Assert.False(Config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 10.5).Result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowSetRatingRatingLowerBoundsTest()
|
||||
{
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
Assert.False(Config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 0).Result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowSetRatingUserSession()
|
||||
{
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
AccountState accountState = Config.Client.GetTvShowAccountStateAsync(IdHelper.BreakingBad).Result;
|
||||
|
||||
// Remove the rating
|
||||
if (accountState.Rating.HasValue)
|
||||
{
|
||||
Assert.True(Config.Client.TvShowRemoveRatingAsync(IdHelper.BreakingBad).Result);
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
|
||||
// Test that the episode is NOT rated
|
||||
accountState = Config.Client.GetTvShowAccountStateAsync(IdHelper.BreakingBad).Result;
|
||||
|
||||
Assert.Equal(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.False(accountState.Rating.HasValue);
|
||||
|
||||
// Rate the episode
|
||||
Config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 5).Sync();
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
Thread.Sleep(2000);
|
||||
|
||||
// Test that the episode IS rated
|
||||
accountState = Config.Client.GetTvShowAccountStateAsync(IdHelper.BreakingBad).Result;
|
||||
Assert.Equal(IdHelper.BreakingBad, accountState.Id);
|
||||
Assert.True(accountState.Rating.HasValue);
|
||||
|
||||
// Remove the rating
|
||||
Assert.True(Config.Client.TvShowRemoveRatingAsync(IdHelper.BreakingBad).Result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowSetRatingGuestSession()
|
||||
public async Task TestTvShowSetRatingGuestSession()
|
||||
{
|
||||
// There is no way to validate the change besides the success return of the api call since the guest session doesn't have access to anything else
|
||||
Config.Client.SetSessionInformation(Config.GuestTestSessionId, SessionType.GuestSession);
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.GuestTestSessionId, SessionType.GuestSession);
|
||||
|
||||
// Try changing the rating
|
||||
Assert.True(Config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 7.5).Result);
|
||||
Assert.True(await TMDbClient.TvShowSetRatingAsync(IdHelper.BreakingBad, 7.5));
|
||||
|
||||
Assert.False(await TMDbClient.TvShowSetRatingAsync(IdHelper.BreakingBad, 7.1));
|
||||
|
||||
// Try changing it back to the previous rating
|
||||
Assert.True(Config.Client.TvShowSetRatingAsync(IdHelper.BreakingBad, 8).Result);
|
||||
Assert.True(await TMDbClient.TvShowSetRatingAsync(IdHelper.BreakingBad, 8));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestTvShowMissing()
|
||||
public async Task TestTvShowMissingAsync()
|
||||
{
|
||||
TvShow tvShow = Config.Client.GetTvShowAsync(IdHelper.MissingID).Result;
|
||||
TvShow tvShow = await TMDbClient.GetTvShowAsync(IdHelper.MissingID);
|
||||
|
||||
Assert.Null(tvShow);
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TMDbLibTests.Helpers
|
||||
{
|
||||
public static class AsyncHelper
|
||||
{
|
||||
public static void Sync(this Task task)
|
||||
{
|
||||
task.GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public static T Sync<T>(this Task<T> task)
|
||||
{
|
||||
return task.GetAwaiter().GetResult();
|
||||
}
|
||||
}
|
||||
}
|
@ -20,14 +20,18 @@
|
||||
|
||||
// TV
|
||||
public const int GameOfThrones = 1399;
|
||||
public const int GameOfThronesSeason8 = 107971;
|
||||
public const int GameOfThronesSeason4Episode10 = 63103;
|
||||
public const int BreakingBad = 1396;
|
||||
public const int BreakingBadSeason1Id = 3572;
|
||||
public const int BreakingBadSeason1Episode1Id = 62085;
|
||||
public const int BigBangTheory = 1418;
|
||||
public const int BigBangTheorySeason1Episode1Id = 64766;
|
||||
public const int BigBangTheorySeason1Episode2Id = 64777;
|
||||
public const int KeepingUpAppearances = 34;
|
||||
public const int DoctorWho = 121;
|
||||
public const int House = 1408;
|
||||
public const int FullerHouse = 63623;
|
||||
|
||||
public const int TmdbBreakingBadId = 1396;
|
||||
public const string TvdbBreakingBadId = "81189";
|
||||
@ -39,7 +43,7 @@
|
||||
public const string FreebaseMidBreakingBadId = "m/03d34x8";
|
||||
|
||||
// Persons
|
||||
public const int PersonPartialDate = 833;
|
||||
public const int FrankSinatra = 4347;
|
||||
public const int BruceWillis = 62;
|
||||
public const int HughLaurie = 41419;
|
||||
public const string ImdbBruceWillis = "nm0000246";
|
||||
@ -47,6 +51,7 @@
|
||||
|
||||
// Collections
|
||||
public const int JamesBondCollection = 645;
|
||||
public const int BackToTheFutureCollection = 264;
|
||||
|
||||
// Networks
|
||||
public const int TwentiethCenturyFox = 25;
|
||||
@ -58,6 +63,13 @@
|
||||
public const string BruceWillisMiamiVice = "525719bb760ee3776a1835d3";
|
||||
public const string HughLaurieHouse = "5256ccf519c2956ff607ca00";
|
||||
|
||||
// Genres
|
||||
public const int ActionAdventureTvGenre = 10759;
|
||||
public const int AdventureMovieGenre = 12;
|
||||
|
||||
// Keywords
|
||||
public const int AgentKeyword = 33705;
|
||||
|
||||
// Invalid IDs
|
||||
public const int MissingMovie = 230;
|
||||
public const int MissingID = 999999999;
|
||||
|
32
TMDbLibTests/Helpers/PropertyHelpers.cs
Normal file
32
TMDbLibTests/Helpers/PropertyHelpers.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
|
||||
namespace TMDbLibTests.Helpers
|
||||
{
|
||||
internal static class PropertyHelpers
|
||||
{
|
||||
public static PropertyInfo GetPropertyInfo<TSource, TProperty>(Expression<Func<TSource, TProperty>> propertyLambda)
|
||||
{
|
||||
Type type = typeof(TSource);
|
||||
|
||||
MemberExpression member;
|
||||
if (propertyLambda.Body is MemberExpression asMember)
|
||||
member = asMember;
|
||||
else if (propertyLambda.Body is UnaryExpression asUnary && asUnary.Operand is MemberExpression asMember2)
|
||||
member = asMember2;
|
||||
else
|
||||
throw new ArgumentException($"Expression '{propertyLambda}' refers to a method, not a property.");
|
||||
|
||||
PropertyInfo propInfo = member.Member as PropertyInfo;
|
||||
if (propInfo == null)
|
||||
throw new ArgumentException($"Expression '{propertyLambda}' refers to a field, not a property.");
|
||||
|
||||
if (type != propInfo.ReflectedType &&
|
||||
!type.IsSubclassOf(propInfo.ReflectedType))
|
||||
throw new ArgumentException($"Expression '{propertyLambda}' refers to a property that is not from type {type}.");
|
||||
|
||||
return propInfo;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using TMDbLib.Objects.General;
|
||||
using Xunit;
|
||||
|
||||
@ -8,56 +7,32 @@ namespace TMDbLibTests.Helpers
|
||||
{
|
||||
public static class TestHelpers
|
||||
{
|
||||
public static bool InternetUriExists(Uri uri)
|
||||
public static Task SearchPagesAsync<T>(Func<int, Task<SearchContainer<T>>> getter)
|
||||
{
|
||||
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri);
|
||||
req.Method = "HEAD";
|
||||
|
||||
try
|
||||
{
|
||||
using (req.GetResponseAsync().Sync())
|
||||
{
|
||||
// It exists
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
HttpWebResponse response = (HttpWebResponse)ex.Response;
|
||||
if (response == null)
|
||||
Debug.WriteLine(ex.Status + ": " + uri);
|
||||
else
|
||||
Debug.WriteLine(response.StatusCode + ": " + uri);
|
||||
return false;
|
||||
}
|
||||
return SearchPagesAsync<SearchContainer<T>, T>(getter);
|
||||
}
|
||||
|
||||
public static void SearchPages<T>(Func<int, SearchContainer<T>> getter)
|
||||
public static async Task SearchPagesAsync<TContainer, T>(Func<int, Task<TContainer>> getter) where TContainer : SearchContainer<T>
|
||||
{
|
||||
// Check page 1
|
||||
SearchContainer<T> results = getter(1);
|
||||
TContainer results = await getter(1);
|
||||
|
||||
Assert.NotNull(results);
|
||||
Assert.NotNull(results.Results);
|
||||
Assert.Equal(1, results.Page);
|
||||
Assert.NotEmpty(results.Results);
|
||||
Assert.True(results.Results.Count > 0);
|
||||
Assert.True(results.TotalResults > 0);
|
||||
Assert.True(results.TotalPages > 0);
|
||||
|
||||
// Check page 2
|
||||
SearchContainer<T> results2 = getter(2);
|
||||
TContainer results2 = await getter(2);
|
||||
|
||||
Assert.NotNull(results2);
|
||||
Assert.NotNull(results2.Results);
|
||||
Assert.Equal(2, results2.Page);
|
||||
// The page counts often don't match due to caching on the api
|
||||
//Assert.AreEqual(results.TotalResults, results2.TotalResults);
|
||||
//Assert.AreEqual(results.TotalPages, results2.TotalPages);
|
||||
|
||||
// If page 1 has all results, page 2 must be empty - else not.
|
||||
if (results.Results.Count == results.TotalResults)
|
||||
Assert.Equal(0, results2.Results.Count);
|
||||
Assert.Empty(results2.Results);
|
||||
else
|
||||
Assert.NotEqual(0, results2.Results.Count);
|
||||
Assert.NotEmpty(results2.Results);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMDbLib.Objects.General;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.People;
|
||||
using Xunit;
|
||||
|
||||
@ -12,43 +10,25 @@ namespace TMDbLibTests.Helpers
|
||||
{
|
||||
private static readonly Regex ImagePathRegex = new Regex(@"^/[a-zA-Z0-9]{26,}\.(?:jpg|png)$", RegexOptions.Compiled);
|
||||
|
||||
public static void TestImages(TestConfig config, ProfileImages images)
|
||||
public static void TestImagePaths(Images images)
|
||||
{
|
||||
Assert.True(images.Profiles.Count > 0);
|
||||
|
||||
string profileSize = config.Client.Config.Images.ProfileSizes.First();
|
||||
|
||||
TestImagesInternal(config, images.Profiles.Select(s => s.FilePath), profileSize);
|
||||
TestImagePaths(images.Backdrops);
|
||||
TestImagePaths(images.Posters);
|
||||
}
|
||||
|
||||
public static void TestImages(TestConfig config, Images images)
|
||||
public static void TestImagePaths(IEnumerable<string> imagePaths)
|
||||
{
|
||||
Assert.True(images.Backdrops.Count > 0);
|
||||
Assert.True(images.Posters.Count > 0);
|
||||
|
||||
string backdropSize = config.Client.Config.Images.BackdropSizes.First();
|
||||
string posterSize = config.Client.Config.Images.PosterSizes.First();
|
||||
|
||||
TestImagesInternal(config, images.Backdrops.Select(s => s.FilePath), backdropSize);
|
||||
|
||||
TestImagesInternal(config, images.Posters.Select(s => s.FilePath), posterSize);
|
||||
Assert.All(imagePaths, path => Assert.True(ImagePathRegex.IsMatch(path), "path was not a valid image path, was: " + path));
|
||||
}
|
||||
|
||||
private static void TestImagesInternal(TestConfig config, IEnumerable<string> images, string posterSize)
|
||||
public static void TestImagePaths<T>(IEnumerable<T> images) where T : ImageData
|
||||
{
|
||||
foreach (string imageData in images)
|
||||
{
|
||||
Uri url = config.Client.GetImageUrl(posterSize, imageData);
|
||||
Uri urlSecure = config.Client.GetImageUrl(posterSize, imageData, true);
|
||||
|
||||
Assert.True(TestHelpers.InternetUriExists(url));
|
||||
Assert.True(TestHelpers.InternetUriExists(urlSecure));
|
||||
}
|
||||
Assert.All(images, x => Assert.True(ImagePathRegex.IsMatch(x.FilePath), "image.FilePath was not a valid image path, was: " + x.FilePath));
|
||||
}
|
||||
|
||||
public static bool TestImagePath(string path)
|
||||
public static void TestImagePaths(IEnumerable<TaggedImage> images)
|
||||
{
|
||||
return ImagePathRegex.IsMatch(path);
|
||||
Assert.All(images, x => Assert.True(ImagePathRegex.IsMatch(x.FilePath), "image.FilePath was not a valid image path, was: " + x.FilePath));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,41 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace TMDbLibTests.Helpers
|
||||
{
|
||||
public static class TestMethodsHelper
|
||||
{
|
||||
public static void TestGetExclusive<T, TId, TResult>(Dictionary<T, Func<TResult, object>> methodSelectors, Func<TId, T, TResult> getterMethod, TId id) where T : struct
|
||||
/// <summary>
|
||||
/// Tests that a client method will get a specific part of the TMDb api, but not any other methods
|
||||
/// </summary>
|
||||
public static async Task TestGetExclusive<TEnum, TResult>(Dictionary<TEnum, Func<TResult, object>> methodSelectors, Func<TEnum, Task<TResult>> getterMethod) where TEnum : Enum
|
||||
{
|
||||
Assert.True(typeof(T).GetTypeInfo().IsEnum);
|
||||
|
||||
// Test each method
|
||||
foreach (T method in methodSelectors.Keys)
|
||||
foreach (TEnum method in methodSelectors.Keys)
|
||||
{
|
||||
// Fetch data
|
||||
TResult item = getterMethod(id, method);
|
||||
TResult item = await getterMethod(method);
|
||||
|
||||
// Ensure we have the piece we're looking for
|
||||
Assert.NotNull(methodSelectors[method](item));
|
||||
|
||||
// .. And none of the others
|
||||
foreach (T nonExpectedMethod in methodSelectors.Keys.Except(new[] { method }))
|
||||
Assert.Null(methodSelectors[nonExpectedMethod](item));
|
||||
foreach (TEnum otherMethod in methodSelectors.Keys.Except(new[] { method }))
|
||||
Assert.Null(methodSelectors[otherMethod](item));
|
||||
}
|
||||
}
|
||||
|
||||
public static void TestAllNotNull<T, TResult>(Dictionary<T, Func<TResult, object>> methodSelectors, TResult item) where T : struct
|
||||
/// <summary>
|
||||
/// Tests that a client method will get all parts of the TMDb api, when requested
|
||||
/// </summary>
|
||||
public static async Task TestGetAll<TEnum, TResult>(Dictionary<TEnum, Func<TResult, object>> methodSelectors, Func<TEnum, Task<TResult>> getterMethod, Func<TResult, Task> extraAction = null) where TEnum : Enum
|
||||
{
|
||||
Assert.True(typeof(T).GetTypeInfo().IsEnum);
|
||||
int combinedEnumInt = 0;
|
||||
foreach (TEnum key in methodSelectors.Keys)
|
||||
combinedEnumInt |= Convert.ToInt32(key);
|
||||
|
||||
TEnum combinedEnum = (TEnum)Enum.ToObject(typeof(TEnum), combinedEnumInt);
|
||||
|
||||
TResult item = await getterMethod(combinedEnum);
|
||||
|
||||
// Ensure we have all the pieces
|
||||
foreach (T method in methodSelectors.Keys)
|
||||
{
|
||||
foreach (TEnum method in methodSelectors.Keys)
|
||||
Assert.NotNull(methodSelectors[method](item));
|
||||
}
|
||||
|
||||
// Execute any additional tests
|
||||
if (extraAction != null)
|
||||
await extraAction(item);
|
||||
}
|
||||
|
||||
public static async Task SetValidateRemoveTest(Func<Task> set, Func<Task> remove, Func<bool, Task> validate)
|
||||
{
|
||||
// Act
|
||||
await set();
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
await Task.Delay(2000);
|
||||
|
||||
// Validate
|
||||
await validate(true);
|
||||
|
||||
// Act
|
||||
await remove();
|
||||
|
||||
// Allow TMDb to cache our changes
|
||||
await Task.Delay(2000);
|
||||
|
||||
// Validate
|
||||
await validate(false);
|
||||
}
|
||||
}
|
||||
}
|
73
TMDbLibTests/Helpers/VerifyExtensions.cs
Normal file
73
TMDbLibTests/Helpers/VerifyExtensions.cs
Normal file
@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using Newtonsoft.Json;
|
||||
using VerifyTests;
|
||||
|
||||
namespace TMDbLibTests.Helpers
|
||||
{
|
||||
internal static class VerifyExtensions
|
||||
{
|
||||
private static string GetPropertyName<T>(Expression<Func<T, object>> expression)
|
||||
{
|
||||
PropertyInfo prop = PropertyHelpers.GetPropertyInfo(expression);
|
||||
|
||||
JsonPropertyAttribute jsonPropAttribute = prop.GetCustomAttribute<JsonPropertyAttribute>();
|
||||
return jsonPropAttribute?.PropertyName ?? prop.Name;
|
||||
}
|
||||
|
||||
public static VerifySettings IgnoreProperty(this VerifySettings settings, params string[] properties)
|
||||
{
|
||||
foreach (string propName in properties)
|
||||
{
|
||||
string searchString = $" {propName}: ";
|
||||
settings.ScrubLines(x => x.Contains(searchString));
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
public static VerifySettings IgnoreProperty<T>(this VerifySettings settings, params Expression<Func<T, object>>[] properties)
|
||||
{
|
||||
string[] propNames = properties.Select(GetPropertyName).ToArray();
|
||||
|
||||
return settings.IgnoreProperty(propNames);
|
||||
}
|
||||
|
||||
private static Regex _propRegex = new Regex(@"^(?<pre>[\s]*)(?<name>[\S]+): (?<value>.*?)(?<post>,|$)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
public static VerifySettings SimplifyProperty(this VerifySettings settings, params string[] properties)
|
||||
{
|
||||
foreach (string propName in properties)
|
||||
{
|
||||
settings.ScrubLinesWithReplace(original =>
|
||||
{
|
||||
Match match = _propRegex.Match(original);
|
||||
if (!match.Success)
|
||||
return original;
|
||||
|
||||
if (match.Groups["name"].Value != propName)
|
||||
return original;
|
||||
|
||||
string newValue = match.Groups["value"].Value;
|
||||
if (newValue.Length > 0)
|
||||
newValue = "<non-empty>";
|
||||
|
||||
return match.Groups["pre"].Value + match.Groups["name"].Value + ": " + newValue +
|
||||
match.Groups["post"].Value;
|
||||
});
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
public static VerifySettings SimplifyProperty<T>(this VerifySettings settings, params Expression<Func<T, object>>[] properties)
|
||||
{
|
||||
string[] propNames = properties.Select(GetPropertyName).ToArray();
|
||||
|
||||
return settings.SimplifyProperty(propNames);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
namespace TMDbLibTests.JsonHelpers
|
||||
{
|
||||
public class FailingContractResolver : DefaultContractResolver
|
||||
{
|
||||
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
|
||||
{
|
||||
JsonProperty res = base.CreateProperty(member, memberSerialization);
|
||||
|
||||
if (!res.Ignored)
|
||||
// If we haven't explicitly stated that a field is not needed, we require it for compliance
|
||||
res.Required = Required.AllowNull;
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,146 +1,174 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using TMDbLib.Client;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Search;
|
||||
using TMDbLibTests.Helpers;
|
||||
using VerifyTests;
|
||||
using VerifyXunit;
|
||||
|
||||
namespace TMDbLibTests.JsonHelpers
|
||||
{
|
||||
public class TestBase : IDisposable
|
||||
[UsesVerify]
|
||||
public abstract class TestBase
|
||||
{
|
||||
private static readonly Regex NormalizeRegex = new Regex(@"\[[\d]+\]", RegexOptions.Compiled);
|
||||
private readonly List<ErrorEventArgs> _errors = new List<ErrorEventArgs>();
|
||||
private VerifySettings VerifySettings { get; }
|
||||
|
||||
protected readonly TestConfig Config;
|
||||
protected readonly TestConfig TestConfig;
|
||||
|
||||
private readonly List<string> _ignoreMissingCSharp;
|
||||
protected TMDbClient TMDbClient => TestConfig.Client;
|
||||
|
||||
private readonly List<string> _ignoreMissingJson;
|
||||
|
||||
/// <summary>
|
||||
/// Ignores errors about missing JSON properties (Where C# properties are not set)
|
||||
/// </summary>
|
||||
protected void IgnoreMissingJson(params string[] keys)
|
||||
protected TestBase()
|
||||
{
|
||||
_ignoreMissingJson.AddRange(keys);
|
||||
}
|
||||
VerifySettings = new VerifySettings();
|
||||
//VerifySettings.UseExtension("json");
|
||||
VerifySettings.AutoVerify();
|
||||
|
||||
/// <summary>
|
||||
/// Ignores errors about missing C# properties (Where new or unknown JSON properties are present)
|
||||
/// </summary>
|
||||
protected void IgnoreMissingCSharp(params string[] keys)
|
||||
{
|
||||
_ignoreMissingCSharp.AddRange(keys);
|
||||
}
|
||||
VerifySettings.UseDirectory("..\\Verification");
|
||||
|
||||
public TestBase()
|
||||
// Ignore and simplify many dynamic properties
|
||||
VerifySettings.IgnoreProperty<SearchMovie>(x => x.VoteCount, x => x.Popularity, x => x.VoteAverage);
|
||||
VerifySettings.SimplifyProperty<SearchMovie>(x => x.BackdropPath, x => x.PosterPath);
|
||||
VerifySettings.SimplifyProperty<SearchPerson>(x => x.ProfilePath);
|
||||
VerifySettings.SimplifyProperty<SearchTvEpisode>(x => x.StillPath);
|
||||
VerifySettings.SimplifyProperty<ImageData>(x => x.FilePath);
|
||||
VerifySettings.SimplifyProperty<SearchCompany>(x => x.LogoPath);
|
||||
|
||||
VerifySettings.AddExtraSettings(serializerSettings =>
|
||||
{
|
||||
_ignoreMissingJson = new List<string>();
|
||||
_ignoreMissingCSharp = new List<string>();
|
||||
serializerSettings.ContractResolver = new DataSortingContractResolver(serializerSettings.ContractResolver);
|
||||
});
|
||||
|
||||
JsonSerializerSettings sett = new JsonSerializerSettings();
|
||||
|
||||
sett.MissingMemberHandling = MissingMemberHandling.Error;
|
||||
sett.ContractResolver = new FailingContractResolver();
|
||||
sett.Error = Error;
|
||||
WebProxy proxy = null;
|
||||
//WebProxy proxy = new WebProxy("http://127.0.0.1:8888");
|
||||
|
||||
Config = new TestConfig(serializer: JsonSerializer.Create(sett));
|
||||
TestConfig = new TestConfig(serializer: JsonSerializer.Create(sett), proxy: proxy);
|
||||
}
|
||||
|
||||
private void Error(object sender, ErrorEventArgs errorEventArgs)
|
||||
protected Task Verify<T>(T obj, Action<VerifySettings> configure = null)
|
||||
{
|
||||
_errors.Add(errorEventArgs);
|
||||
errorEventArgs.ErrorContext.Handled = true;
|
||||
VerifySettings settings = VerifySettings;
|
||||
|
||||
if (configure != null)
|
||||
{
|
||||
settings = new VerifySettings(VerifySettings);
|
||||
configure(settings);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_errors.Any())
|
||||
{
|
||||
// Sort the errors
|
||||
// Also deduplicate them, as there is no point in blasting us with multiple instances of the "same" error
|
||||
Dictionary<string, ErrorEventArgs> missingFieldInCSharp = new Dictionary<string, ErrorEventArgs>();
|
||||
Dictionary<string, ErrorEventArgs> missingPropertyInJson = new Dictionary<string, ErrorEventArgs>();
|
||||
Dictionary<string, ErrorEventArgs> other = new Dictionary<string, ErrorEventArgs>();
|
||||
|
||||
foreach (ErrorEventArgs error in _errors)
|
||||
{
|
||||
string key = error.ErrorContext.Path + " / " + error.ErrorContext.Member;
|
||||
string errorMessage = error.ErrorContext.Error.Message;
|
||||
|
||||
key = NormalizeRegex.Replace(key, "[array]");
|
||||
|
||||
if (errorMessage.StartsWith("Could not find member"))
|
||||
{
|
||||
// Field in JSON is missing in C#
|
||||
if (!_ignoreMissingCSharp.Contains(key) && !missingFieldInCSharp.ContainsKey(key))
|
||||
missingFieldInCSharp.Add(key, error);
|
||||
return Verifier.Verify(obj, settings);
|
||||
}
|
||||
else if (errorMessage.StartsWith("Required property"))
|
||||
|
||||
class DataSortingContractResolver : IContractResolver
|
||||
{
|
||||
// Field in C# is missing in JSON
|
||||
if (!_ignoreMissingJson.Contains(key) && !missingPropertyInJson.ContainsKey(key))
|
||||
missingPropertyInJson.Add(key, error);
|
||||
private readonly IContractResolver _innerResolver;
|
||||
|
||||
public DataSortingContractResolver(IContractResolver innerResolver)
|
||||
{
|
||||
_innerResolver = innerResolver;
|
||||
}
|
||||
|
||||
public JsonContract ResolveContract(Type type)
|
||||
{
|
||||
JsonContract contract = _innerResolver.ResolveContract(type);
|
||||
|
||||
// Add a callback that is invoked on each serialization of an object
|
||||
// We do this to be able to sort lists
|
||||
contract.OnSerializingCallbacks.Add(SerializingCallback);
|
||||
|
||||
return contract;
|
||||
}
|
||||
|
||||
private static string[] _sortFieldsInOrder = { "CreditId", "Id", "Iso_3166_1", "EpisodeNumber", "SeasonNumber" };
|
||||
|
||||
private void SerializingCallback(object obj, StreamingContext context)
|
||||
{
|
||||
if (!(obj is IEnumerable) || obj is IDictionary)
|
||||
return;
|
||||
|
||||
Type objType = obj.GetType();
|
||||
if (obj is IList objAsList)
|
||||
{
|
||||
Debug.Assert(objType.IsGenericType);
|
||||
|
||||
Type innerType = objType.GetGenericArguments().First();
|
||||
|
||||
// Determine which comparer to use
|
||||
IComparer comparer = null;
|
||||
if (innerType.IsValueType)
|
||||
comparer = Comparer.Default;
|
||||
else
|
||||
{
|
||||
if (!other.ContainsKey(key))
|
||||
other.Add(key, error);
|
||||
}
|
||||
}
|
||||
|
||||
// Combine all errors into a nice text
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (missingFieldInCSharp.Any())
|
||||
foreach (string fieldName in _sortFieldsInOrder)
|
||||
{
|
||||
sb.AppendLine("Fields missing in C# (Present in JSON)");
|
||||
foreach (KeyValuePair<string, ErrorEventArgs> pair in missingFieldInCSharp)
|
||||
sb.AppendLine($"[{pair.Value.CurrentObject.GetType().Name}] {pair.Key}: {pair.Value.ErrorContext.Error.Message}");
|
||||
PropertyInfo prop = innerType.GetProperty(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty);
|
||||
if (prop == null)
|
||||
continue;
|
||||
|
||||
sb.AppendLine();
|
||||
comparer = new CompareObjectOnProperty(prop);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (missingPropertyInJson.Any())
|
||||
if (comparer != null)
|
||||
{
|
||||
sb.AppendLine("Fields missing in JSON (Present in C#)");
|
||||
foreach (KeyValuePair<string, ErrorEventArgs> pair in missingPropertyInJson)
|
||||
sb.AppendLine($"[{pair.Value.CurrentObject.GetType().Name}] {pair.Key}: {pair.Value.ErrorContext.Error.Message}");
|
||||
// Is sorted?
|
||||
bool isSorted = IsSorted(objAsList, comparer);
|
||||
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
if (other.Any())
|
||||
if (!isSorted)
|
||||
{
|
||||
sb.AppendLine("Other errors");
|
||||
foreach (KeyValuePair<string, ErrorEventArgs> pair in other)
|
||||
sb.AppendLine($"[{pair.Value.CurrentObject.GetType().Name}] {pair.Key}: {pair.Value.ErrorContext.Error.Message}");
|
||||
// Sort the list using our comparer
|
||||
List<object> sortList = objAsList.Cast<object>().ToList();
|
||||
sortList.Sort((x, y) => comparer.Compare(x, y));
|
||||
|
||||
sb.AppendLine();
|
||||
// Transfer values
|
||||
for (int i = 0; i < objAsList.Count; i++)
|
||||
objAsList[i] = sortList[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (missingFieldInCSharp.Any())
|
||||
private static bool IsSorted(IList list, IComparer comparer)
|
||||
{
|
||||
// Helper line of properties that can be ignored
|
||||
sb.AppendLine("Ignore JSON props missing from C#:");
|
||||
sb.AppendLine(nameof(IgnoreMissingCSharp) + "(" + string.Join(", ", missingFieldInCSharp.OrderBy(s => s.Key).Select(s => $"\"{s.Key}\"")) + ");");
|
||||
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
if (missingPropertyInJson.Any())
|
||||
for (var i = 1; i < list.Count; i++)
|
||||
{
|
||||
// Helper line of properties that can be ignored
|
||||
sb.AppendLine("Ignore C# props missing from JSON:");
|
||||
sb.AppendLine(nameof(IgnoreMissingJson) + "(" + string.Join(", ", missingPropertyInJson.OrderBy(s => s.Key).Select(s => $"\"{s.Key}\"")) + ");");
|
||||
var a = list[i - 1];
|
||||
var b = list[i];
|
||||
|
||||
sb.AppendLine();
|
||||
if (comparer.Compare(a, b) > 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (missingFieldInCSharp.Any() || missingPropertyInJson.Any() || other.Any())
|
||||
throw new Exception(sb.ToString());
|
||||
return true;
|
||||
}
|
||||
|
||||
class CompareObjectOnProperty : IComparer
|
||||
{
|
||||
private readonly PropertyInfo _property;
|
||||
|
||||
public CompareObjectOnProperty(PropertyInfo property)
|
||||
{
|
||||
_property = property;
|
||||
}
|
||||
|
||||
public int Compare(object x, object y)
|
||||
{
|
||||
object? valX = _property.GetValue(x);
|
||||
object? valY = _property.GetValue(y);
|
||||
|
||||
return Comparer.Default.Compare(valX, valY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,14 +6,19 @@
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="JsonHelpers\*.verified.txt" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TMDbLib\TMDbLib.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
|
||||
<PackageReference Include="xunit" Version="2.2.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" PrivateAssets="All" />
|
||||
<PackageReference Include="Verify.Xunit" Version="11.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Net;
|
||||
using Newtonsoft.Json;
|
||||
using TMDbLibTests.Exceptions;
|
||||
using TMDbLib.Client;
|
||||
|
||||
@ -13,18 +14,18 @@ namespace TMDbLibTests
|
||||
public readonly string UserSessionId = "c413282cdadad9af972c06d9b13096a8b13ab1c1";
|
||||
public readonly string GuestTestSessionId = "d425468da2781d6799ba14c05f7327e7";
|
||||
|
||||
public TMDbClient Client { get; set; }
|
||||
public TMDbClient Client { get; }
|
||||
|
||||
public string Username = "TMDbTestAccount";
|
||||
|
||||
public string Password = "TJX6vP7bPC%!ZrJwAqtCU5FshHEKAwzr6YvR3%CU9s7BrjqUWmjC8AMuXju*eTEu524zsxDQK5ySY6EmjAC3e54B%WvkS9FNPE3K";
|
||||
|
||||
public TestConfig(bool useSsl = false, JsonSerializer serializer = null)
|
||||
public TestConfig(bool useSsl = false, JsonSerializer serializer = null, IWebProxy proxy = null)
|
||||
{
|
||||
if (APIKey.Length == 0)
|
||||
throw new ConfigurationErrorsException("You need to configure the API Key before running any tests. Look at the TestConfig class.");
|
||||
|
||||
Client = new TMDbClient(APIKey, useSsl, serializer: serializer)
|
||||
Client = new TMDbClient(APIKey, useSsl, serializer: serializer, proxy: proxy)
|
||||
{
|
||||
MaxRetryCount = 1
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
using TMDbLib.Objects.General;
|
||||
@ -20,13 +21,15 @@ namespace TMDbLibTests.UtilityTests
|
||||
JsonSerializerSettings settings = new JsonSerializerSettings();
|
||||
settings.Converters.Add(new AccountStateConverter());
|
||||
|
||||
AccountState original = new AccountState();
|
||||
original.Rating = 5;
|
||||
var original = new
|
||||
{
|
||||
rated = new { value = 5 }
|
||||
};
|
||||
|
||||
string json = JsonConvert.SerializeObject(original, settings);
|
||||
AccountState result = JsonConvert.DeserializeObject<AccountState>(json, settings);
|
||||
|
||||
Assert.Equal(original.Rating, result.Rating);
|
||||
Assert.Equal(5, result.Rating);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@ -37,54 +40,48 @@ namespace TMDbLibTests.UtilityTests
|
||||
JsonSerializerSettings settings = new JsonSerializerSettings();
|
||||
settings.Converters.Add(new AccountStateConverter());
|
||||
|
||||
AccountState original = new AccountState();
|
||||
original.Rating = null;
|
||||
|
||||
var original = new { rated = false };
|
||||
string json = JsonConvert.SerializeObject(original, settings);
|
||||
AccountState result = JsonConvert.DeserializeObject<AccountState>(json, settings);
|
||||
|
||||
Assert.Equal(original.Rating, result.Rating);
|
||||
Assert.Null(result.Rating);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the AccountStateConverter on the AccountState type
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestAccountStateConverterAccountState()
|
||||
public async Task TestAccountStateConverterAccountState()
|
||||
{
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
AccountState accountState = Config.Client.GetMovieAccountStateAsync(IdHelper.Avatar).Sync();
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
AccountState accountState = await TMDbClient.GetMovieAccountStateAsync(IdHelper.Avatar);
|
||||
|
||||
Assert.Equal(IdHelper.Avatar, accountState.Id);
|
||||
Assert.True(accountState.Favorite);
|
||||
Assert.False(accountState.Watchlist);
|
||||
Assert.Equal(2.5d, accountState.Rating);
|
||||
await Verify(accountState);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the AccountStateConverter on the TvEpisodeAccountState type
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestAccountStateConverterTvEpisodeAccountState()
|
||||
public async Task TestAccountStateConverterTvEpisodeAccountState()
|
||||
{
|
||||
Config.Client.SetSessionInformation(Config.UserSessionId, SessionType.UserSession);
|
||||
ResultContainer<TvEpisodeAccountStateWithNumber> season = Config.Client.GetTvSeasonAccountStateAsync(IdHelper.BigBangTheory, 1).Sync();
|
||||
await TMDbClient.SetSessionInformationAsync(TestConfig.UserSessionId, SessionType.UserSession);
|
||||
ResultContainer<TvEpisodeAccountStateWithNumber> season = await TMDbClient.GetTvSeasonAccountStateAsync(IdHelper.BigBangTheory, 1);
|
||||
|
||||
// Episode 1 has a rating
|
||||
TvEpisodeAccountStateWithNumber episode = season.Results.FirstOrDefault(s => s.EpisodeNumber == 1);
|
||||
Assert.NotNull(episode);
|
||||
TvEpisodeAccountStateWithNumber episodeA = season.Results.Single(s => s.EpisodeNumber == 1);
|
||||
|
||||
Assert.Equal(IdHelper.BigBangTheorySeason1Episode1Id, episode.Id);
|
||||
Assert.Equal(1, episode.EpisodeNumber);
|
||||
Assert.Equal(5d, episode.Rating);
|
||||
Assert.NotNull(episodeA.Rating);
|
||||
|
||||
// Episode 2 has no rating
|
||||
episode = season.Results.FirstOrDefault(s => s.EpisodeNumber == 2);
|
||||
Assert.NotNull(episode);
|
||||
TvEpisodeAccountStateWithNumber episodeB = season.Results.Single(s => s.EpisodeNumber == 2);
|
||||
Assert.Null(episodeB.Rating);
|
||||
|
||||
Assert.Equal(IdHelper.BigBangTheorySeason1Episode2Id, episode.Id);
|
||||
Assert.Equal(2, episode.EpisodeNumber);
|
||||
Assert.Null(episode.Rating);
|
||||
await Verify(new
|
||||
{
|
||||
episodeA,
|
||||
episodeB
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using TMDbLib.Objects.Changes;
|
||||
using TMDbLib.Objects.Movies;
|
||||
using TMDbLib.Utilities.Converters;
|
||||
using TMDbLibTests.Helpers;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
using Xunit;
|
||||
|
||||
@ -13,7 +13,7 @@ namespace TMDbLibTests.UtilityTests
|
||||
public class ChangeItemConverterTest : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void ChangeItemConverter_ChangeItemAdded()
|
||||
public async Task ChangeItemConverter_ChangeItemAdded()
|
||||
{
|
||||
JsonSerializerSettings settings = new JsonSerializerSettings();
|
||||
settings.Converters.Add(new ChangeItemConverter());
|
||||
@ -25,13 +25,11 @@ namespace TMDbLibTests.UtilityTests
|
||||
string json = JsonConvert.SerializeObject(original, settings);
|
||||
ChangeItemAdded result = JsonConvert.DeserializeObject<ChangeItemBase>(json, settings) as ChangeItemAdded;
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(original.Iso_639_1, result.Iso_639_1);
|
||||
Assert.Equal(original.Value, result.Value);
|
||||
await Verify(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ChangeItemConverter_ChangeItemCreated()
|
||||
public async Task ChangeItemConverter_ChangeItemCreated()
|
||||
{
|
||||
JsonSerializerSettings settings = new JsonSerializerSettings();
|
||||
settings.Converters.Add(new ChangeItemConverter());
|
||||
@ -42,12 +40,11 @@ namespace TMDbLibTests.UtilityTests
|
||||
string json = JsonConvert.SerializeObject(original, settings);
|
||||
ChangeItemCreated result = JsonConvert.DeserializeObject<ChangeItemBase>(json, settings) as ChangeItemCreated;
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(original.Iso_639_1, result.Iso_639_1);
|
||||
await Verify(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ChangeItemConverter_ChangeItemDeleted()
|
||||
public async Task ChangeItemConverter_ChangeItemDeleted()
|
||||
{
|
||||
JsonSerializerSettings settings = new JsonSerializerSettings();
|
||||
settings.Converters.Add(new ChangeItemConverter());
|
||||
@ -59,13 +56,11 @@ namespace TMDbLibTests.UtilityTests
|
||||
string json = JsonConvert.SerializeObject(original, settings);
|
||||
ChangeItemDeleted result = JsonConvert.DeserializeObject<ChangeItemBase>(json, settings) as ChangeItemDeleted;
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(original.Iso_639_1, result.Iso_639_1);
|
||||
Assert.Equal(original.OriginalValue, result.OriginalValue);
|
||||
await Verify(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ChangeItemConverter_ChangeItemUpdated()
|
||||
public async Task ChangeItemConverter_ChangeItemUpdated()
|
||||
{
|
||||
JsonSerializerSettings settings = new JsonSerializerSettings();
|
||||
settings.Converters.Add(new ChangeItemConverter());
|
||||
@ -78,26 +73,18 @@ namespace TMDbLibTests.UtilityTests
|
||||
string json = JsonConvert.SerializeObject(original, settings);
|
||||
ChangeItemUpdated result = JsonConvert.DeserializeObject<ChangeItemBase>(json, settings) as ChangeItemUpdated;
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(original.Iso_639_1, result.Iso_639_1);
|
||||
Assert.Equal(original.OriginalValue, result.OriginalValue);
|
||||
Assert.Equal(original.Value, result.Value);
|
||||
await Verify(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the ChangeItemConverter
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestChangeItemConverter()
|
||||
public async Task TestChangeItemConverter()
|
||||
{
|
||||
// Not all ChangeItem's have an iso_639_1 or an original_value
|
||||
IgnoreMissingJson(" / iso_639_1", " / original_value");
|
||||
Movie latestMovie = await TMDbClient.GetMovieLatestAsync();
|
||||
IList<Change> changes = await TMDbClient.GetMovieChangesAsync(latestMovie.Id);
|
||||
|
||||
// Ignore missing movie properties
|
||||
IgnoreMissingJson(" / account_states", " / alternative_titles", " / changes", " / credits", " / images", " / keywords", " / lists", " / release_dates", " / releases", " / reviews", " / similar", " / translations", " / videos", " / external_ids", " / recommendations");
|
||||
|
||||
Movie latestMovie = Config.Client.GetMovieLatestAsync().Sync();
|
||||
List<Change> changes = Config.Client.GetMovieChangesAsync(latestMovie.Id).Sync();
|
||||
List<ChangeItemBase> changeItems = changes.SelectMany(s => s.Items).ToList();
|
||||
|
||||
ChangeAction[] actions = { ChangeAction.Added, ChangeAction.Created, ChangeAction.Updated };
|
||||
|
@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
using TMDbLib.Utilities.Converters;
|
||||
using TMDbLibTests.Helpers;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
using Xunit;
|
||||
|
||||
@ -30,9 +30,9 @@ namespace TMDbLibTests.UtilityTests
|
||||
/// Tests the CustomDatetimeFormatConverter
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestCustomDatetimeFormatConverter()
|
||||
public async Task TestCustomDatetimeFormatConverter()
|
||||
{
|
||||
Token token = Config.Client.AuthenticationRequestAutenticationTokenAsync().Sync();
|
||||
Token token = await TMDbClient.AuthenticationRequestAutenticationTokenAsync();
|
||||
|
||||
DateTime low = DateTime.UtcNow.AddHours(-2);
|
||||
DateTime high = DateTime.UtcNow.AddHours(2);
|
||||
|
@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json;
|
||||
using TMDbLib.Objects.Changes;
|
||||
using TMDbLib.Objects.General;
|
||||
@ -15,11 +13,11 @@ namespace TMDbLibTests.UtilityTests
|
||||
{
|
||||
public static IEnumerable<object[]> GetEnumMembers(Type type)
|
||||
{
|
||||
IEnumerable<FieldInfo> members = type.GetTypeInfo().DeclaredFields.Where(s => s.IsStatic);
|
||||
Array values = Enum.GetValues(type);
|
||||
|
||||
foreach (FieldInfo member in members)
|
||||
foreach (Enum value in values)
|
||||
{
|
||||
yield return new[] { member.GetValue(null) };
|
||||
yield return new object[] { value };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Search;
|
||||
using TMDbLib.Utilities.Converters;
|
||||
using TMDbLibTests.Helpers;
|
||||
using TMDbLibTests.JsonHelpers;
|
||||
using Xunit;
|
||||
|
||||
@ -13,7 +13,7 @@ namespace TMDbLibTests.UtilityTests
|
||||
public class KnownForConverterTest : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void KnownForConverter_Movie()
|
||||
public async Task KnownForConverter_Movie()
|
||||
{
|
||||
JsonSerializerSettings settings = new JsonSerializerSettings();
|
||||
settings.Converters.Add(new KnownForConverter());
|
||||
@ -22,10 +22,9 @@ namespace TMDbLibTests.UtilityTests
|
||||
original.OriginalTitle = "Hello world";
|
||||
|
||||
string json = JsonConvert.SerializeObject(original, settings);
|
||||
KnownForMovie result = JsonConvert.DeserializeObject<KnownForBase>(json, settings) as KnownForMovie;
|
||||
KnownForMovie result = (KnownForMovie)JsonConvert.DeserializeObject<KnownForBase>(json, settings);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(original.MediaType, result.MediaType);
|
||||
Assert.Equal(original.Title, result.Title);
|
||||
}
|
||||
|
||||
@ -39,10 +38,9 @@ namespace TMDbLibTests.UtilityTests
|
||||
original.OriginalName = "Hello world";
|
||||
|
||||
string json = JsonConvert.SerializeObject(original, settings);
|
||||
KnownForTv result = JsonConvert.DeserializeObject<KnownForBase>(json, settings) as KnownForTv;
|
||||
KnownForTv result = (KnownForTv)JsonConvert.DeserializeObject<KnownForBase>(json, settings);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(original.MediaType, result.MediaType);
|
||||
Assert.Equal(original.OriginalName, result.OriginalName);
|
||||
}
|
||||
|
||||
@ -50,15 +48,11 @@ namespace TMDbLibTests.UtilityTests
|
||||
/// Tests the KnownForConverter
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestJsonKnownForConverter()
|
||||
public async Task TestJsonKnownForConverter()
|
||||
{
|
||||
// Ignore missing fields
|
||||
IgnoreMissingJson("results[array] / media_type");
|
||||
SearchContainer<SearchPerson> result = await TMDbClient.SearchPersonAsync("Willis");
|
||||
|
||||
SearchContainer<SearchPerson> result = Config.Client.SearchPersonAsync("Willis").Sync();
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.Results);
|
||||
Assert.NotNull(result?.Results);
|
||||
|
||||
List<KnownForBase> knownForList = result.Results.SelectMany(s => s.KnownFor).ToList();
|
||||
Assert.True(knownForList.Any());
|
||||
|
@ -1,3 +1,4 @@
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Search;
|
||||
@ -20,10 +21,9 @@ namespace TMDbLibTests.UtilityTests
|
||||
original.OriginalTitle = "Hello world";
|
||||
|
||||
string json = JsonConvert.SerializeObject(original, settings);
|
||||
SearchMovie result = JsonConvert.DeserializeObject<SearchBase>(json, settings) as SearchMovie;
|
||||
SearchMovie result = (SearchMovie)JsonConvert.DeserializeObject<SearchBase>(json, settings);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(original.MediaType, result.MediaType);
|
||||
Assert.Equal(original.OriginalTitle, result.OriginalTitle);
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ namespace TMDbLibTests.UtilityTests
|
||||
original.OriginalName = "Hello world";
|
||||
|
||||
string json = JsonConvert.SerializeObject(original, settings);
|
||||
SearchTv result = JsonConvert.DeserializeObject<SearchBase>(json, settings) as SearchTv;
|
||||
SearchTv result = (SearchTv)JsonConvert.DeserializeObject<SearchBase>(json, settings);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(original.MediaType, result.MediaType);
|
||||
@ -54,7 +54,7 @@ namespace TMDbLibTests.UtilityTests
|
||||
original.Name = "Hello world";
|
||||
|
||||
string json = JsonConvert.SerializeObject(original, settings);
|
||||
SearchPerson result = JsonConvert.DeserializeObject<SearchBase>(json, settings) as SearchPerson;
|
||||
SearchPerson result = (SearchPerson)JsonConvert.DeserializeObject<SearchBase>(json, settings);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(original.MediaType, result.MediaType);
|
||||
@ -65,10 +65,10 @@ namespace TMDbLibTests.UtilityTests
|
||||
/// Tests the SearchBaseConverter
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestSearchBaseConverter()
|
||||
public async Task TestSearchBaseConverter()
|
||||
{
|
||||
TestHelpers.SearchPages(i => Config.Client.SearchMultiAsync("Jobs", i).Sync());
|
||||
SearchContainer<SearchBase> result = Config.Client.SearchMultiAsync("Jobs").Sync();
|
||||
await TestHelpers.SearchPagesAsync(i => TMDbClient.SearchMultiAsync("Jobs", i));
|
||||
SearchContainer<SearchBase> result = await TMDbClient.SearchMultiAsync("Jobs");
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.Results);
|
||||
|
@ -1,3 +1,4 @@
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.People;
|
||||
@ -19,9 +20,11 @@ namespace TMDbLibTests.UtilityTests
|
||||
|
||||
SearchMovie originalMedia = new SearchMovie { OriginalTitle = "Hello world" };
|
||||
|
||||
TaggedImage original = new TaggedImage();
|
||||
original.MediaType = MediaType.Movie;
|
||||
original.Media = originalMedia;
|
||||
TaggedImage original = new TaggedImage
|
||||
{
|
||||
MediaType = originalMedia.MediaType,
|
||||
Media = originalMedia
|
||||
};
|
||||
|
||||
string json = JsonConvert.SerializeObject(original, settings);
|
||||
TaggedImage result = JsonConvert.DeserializeObject<TaggedImage>(json, settings);
|
||||
@ -65,21 +68,25 @@ namespace TMDbLibTests.UtilityTests
|
||||
/// Tests the TaggedImageConverter
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void TestJsonTaggedImageConverter()
|
||||
public async Task TestJsonTaggedImageConverter()
|
||||
{
|
||||
// Ignore fields not set
|
||||
IgnoreMissingCSharp("_id / _id", "adult / adult", "backdrop_path / backdrop_path", "first_air_date / first_air_date", "genre_ids / genre_ids", "name / name", "origin_country / origin_country", "original_language / original_language", "original_name / original_name", "original_title / original_title", "overview / overview", "poster_path / poster_path", "release_date / release_date", "title / title", "video / video", "vote_average / vote_average", "vote_count / vote_count");
|
||||
IgnoreMissingJson(" / media_type");
|
||||
|
||||
// Get images
|
||||
SearchContainerWithId<TaggedImage> result = Config.Client.GetPersonTaggedImagesAsync(IdHelper.HughLaurie, 1).Sync();
|
||||
SearchContainerWithId<TaggedImage> result = await TMDbClient.GetPersonTaggedImagesAsync(IdHelper.HughLaurie, 1);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.NotNull(result.Results);
|
||||
Assert.Equal(IdHelper.HughLaurie, result.Id);
|
||||
|
||||
Assert.Contains(result.Results, item => item.MediaType == MediaType.Tv && item.Media is SearchTv);
|
||||
Assert.Contains(result.Results, item => item.MediaType == MediaType.Movie && item.Media is SearchMovie);
|
||||
Assert.All(result.Results, item =>
|
||||
{
|
||||
if (item.MediaType == MediaType.Tv)
|
||||
Assert.IsType<SearchTv>(item.Media);
|
||||
});
|
||||
Assert.All(result.Results, item =>
|
||||
{
|
||||
if (item.MediaType == MediaType.Movie)
|
||||
Assert.IsType<SearchMovie>(item.Media);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -11,16 +11,16 @@ namespace TMDbLibTests.UtilityTests
|
||||
[Fact]
|
||||
public void EnumDescriptionNonEnumTest()
|
||||
{
|
||||
EnumTestStruct strct = new EnumTestStruct();
|
||||
EnumTestStruct @struct = new EnumTestStruct();
|
||||
|
||||
Assert.Throws<ArgumentException>(() => strct.GetDescription());
|
||||
Assert.Throws<ArgumentException>(() => @struct.GetDescription());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnumDescriptionNonDescriptionTest()
|
||||
{
|
||||
EnumTestEnum enm = EnumTestEnum.A;
|
||||
string s = enm.GetDescription();
|
||||
EnumTestEnum @enum = EnumTestEnum.A;
|
||||
string s = @enum.GetDescription();
|
||||
|
||||
Assert.Equal("A", s);
|
||||
}
|
||||
@ -28,8 +28,8 @@ namespace TMDbLibTests.UtilityTests
|
||||
[Fact]
|
||||
public void EnumDescriptionTest()
|
||||
{
|
||||
EnumTestEnum enm = EnumTestEnum.B;
|
||||
string s = enm.GetDescription();
|
||||
EnumTestEnum @enum = EnumTestEnum.B;
|
||||
string s = @enum.GetDescription();
|
||||
|
||||
Assert.Equal("B-Description", s);
|
||||
}
|
||||
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
favorite: true,
|
||||
id: 19995
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
episodeA: {
|
||||
episode_number: 1,
|
||||
id: 64766,
|
||||
rating: 5.0
|
||||
},
|
||||
episodeB: {
|
||||
episode_number: 2,
|
||||
id: 64777
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
value: Hello world,
|
||||
action: added,
|
||||
iso_639_1: en
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
action: created,
|
||||
iso_639_1: en
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
original_value: Hello world,
|
||||
action: deleted,
|
||||
iso_639_1: en
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
{
|
||||
original_value: Hello world,
|
||||
value: Hello world 1234,
|
||||
action: updated,
|
||||
iso_639_1: en
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
list_type: movie,
|
||||
description: This is a test list,
|
||||
id: 1724,
|
||||
iso_639_1: en,
|
||||
item_count: 1,
|
||||
name: Test list
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
avatar: {
|
||||
gravatar: {
|
||||
hash: Guid_1
|
||||
}
|
||||
},
|
||||
id: 6089455,
|
||||
iso_3166_1: BE,
|
||||
iso_639_1: en,
|
||||
name: Test Name,
|
||||
username: TMDbTestAccount
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
{
|
||||
original_title: Avatar,
|
||||
release_date: DateTime_1,
|
||||
title: Avatar,
|
||||
backdrop_path: <non-empty>,
|
||||
genre_ids: [
|
||||
12,
|
||||
14,
|
||||
28,
|
||||
878
|
||||
],
|
||||
original_language: en,
|
||||
overview: In the 22nd century, a paraplegic Marine is dispatched to the moon Pandora on a unique mission, but becomes torn between following orders and protecting an alien civilization.,
|
||||
poster_path: <non-empty>,
|
||||
id: 19995,
|
||||
media_type: movie,
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user