mirror of
https://github.com/jellyfin/TMDbLib.git
synced 2024-11-26 23:30:23 +00:00
parent
88d3fd2c63
commit
62b3e26ad7
@ -163,7 +163,7 @@ namespace TMDbLib.Client
|
||||
{
|
||||
try
|
||||
{
|
||||
ActiveAccount = AccountGetDetails();
|
||||
ActiveAccount = AccountGetDetails().Result;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using TMDbLib.Objects.Account;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
@ -17,14 +18,14 @@ namespace TMDbLib.Client
|
||||
/// </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 AccountDetails AccountGetDetails()
|
||||
public async Task<AccountDetails> AccountGetDetails()
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
RestRequest request = new RestRequest("account");
|
||||
request.AddParameter("session_id", SessionId);
|
||||
|
||||
IRestResponse<AccountDetails> response = _client.Get<AccountDetails>(request);
|
||||
IRestResponse<AccountDetails> response = await _client.ExecuteGetTaskAsync<AccountDetails>(request);
|
||||
|
||||
return response.Data;
|
||||
}
|
||||
@ -35,7 +36,7 @@ namespace TMDbLib.Client
|
||||
/// </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 SearchContainer<List> AccountGetLists(int page = 1, string language = null)
|
||||
public async Task<SearchContainer<List>> AccountGetLists(int page = 1, string language = null)
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
@ -49,7 +50,7 @@ namespace TMDbLib.Client
|
||||
if (!string.IsNullOrWhiteSpace(language))
|
||||
request.AddParameter("language", language);
|
||||
|
||||
IRestResponse<SearchContainer<List>> response = _client.Get<SearchContainer<List>>(request);
|
||||
IRestResponse<SearchContainer<List>> response = await _client.ExecuteGetTaskAsync<SearchContainer<List>>(request);
|
||||
|
||||
return response.Data;
|
||||
}
|
||||
@ -62,7 +63,7 @@ namespace TMDbLib.Client
|
||||
/// <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 bool AccountChangeMovieFavoriteStatus(int movieId, bool isFavorite)
|
||||
public async Task<bool> AccountChangeMovieFavoriteStatus(int movieId, bool isFavorite)
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
@ -71,7 +72,7 @@ namespace TMDbLib.Client
|
||||
request.AddParameter("session_id", SessionId, ParameterType.QueryString);
|
||||
request.AddBody(new { movie_id = movieId, favorite = isFavorite });
|
||||
|
||||
IRestResponse<PostReply> response = _client.Post<PostReply>(request);
|
||||
IRestResponse<PostReply> response = await _client.ExecutePostTaskAsync<PostReply>(request);
|
||||
|
||||
// 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
|
||||
@ -87,7 +88,7 @@ namespace TMDbLib.Client
|
||||
/// <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 bool AccountChangeMovieWatchlistStatus(int movieId, bool isOnWatchlist)
|
||||
public async Task<bool> AccountChangeMovieWatchlistStatus(int movieId, bool isOnWatchlist)
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
@ -96,7 +97,7 @@ namespace TMDbLib.Client
|
||||
request.AddParameter("session_id", SessionId, ParameterType.QueryString);
|
||||
request.AddBody(new { movie_id = movieId, movie_watchlist = isOnWatchlist });
|
||||
|
||||
IRestResponse<PostReply> response = _client.Post<PostReply>(request);
|
||||
IRestResponse<PostReply> response = await _client.ExecutePostTaskAsync<PostReply>(request);
|
||||
|
||||
// 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
|
||||
@ -109,13 +110,13 @@ namespace TMDbLib.Client
|
||||
/// </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 SearchContainer<SearchMovie> AccountGetFavoriteMovies(
|
||||
public async Task<SearchContainer<SearchMovie>> AccountGetFavoriteMovies(
|
||||
int page = 1,
|
||||
AccountMovieSortBy sortBy = AccountMovieSortBy.Undefined,
|
||||
SortOrder sortOrder = SortOrder.Undefined,
|
||||
string language = null)
|
||||
{
|
||||
return GetAccountList(page, sortBy, sortOrder, language, AccountListsMethods.FavoriteMovies);
|
||||
return await GetAccountList(page, sortBy, sortOrder, language, AccountListsMethods.FavoriteMovies);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -123,13 +124,13 @@ namespace TMDbLib.Client
|
||||
/// </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 SearchContainer<SearchMovie> AccountGetMovieWatchlist(
|
||||
public async Task<SearchContainer<SearchMovie>> AccountGetMovieWatchlist(
|
||||
int page = 1,
|
||||
AccountMovieSortBy sortBy = AccountMovieSortBy.Undefined,
|
||||
SortOrder sortOrder = SortOrder.Undefined,
|
||||
string language = null)
|
||||
{
|
||||
return GetAccountList(page, sortBy, sortOrder, language, AccountListsMethods.MovieWatchlist);
|
||||
return await GetAccountList(page, sortBy, sortOrder, language, AccountListsMethods.MovieWatchlist);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -137,16 +138,16 @@ namespace TMDbLib.Client
|
||||
/// </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 SearchContainer<SearchMovie> AccountGetRatedMovies(
|
||||
public async Task<SearchContainer<SearchMovie>> AccountGetRatedMovies(
|
||||
int page = 1,
|
||||
AccountMovieSortBy sortBy = AccountMovieSortBy.Undefined,
|
||||
SortOrder sortOrder = SortOrder.Undefined,
|
||||
string language = null)
|
||||
{
|
||||
return GetAccountList(page, sortBy, sortOrder, language, AccountListsMethods.RatedMovies);
|
||||
return await GetAccountList(page, sortBy, sortOrder, language, AccountListsMethods.RatedMovies);
|
||||
}
|
||||
|
||||
private SearchContainer<SearchMovie> GetAccountList(int page, AccountMovieSortBy sortBy, SortOrder sortOrder, string language, AccountListsMethods method)
|
||||
private async Task<SearchContainer<SearchMovie>> GetAccountList(int page, AccountMovieSortBy sortBy, SortOrder sortOrder, string language, AccountListsMethods method)
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
@ -167,7 +168,7 @@ namespace TMDbLib.Client
|
||||
if (!string.IsNullOrWhiteSpace(language))
|
||||
request.AddParameter("language", language);
|
||||
|
||||
IRestResponse<SearchContainer<SearchMovie>> response = _client.Get<SearchContainer<SearchMovie>>(request);
|
||||
IRestResponse<SearchContainer<SearchMovie>> response = await _client.ExecuteGetTaskAsync<SearchContainer<SearchMovie>>(request);
|
||||
|
||||
return response.Data;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
|
||||
@ -7,14 +8,14 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public Token AuthenticationRequestAutenticationToken()
|
||||
public async Task<Token> AuthenticationRequestAutenticationToken()
|
||||
{
|
||||
RestRequest request = new RestRequest("authentication/token/new")
|
||||
{
|
||||
DateFormat = "yyyy-MM-dd HH:mm:ss UTC"
|
||||
};
|
||||
|
||||
IRestResponse<Token> response = _client.Get<Token>(request);
|
||||
IRestResponse<Token> response = await _client.ExecuteGetTaskAsync<Token>(request);
|
||||
Token token = response.Data;
|
||||
|
||||
token.AuthenticationCallback = response.Headers.First(h => h.Name.Equals("Authentication-Callback")).Value.ToString();
|
||||
@ -22,27 +23,27 @@ namespace TMDbLib.Client
|
||||
return token;
|
||||
}
|
||||
|
||||
public void AuthenticationValidateUserToken(string initialRequestToken, string username, string password)
|
||||
public async void AuthenticationValidateUserToken(string initialRequestToken, string username, string password)
|
||||
{
|
||||
RestRequest request = new RestRequest("authentication/token/validate_with_login");
|
||||
request.AddParameter("request_token", initialRequestToken);
|
||||
request.AddParameter("username", username);
|
||||
request.AddParameter("password", password);
|
||||
RestRequest request = new RestRequest("authentication/token/validate_with_login");
|
||||
request.AddParameter("request_token", initialRequestToken);
|
||||
request.AddParameter("username", username);
|
||||
request.AddParameter("password", password);
|
||||
|
||||
IRestResponse response = _client.Get(request);
|
||||
IRestResponse response = await _client.ExecuteGetTaskAsync(request);
|
||||
|
||||
if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
||||
{
|
||||
throw new UnauthorizedAccessException("Call to TMDb returned unauthorized. Most likely the provided user credentials are invalid.");
|
||||
}
|
||||
if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
||||
{
|
||||
throw new UnauthorizedAccessException("Call to TMDb returned unauthorized. Most likely the provided user credentials are invalid.");
|
||||
}
|
||||
}
|
||||
|
||||
public UserSession AuthenticationGetUserSession(string initialRequestToken)
|
||||
public async Task<UserSession> AuthenticationGetUserSession(string initialRequestToken)
|
||||
{
|
||||
RestRequest request = new RestRequest("authentication/session/new");
|
||||
request.AddParameter("request_token", initialRequestToken);
|
||||
|
||||
IRestResponse<UserSession> response = _client.Get<UserSession>(request);
|
||||
IRestResponse<UserSession> response = await _client.ExecuteGetTaskAsync<UserSession>(request);
|
||||
|
||||
return response.Data;
|
||||
}
|
||||
@ -52,21 +53,21 @@ namespace TMDbLib.Client
|
||||
/// </summary>
|
||||
/// <param name="username">A valid TMDb username</param>
|
||||
/// <param name="password">The passoword for the provided login</param>
|
||||
public UserSession AuthenticationGetUserSession(string username, string password)
|
||||
public async Task<UserSession> AuthenticationGetUserSession(string username, string password)
|
||||
{
|
||||
Token token = AuthenticationRequestAutenticationToken();
|
||||
AuthenticationValidateUserToken(token.RequestToken, username, password);
|
||||
return AuthenticationGetUserSession(token.RequestToken);
|
||||
Token token = await AuthenticationRequestAutenticationToken();
|
||||
AuthenticationValidateUserToken(token.RequestToken, username, password);
|
||||
return await AuthenticationGetUserSession(token.RequestToken);
|
||||
}
|
||||
|
||||
public GuestSession AuthenticationCreateGuestSession()
|
||||
public async Task<GuestSession> AuthenticationCreateGuestSession()
|
||||
{
|
||||
RestRequest request = new RestRequest("authentication/guest_session/new")
|
||||
{
|
||||
DateFormat = "yyyy-MM-dd HH:mm:ss UTC"
|
||||
};
|
||||
|
||||
IRestResponse<GuestSession> response = _client.Get<GuestSession>(request);
|
||||
IRestResponse<GuestSession> response = await _client.ExecuteGetTaskAsync<GuestSession>(request);
|
||||
|
||||
return response.Data;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using TMDbLib.Objects.Changes;
|
||||
using TMDbLib.Objects.General;
|
||||
@ -7,7 +8,7 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
private T GetChanges<T>(string type, int page = 0, DateTime? startDate = null, DateTime? endDate = null) where T : new()
|
||||
private async Task<T> GetChanges<T>(string type, int page = 0, DateTime? startDate = null, DateTime? endDate = null) where T : new()
|
||||
{
|
||||
RestRequest req = new RestRequest("{type}/changes");
|
||||
req.AddUrlSegment("type", type);
|
||||
@ -19,7 +20,7 @@ namespace TMDbLib.Client
|
||||
if (endDate != null)
|
||||
req.AddParameter("end_date", endDate.Value.ToString("yyyy-MM-dd"));
|
||||
|
||||
IRestResponse<T> resp = _client.Get<T>(req);
|
||||
IRestResponse<T> resp = await _client.ExecuteGetTaskAsync<T>(req);
|
||||
|
||||
return resp.Data;
|
||||
}
|
||||
@ -31,9 +32,9 @@ namespace TMDbLib.Client
|
||||
/// You can then use the movie changes API to get the actual data that has been changed. (.GetMovieChanges)
|
||||
/// </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 SearchContainer<ChangesListItem> GetChangesMovies(int page = 0, DateTime? startDate = null, DateTime? endDate = null)
|
||||
public async Task<SearchContainer<ChangesListItem>> GetChangesMovies(int page = 0, DateTime? startDate = null, DateTime? endDate = null)
|
||||
{
|
||||
return GetChanges<SearchContainer<ChangesListItem>>("movie", page, startDate, endDate);
|
||||
return await GetChanges<SearchContainer<ChangesListItem>>("movie", page, startDate, endDate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -43,9 +44,9 @@ namespace TMDbLib.Client
|
||||
/// You can then use the person changes API to get the actual data that has been changed.(.GetPersonChanges)
|
||||
/// </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 SearchContainer<ChangesListItem> GetChangesPeople(int page = 0, DateTime? startDate = null, DateTime? endDate = null)
|
||||
public async Task<SearchContainer<ChangesListItem>> GetChangesPeople(int page = 0, DateTime? startDate = null, DateTime? endDate = null)
|
||||
{
|
||||
return GetChanges<SearchContainer<ChangesListItem>>("person", page, startDate, endDate);
|
||||
return await GetChanges<SearchContainer<ChangesListItem>>("person", page, startDate, endDate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -58,9 +59,9 @@ 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 SearchContainer<ChangesListItem> GetChangesTv(int page = 0, DateTime? startDate = null, DateTime? endDate = null)
|
||||
public async Task<SearchContainer<ChangesListItem>> GetChangesTv(int page = 0, DateTime? startDate = null, DateTime? endDate = null)
|
||||
{
|
||||
return GetChanges<SearchContainer<ChangesListItem>>("tv", page, startDate, endDate);
|
||||
return await GetChanges<SearchContainer<ChangesListItem>>("tv", page, startDate, endDate);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using TMDbLib.Objects.Collections;
|
||||
using TMDbLib.Objects.General;
|
||||
@ -9,12 +10,12 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public Collection GetCollection(int collectionId, CollectionMethods extraMethods = CollectionMethods.Undefined)
|
||||
public async Task<Collection> GetCollection(int collectionId, CollectionMethods extraMethods = CollectionMethods.Undefined)
|
||||
{
|
||||
return GetCollection(collectionId, null, extraMethods);
|
||||
return await GetCollection(collectionId, null, extraMethods);
|
||||
}
|
||||
|
||||
public Collection GetCollection(int collectionId, string language, CollectionMethods extraMethods = CollectionMethods.Undefined)
|
||||
public async Task<Collection> GetCollection(int collectionId, string language, CollectionMethods extraMethods = CollectionMethods.Undefined)
|
||||
{
|
||||
RestRequest req = new RestRequest("collection/{collectionId}");
|
||||
req.AddUrlSegment("collectionId", collectionId.ToString());
|
||||
@ -34,12 +35,12 @@ namespace TMDbLib.Client
|
||||
|
||||
req.DateFormat = "yyyy-MM-dd";
|
||||
|
||||
IRestResponse<Collection> resp = _client.Get<Collection>(req);
|
||||
IRestResponse<Collection> resp = await _client.ExecuteGetTaskAsync<Collection>(req);
|
||||
|
||||
return resp.Data;
|
||||
}
|
||||
|
||||
private T GetCollectionMethod<T>(int collectionId, CollectionMethods collectionMethod, string language = null) where T : new()
|
||||
private async Task<T> GetCollectionMethod<T>(int collectionId, CollectionMethods collectionMethod, string language = null) where T : new()
|
||||
{
|
||||
RestRequest req = new RestRequest("collection/{collectionId}/{method}");
|
||||
req.AddUrlSegment("collectionId", collectionId.ToString());
|
||||
@ -48,14 +49,14 @@ namespace TMDbLib.Client
|
||||
if (language != null)
|
||||
req.AddParameter("language", language);
|
||||
|
||||
IRestResponse<T> resp = _client.Get<T>(req);
|
||||
IRestResponse<T> resp = await _client.ExecuteGetTaskAsync<T>(req);
|
||||
|
||||
return resp.Data;
|
||||
}
|
||||
|
||||
public ImagesWithId GetCollectionImages(int collectionId, string language = null)
|
||||
public async Task<ImagesWithId> GetCollectionImages(int collectionId, string language = null)
|
||||
{
|
||||
return GetCollectionMethod<ImagesWithId>(collectionId, CollectionMethods.Images, language);
|
||||
return await GetCollectionMethod<ImagesWithId>(collectionId, CollectionMethods.Images, language);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using TMDbLib.Objects.Companies;
|
||||
using TMDbLib.Objects.General;
|
||||
@ -9,7 +10,7 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public Company GetCompany(int companyId, CompanyMethods extraMethods = CompanyMethods.Undefined)
|
||||
public async Task<Company> GetCompany(int companyId, CompanyMethods extraMethods = CompanyMethods.Undefined)
|
||||
{
|
||||
RestRequest req = new RestRequest("company/{companyId}");
|
||||
req.AddUrlSegment("companyId", companyId.ToString());
|
||||
@ -26,12 +27,12 @@ namespace TMDbLib.Client
|
||||
|
||||
req.DateFormat = "yyyy-MM-dd";
|
||||
|
||||
IRestResponse<Company> resp = _client.Get<Company>(req);
|
||||
IRestResponse<Company> resp = await _client.ExecuteGetTaskAsync<Company>(req);
|
||||
|
||||
return resp.Data;
|
||||
}
|
||||
|
||||
private T GetCompanyMethod<T>(int companyId, CompanyMethods companyMethod, int page = 0, string language = null) where T : new()
|
||||
private async Task<T> GetCompanyMethod<T>(int companyId, CompanyMethods companyMethod, int page = 0, string language = null) where T : new()
|
||||
{
|
||||
RestRequest req = new RestRequest("company/{companyId}/{method}");
|
||||
req.AddUrlSegment("companyId", companyId.ToString());
|
||||
@ -42,19 +43,19 @@ namespace TMDbLib.Client
|
||||
if (language != null)
|
||||
req.AddParameter("language", language);
|
||||
|
||||
IRestResponse<T> resp = _client.Get<T>(req);
|
||||
IRestResponse<T> resp = await _client.ExecuteGetTaskAsync<T>(req);
|
||||
|
||||
return resp.Data;
|
||||
}
|
||||
|
||||
public SearchContainerWithId<MovieResult> GetCompanyMovies(int companyId, int page = 0)
|
||||
public async Task<SearchContainerWithId<MovieResult>> GetCompanyMovies(int companyId, int page = 0)
|
||||
{
|
||||
return GetCompanyMovies(companyId, DefaultLanguage, page);
|
||||
return await GetCompanyMovies(companyId, DefaultLanguage, page);
|
||||
}
|
||||
|
||||
public SearchContainerWithId<MovieResult> GetCompanyMovies(int companyId, string language, int page = 0)
|
||||
public async Task<SearchContainerWithId<MovieResult>> GetCompanyMovies(int companyId, string language, int page = 0)
|
||||
{
|
||||
return GetCompanyMethod<SearchContainerWithId<MovieResult>>(companyId, CompanyMethods.Movies, page, language);
|
||||
return await GetCompanyMethod<SearchContainerWithId<MovieResult>>(companyId, CompanyMethods.Movies, page, language);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using TMDbLib.Objects.Discover;
|
||||
using TMDbLib.Objects.General;
|
||||
@ -24,7 +25,7 @@ namespace TMDbLib.Client
|
||||
/// <param name="firstAirDateGreaterThan">The minimum airdate of tv shows to include.</param>
|
||||
/// <param name="firstAirDateLessThan">The maximum airdate of tv shows to include.</param>
|
||||
/// <returns>Will return a list of tv shows that corespond to the provided parameters</returns>
|
||||
public SearchContainer<TvShowBase> DiscoverTvShows(
|
||||
public async Task<SearchContainer<TvShowBase>> DiscoverTvShows(
|
||||
int page = 1,
|
||||
string language = null,
|
||||
DiscoverTvShowSortBy sortBy = DiscoverTvShowSortBy.Undefined,
|
||||
@ -68,7 +69,7 @@ namespace TMDbLib.Client
|
||||
if (firstAirDateLessThan.HasValue)
|
||||
request.AddParameter("first_air_date.lte", firstAirDateLessThan.Value.ToString("yyyy-MM-dd"));
|
||||
|
||||
IRestResponse<SearchContainer<TvShowBase>> response = _client.Get<SearchContainer<TvShowBase>>(request);
|
||||
IRestResponse<SearchContainer<TvShowBase>> response = await _client.ExecuteGetTaskAsync<SearchContainer<TvShowBase>>(request);
|
||||
|
||||
return response.Data;
|
||||
}
|
||||
@ -91,7 +92,7 @@ namespace TMDbLib.Client
|
||||
/// <param name="releaseDateLessThan">The maximum release date of movies to include.</param>
|
||||
/// <param name="withCompanies">Filter movies based on the company that created them. Expected value is an integer (the id of a company). Multiple values can be specified. Comma separated indicates an 'AND' query, while a pipe (|) separated value indicates an 'OR'.</param>
|
||||
/// <returns>Will return a list of movies that corespond to the provided parameters</returns>
|
||||
public SearchContainer<SearchMovie> DiscoverMovies(
|
||||
public async Task<SearchContainer<SearchMovie>> DiscoverMovies(
|
||||
int? page = null,
|
||||
string language = null,
|
||||
DiscoverMovieSortBy sortBy = DiscoverMovieSortBy.Undefined,
|
||||
@ -159,7 +160,7 @@ namespace TMDbLib.Client
|
||||
if (!String.IsNullOrWhiteSpace(withCompanies))
|
||||
request.AddParameter("with_companies", withCompanies);
|
||||
|
||||
IRestResponse<SearchContainer<SearchMovie>> response = _client.Get<SearchContainer<SearchMovie>>(request);
|
||||
IRestResponse<SearchContainer<SearchMovie>> response = await _client.ExecuteGetTaskAsync<SearchContainer<SearchMovie>>(request);
|
||||
|
||||
return response.Data;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using RestSharp;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using RestSharp.Contrib;
|
||||
using TMDbLib.Objects.Find;
|
||||
using TMDbLib.Utilities;
|
||||
@ -17,7 +18,7 @@ namespace TMDbLib.Client
|
||||
/// <param name="source">The source the specified id belongs to</param>
|
||||
/// <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>
|
||||
public FindContainer Find(FindExternalSource source, string id)
|
||||
public async Task<FindContainer> Find(FindExternalSource source, string id)
|
||||
{
|
||||
RestRequest req = new RestRequest("find/{id}");
|
||||
|
||||
@ -29,7 +30,7 @@ namespace TMDbLib.Client
|
||||
|
||||
req.AddParameter("external_source", source.GetDescription());
|
||||
|
||||
IRestResponse<FindContainer> resp = _client.Get<FindContainer>(req);
|
||||
IRestResponse<FindContainer> resp = await _client.ExecuteGetTaskAsync<FindContainer>(req);
|
||||
|
||||
return resp.Data;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Genres;
|
||||
@ -7,19 +8,19 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public List<Genre> GetGenres()
|
||||
public async Task<List<Genre>> GetGenres()
|
||||
{
|
||||
return GetGenres(DefaultLanguage);
|
||||
return await GetGenres(DefaultLanguage);
|
||||
}
|
||||
|
||||
public List<Genre> GetGenres(string language)
|
||||
public async Task<List<Genre>> GetGenres(string language)
|
||||
{
|
||||
RestRequest req = new RestRequest("genre/list");
|
||||
|
||||
if (language != null)
|
||||
req.AddParameter("language", language);
|
||||
|
||||
IRestResponse<GenreContainer> resp = _client.Get<GenreContainer>(req);
|
||||
IRestResponse<GenreContainer> resp =await _client.ExecuteGetTaskAsync<GenreContainer>(req);
|
||||
|
||||
if (resp.Data == null)
|
||||
return null;
|
||||
@ -27,12 +28,12 @@ namespace TMDbLib.Client
|
||||
return resp.Data.Genres;
|
||||
}
|
||||
|
||||
public SearchContainerWithId<MovieResult> GetGenreMovies(int genreId, int page = 0, bool? includeAllMovies = null)
|
||||
public async Task<SearchContainerWithId<MovieResult>> GetGenreMovies(int genreId, int page = 0, bool? includeAllMovies = null)
|
||||
{
|
||||
return GetGenreMovies(genreId, DefaultLanguage, page, includeAllMovies);
|
||||
return await GetGenreMovies(genreId, DefaultLanguage, page, includeAllMovies);
|
||||
}
|
||||
|
||||
public SearchContainerWithId<MovieResult> GetGenreMovies(int genreId, string language, int page = 0, bool? includeAllMovies = null)
|
||||
public async Task<SearchContainerWithId<MovieResult>> GetGenreMovies(int genreId, string language, int page = 0, bool? includeAllMovies = null)
|
||||
{
|
||||
RestRequest req = new RestRequest("genre/{genreId}/movies");
|
||||
req.AddUrlSegment("genreId", genreId.ToString());
|
||||
@ -45,7 +46,7 @@ namespace TMDbLib.Client
|
||||
if (includeAllMovies.HasValue)
|
||||
req.AddParameter("include_all_movies", includeAllMovies.Value ? "true" : "false");
|
||||
|
||||
IRestResponse<SearchContainerWithId<MovieResult>> resp = _client.Get<SearchContainerWithId<MovieResult>>(req);
|
||||
IRestResponse<SearchContainerWithId<MovieResult>> resp = await _client.ExecuteGetTaskAsync<SearchContainerWithId<MovieResult>>(req);
|
||||
|
||||
return resp.Data;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Jobs;
|
||||
@ -11,11 +12,11 @@ namespace TMDbLib.Client
|
||||
/// Retrieves a list of departments and positions within
|
||||
/// </summary>
|
||||
/// <returns>Valid jobs and their departments</returns>
|
||||
public List<Job> GetJobs()
|
||||
public async Task<List<Job>> GetJobs()
|
||||
{
|
||||
RestRequest req = new RestRequest("job/list");
|
||||
|
||||
IRestResponse<JobContainer> response = _client.Get<JobContainer>(req);
|
||||
IRestResponse<JobContainer> response = await _client.ExecuteGetTaskAsync<JobContainer>(req);
|
||||
|
||||
if (response == null || response.Data == null)
|
||||
{
|
||||
|
@ -1,26 +1,27 @@
|
||||
using RestSharp;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using TMDbLib.Objects.General;
|
||||
|
||||
namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public Keyword GetKeyword(int keywordId)
|
||||
public async Task<Keyword> GetKeyword(int keywordId)
|
||||
{
|
||||
RestRequest req = new RestRequest("keyword/{keywordId}");
|
||||
req.AddUrlSegment("keywordId", keywordId.ToString());
|
||||
|
||||
IRestResponse<Keyword> resp = _client.Get<Keyword>(req);
|
||||
IRestResponse<Keyword> resp = await _client.ExecuteGetTaskAsync<Keyword>(req);
|
||||
|
||||
return resp.Data;
|
||||
}
|
||||
|
||||
public SearchContainer<MovieResult> GetKeywordMovies(int keywordId, int page = 0)
|
||||
public async Task<SearchContainer<MovieResult>> GetKeywordMovies(int keywordId, int page = 0)
|
||||
{
|
||||
return GetKeywordMovies(keywordId, DefaultLanguage, page);
|
||||
return await GetKeywordMovies(keywordId, DefaultLanguage, page);
|
||||
}
|
||||
|
||||
public SearchContainer<MovieResult> GetKeywordMovies(int keywordId, string language, int page = 0)
|
||||
public async Task<SearchContainer<MovieResult>> GetKeywordMovies(int keywordId, string language, int page = 0)
|
||||
{
|
||||
RestRequest req = new RestRequest("keyword/{keywordId}/movies");
|
||||
req.AddUrlSegment("keywordId", keywordId.ToString());
|
||||
@ -31,7 +32,7 @@ namespace TMDbLib.Client
|
||||
if (page >= 1)
|
||||
req.AddParameter("page", page);
|
||||
|
||||
IRestResponse<SearchContainer<MovieResult>> resp = _client.Get<SearchContainer<MovieResult>>(req);
|
||||
IRestResponse<SearchContainer<MovieResult>> resp = await _client.ExecuteGetTaskAsync<SearchContainer<MovieResult>>(req);
|
||||
|
||||
return resp.Data;
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Lists;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
using TMDbLib.Utilities;
|
||||
|
||||
namespace TMDbLib.Client
|
||||
{
|
||||
@ -12,7 +14,7 @@ namespace TMDbLib.Client
|
||||
/// Retrieve a list by it's id
|
||||
/// </summary>
|
||||
/// <param name="listId">The id of the list you want to retrieve</param>
|
||||
public List GetList(string listId)
|
||||
public async Task<List> GetList(string listId)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(listId))
|
||||
throw new ArgumentNullException("listId");
|
||||
@ -22,7 +24,7 @@ namespace TMDbLib.Client
|
||||
|
||||
request.DateFormat = "yyyy-MM-dd";
|
||||
|
||||
IRestResponse<List> response = _client.Get<List>(request);
|
||||
IRestResponse<List> response = await _client.ExecuteGetTaskAsync<List>(request);
|
||||
|
||||
return response.Data;
|
||||
}
|
||||
@ -32,7 +34,7 @@ namespace TMDbLib.Client
|
||||
/// </summary>
|
||||
/// <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>
|
||||
public bool GetListIsMoviePresent(string listId, int movieId)
|
||||
public async Task<bool> GetListIsMoviePresent(string listId, int movieId)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(listId))
|
||||
throw new ArgumentNullException("listId");
|
||||
@ -44,7 +46,7 @@ namespace TMDbLib.Client
|
||||
request.AddUrlSegment("listId", listId);
|
||||
request.AddParameter("movie_id", movieId);
|
||||
|
||||
IRestResponse<ListStatus> response = _client.Get<ListStatus>(request);
|
||||
IRestResponse<ListStatus> response = await _client.ExecuteGetTaskAsync<ListStatus>(request);
|
||||
|
||||
return response.Data.ItemPresent;
|
||||
}
|
||||
@ -57,7 +59,7 @@ namespace TMDbLib.Client
|
||||
/// <param name="language">Optional language that might indicate the language of the content in the list</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 string ListCreate(string name, string description = "", string language = null)
|
||||
public async Task<string> ListCreate(string name, string description = "", string language = null)
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
@ -79,7 +81,7 @@ namespace TMDbLib.Client
|
||||
request.AddBody(new { name = name, description = description, language = language });
|
||||
}
|
||||
|
||||
IRestResponse<ListCreateReply> response = _client.Post<ListCreateReply>(request);
|
||||
IRestResponse<ListCreateReply> response = await _client.ExecutePostTaskAsync<ListCreateReply>(request);
|
||||
|
||||
return response.Data == null ? null : response.Data.ListId;
|
||||
}
|
||||
@ -90,7 +92,7 @@ namespace TMDbLib.Client
|
||||
/// <param name="listId">A list id that is owned by the user associated with the current session id</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 bool ListDelete(string listId)
|
||||
public async Task<bool> ListDelete(string listId)
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
@ -101,7 +103,7 @@ namespace TMDbLib.Client
|
||||
request.AddUrlSegment("listId", listId);
|
||||
request.AddParameter("session_id", SessionId, ParameterType.QueryString);
|
||||
|
||||
IRestResponse<PostReply> response = _client.Delete<PostReply>(request);
|
||||
IRestResponse<PostReply> response = await _client.ExecuteDeleteTaskAsync<PostReply>(request);
|
||||
|
||||
// Status code 13 = success
|
||||
return response.Data != null && response.Data.StatusCode == 13;
|
||||
@ -115,9 +117,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 bool ListAddMovie(string listId, int movieId)
|
||||
public async Task<bool> ListAddMovie(string listId, int movieId)
|
||||
{
|
||||
return ManipulateMediaList(listId, movieId, "add_item");
|
||||
return await ManipulateMediaList(listId, movieId, "add_item");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -128,12 +130,12 @@ 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 bool ListRemoveMovie(string listId, int movieId)
|
||||
public async Task<bool> ListRemoveMovie(string listId, int movieId)
|
||||
{
|
||||
return ManipulateMediaList(listId, movieId, "remove_item");
|
||||
return await ManipulateMediaList(listId, movieId, "remove_item");
|
||||
}
|
||||
|
||||
private bool ManipulateMediaList(string listId, int movieId, string method)
|
||||
private async Task<bool> ManipulateMediaList(string listId, int movieId, string method)
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
@ -150,7 +152,7 @@ namespace TMDbLib.Client
|
||||
request.AddParameter("session_id", SessionId, ParameterType.QueryString);
|
||||
request.AddBody(new { media_id = movieId });
|
||||
|
||||
IRestResponse<PostReply> response = _client.Post<PostReply>(request);
|
||||
IRestResponse<PostReply> response = await _client.ExecutePostTaskAsync<PostReply>(request);
|
||||
|
||||
// Status code 8 = "Duplicate entry - The data you tried to submit already exists"
|
||||
// Status code 12 = "The item/record was updated successfully"
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using TMDbLib.Objects.Authentication;
|
||||
using TMDbLib.Objects.General;
|
||||
@ -14,19 +15,19 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public Movie GetMovie(int movieId, MovieMethods extraMethods = MovieMethods.Undefined)
|
||||
public async Task<Movie> GetMovie(int movieId, MovieMethods extraMethods = MovieMethods.Undefined)
|
||||
{
|
||||
return GetMovie(movieId, DefaultLanguage, extraMethods);
|
||||
return await GetMovie(movieId, DefaultLanguage, extraMethods);
|
||||
}
|
||||
|
||||
public Movie GetMovie(string imdbId, MovieMethods extraMethods = MovieMethods.Undefined)
|
||||
public async Task<Movie> GetMovie(string imdbId, MovieMethods extraMethods = MovieMethods.Undefined)
|
||||
{
|
||||
return GetMovie(imdbId, DefaultLanguage, extraMethods);
|
||||
return await GetMovie(imdbId, DefaultLanguage, extraMethods);
|
||||
}
|
||||
|
||||
public Movie GetMovie(int movieId, string language, MovieMethods extraMethods = MovieMethods.Undefined)
|
||||
public async Task<Movie> GetMovie(int movieId, string language, MovieMethods extraMethods = MovieMethods.Undefined)
|
||||
{
|
||||
return GetMovie(movieId.ToString(CultureInfo.InvariantCulture), language, extraMethods);
|
||||
return await GetMovie(movieId.ToString(CultureInfo.InvariantCulture), language, extraMethods);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -38,7 +39,7 @@ namespace TMDbLib.Client
|
||||
/// <returns>The requested 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 Movie GetMovie(string imdbId, string language, MovieMethods extraMethods = MovieMethods.Undefined)
|
||||
public async Task<Movie> GetMovie(string imdbId, string language, MovieMethods extraMethods = MovieMethods.Undefined)
|
||||
{
|
||||
if (extraMethods.HasFlag(MovieMethods.AccountStates))
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
@ -61,7 +62,7 @@ namespace TMDbLib.Client
|
||||
if (appends != string.Empty)
|
||||
request.AddParameter("append_to_response", appends);
|
||||
|
||||
IRestResponse<Movie> response = _client.Get<Movie>(request);
|
||||
IRestResponse<Movie> response = await _client.ExecuteGetTaskAsync<Movie>(request);
|
||||
|
||||
// No data to patch up so return
|
||||
if (response.Data == null) return null;
|
||||
@ -95,7 +96,7 @@ namespace TMDbLib.Client
|
||||
return response.Data;
|
||||
}
|
||||
|
||||
private T GetMovieMethod<T>(int movieId, MovieMethods movieMethod, string dateFormat = null,
|
||||
private async Task<T> GetMovieMethod<T>(int movieId, MovieMethods movieMethod, string dateFormat = null,
|
||||
string country = null,
|
||||
string language = null, int page = 0, DateTime? startDate = null, DateTime? endDate = null) where T : new()
|
||||
{
|
||||
@ -118,89 +119,89 @@ namespace TMDbLib.Client
|
||||
if (endDate != null)
|
||||
request.AddParameter("end_date", endDate.Value.ToString("yyyy-MM-dd"));
|
||||
|
||||
IRestResponse<T> response = _client.Get<T>(request);
|
||||
IRestResponse<T> response = await _client.ExecuteGetTaskAsync<T>(request);
|
||||
|
||||
return response.Data;
|
||||
}
|
||||
|
||||
public AlternativeTitles GetMovieAlternativeTitles(int movieId)
|
||||
public async Task<AlternativeTitles> GetMovieAlternativeTitles(int movieId)
|
||||
{
|
||||
return GetMovieAlternativeTitles(movieId, DefaultCountry);
|
||||
return await GetMovieAlternativeTitles(movieId, DefaultCountry);
|
||||
}
|
||||
|
||||
public AlternativeTitles GetMovieAlternativeTitles(int movieId, string country)
|
||||
public async Task<AlternativeTitles> GetMovieAlternativeTitles(int movieId, string country)
|
||||
{
|
||||
return GetMovieMethod<AlternativeTitles>(movieId, MovieMethods.AlternativeTitles, country: country);
|
||||
return await GetMovieMethod<AlternativeTitles>(movieId, MovieMethods.AlternativeTitles, country: country);
|
||||
}
|
||||
|
||||
public Credits GetMovieCredits(int movieId)
|
||||
public async Task<Credits> GetMovieCredits(int movieId)
|
||||
{
|
||||
return GetMovieMethod<Credits>(movieId, MovieMethods.Credits);
|
||||
return await GetMovieMethod<Credits>(movieId, MovieMethods.Credits);
|
||||
}
|
||||
|
||||
public ImagesWithId GetMovieImages(int movieId)
|
||||
public async Task<ImagesWithId> GetMovieImages(int movieId)
|
||||
{
|
||||
return GetMovieImages(movieId, DefaultLanguage);
|
||||
return await GetMovieImages(movieId, DefaultLanguage);
|
||||
}
|
||||
|
||||
public ImagesWithId GetMovieImages(int movieId, string language)
|
||||
public async Task<ImagesWithId> GetMovieImages(int movieId, string language)
|
||||
{
|
||||
return GetMovieMethod<ImagesWithId>(movieId, MovieMethods.Images, language: language);
|
||||
return await GetMovieMethod<ImagesWithId>(movieId, MovieMethods.Images, language: language);
|
||||
}
|
||||
|
||||
public KeywordsContainer GetMovieKeywords(int movieId)
|
||||
public async Task<KeywordsContainer> GetMovieKeywords(int movieId)
|
||||
{
|
||||
return GetMovieMethod<KeywordsContainer>(movieId, MovieMethods.Keywords);
|
||||
return await GetMovieMethod<KeywordsContainer>(movieId, MovieMethods.Keywords);
|
||||
}
|
||||
|
||||
public Releases GetMovieReleases(int movieId)
|
||||
public async Task<Releases> GetMovieReleases(int movieId)
|
||||
{
|
||||
return GetMovieMethod<Releases>(movieId, MovieMethods.Releases, dateFormat: "yyyy-MM-dd");
|
||||
return await GetMovieMethod<Releases>(movieId, MovieMethods.Releases, dateFormat: "yyyy-MM-dd");
|
||||
}
|
||||
|
||||
public Trailers GetMovieTrailers(int movieId)
|
||||
public async Task<Trailers> GetMovieTrailers(int movieId)
|
||||
{
|
||||
return GetMovieMethod<Trailers>(movieId, MovieMethods.Trailers);
|
||||
return await GetMovieMethod<Trailers>(movieId, MovieMethods.Trailers);
|
||||
}
|
||||
|
||||
public TranslationsContainer GetMovieTranslations(int movieId)
|
||||
public async Task<TranslationsContainer> GetMovieTranslations(int movieId)
|
||||
{
|
||||
return GetMovieMethod<TranslationsContainer>(movieId, MovieMethods.Translations);
|
||||
return await GetMovieMethod<TranslationsContainer>(movieId, MovieMethods.Translations);
|
||||
}
|
||||
|
||||
public SearchContainer<MovieResult> GetMovieSimilarMovies(int movieId, int page = 0)
|
||||
public async Task<SearchContainer<MovieResult>> GetMovieSimilarMovies(int movieId, int page = 0)
|
||||
{
|
||||
return GetMovieSimilarMovies(movieId, DefaultLanguage, page);
|
||||
return await GetMovieSimilarMovies(movieId, DefaultLanguage, page);
|
||||
}
|
||||
|
||||
public SearchContainer<MovieResult> GetMovieSimilarMovies(int movieId, string language, int page = 0)
|
||||
public async Task<SearchContainer<MovieResult>> GetMovieSimilarMovies(int movieId, string language, int page = 0)
|
||||
{
|
||||
return GetMovieMethod<SearchContainer<MovieResult>>(movieId, MovieMethods.SimilarMovies, page: page, language: language, dateFormat: "yyyy-MM-dd");
|
||||
return await GetMovieMethod<SearchContainer<MovieResult>>(movieId, MovieMethods.SimilarMovies, page: page, language: language, dateFormat: "yyyy-MM-dd");
|
||||
}
|
||||
|
||||
public SearchContainer<Review> GetMovieReviews(int movieId, int page = 0)
|
||||
public async Task<SearchContainer<Review>> GetMovieReviews(int movieId, int page = 0)
|
||||
{
|
||||
return GetMovieReviews(movieId, DefaultLanguage, page);
|
||||
return await GetMovieReviews(movieId, DefaultLanguage, page);
|
||||
}
|
||||
|
||||
public SearchContainer<Review> GetMovieReviews(int movieId, string language, int page = 0)
|
||||
public async Task<SearchContainer<Review>> GetMovieReviews(int movieId, string language, int page = 0)
|
||||
{
|
||||
return GetMovieMethod<SearchContainer<Review>>(movieId, MovieMethods.Reviews, page: page, language: language);
|
||||
return await GetMovieMethod<SearchContainer<Review>>(movieId, MovieMethods.Reviews, page: page, language: language);
|
||||
}
|
||||
|
||||
public SearchContainer<ListResult> GetMovieLists(int movieId, int page = 0)
|
||||
public async Task<SearchContainer<ListResult>> GetMovieLists(int movieId, int page = 0)
|
||||
{
|
||||
return GetMovieLists(movieId, DefaultLanguage, page);
|
||||
return await GetMovieLists(movieId, DefaultLanguage, page);
|
||||
}
|
||||
|
||||
public SearchContainer<ListResult> GetMovieLists(int movieId, string language, int page = 0)
|
||||
public async Task<SearchContainer<ListResult>> GetMovieLists(int movieId, string language, int page = 0)
|
||||
{
|
||||
return GetMovieMethod<SearchContainer<ListResult>>(movieId, MovieMethods.Lists, page: page, language: language);
|
||||
return await GetMovieMethod<SearchContainer<ListResult>>(movieId, MovieMethods.Lists, page: page, language: language);
|
||||
}
|
||||
|
||||
public List<Change> GetMovieChanges(int movieId, DateTime? startDate = null, DateTime? endDate = null)
|
||||
public async Task<List<Change>> GetMovieChanges(int movieId, DateTime? startDate = null, DateTime? endDate = null)
|
||||
{
|
||||
return GetMovieMethod<ChangesContainer>(movieId, MovieMethods.Changes, startDate: startDate, endDate: endDate, dateFormat: "yyyy-MM-dd HH:mm:ss UTC").Changes;
|
||||
return (await GetMovieMethod<ChangesContainer>(movieId, MovieMethods.Changes, startDate: startDate, endDate: endDate, dateFormat: "yyyy-MM-dd HH:mm:ss UTC")).Changes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -209,7 +210,7 @@ namespace TMDbLib.Client
|
||||
/// <param name="movieId">The id of the movie to get the account states for</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 MovieAccountState GetMovieAccountState(int movieId)
|
||||
public async Task<MovieAccountState> GetMovieAccountState(int movieId)
|
||||
{
|
||||
RequireSessionId(SessionType.UserSession);
|
||||
|
||||
@ -218,7 +219,7 @@ namespace TMDbLib.Client
|
||||
request.AddUrlSegment("method", MovieMethods.AccountStates.GetDescription());
|
||||
request.AddParameter("session_id", SessionId);
|
||||
|
||||
IRestResponse<MovieAccountState> response = _client.Get<MovieAccountState>(request);
|
||||
IRestResponse<MovieAccountState> response = await _client.ExecuteGetTaskAsync<MovieAccountState>(request);
|
||||
|
||||
// Do some custom deserialization, since TMDb uses a property that changes type we can't use automatic deserialization
|
||||
if (response.Data != null)
|
||||
@ -237,7 +238,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 bool MovieSetRating(int movieId, double rating)
|
||||
public async Task<bool> MovieSetRating(int movieId, double rating)
|
||||
{
|
||||
RequireSessionId(SessionType.GuestSession);
|
||||
|
||||
@ -250,27 +251,27 @@ namespace TMDbLib.Client
|
||||
|
||||
request.AddBody(new { value = rating });
|
||||
|
||||
IRestResponse<PostReply> response = _client.Post<PostReply>(request);
|
||||
IRestResponse<PostReply> response = await _client.ExecutePostTaskAsync<PostReply>(request);
|
||||
|
||||
// status code 1 = "Success"
|
||||
// status code 12 = "The item/record was updated successfully" - Used when an item was previously rated by the user
|
||||
return response.Data != null && (response.Data.StatusCode == 1 || response.Data.StatusCode == 12);
|
||||
}
|
||||
|
||||
public Movie GetMovieLatest()
|
||||
public async Task<Movie> GetMovieLatest()
|
||||
{
|
||||
RestRequest req = new RestRequest("movie/latest");
|
||||
IRestResponse<Movie> resp = _client.Get<Movie>(req);
|
||||
IRestResponse<Movie> resp = await _client.ExecuteGetTaskAsync<Movie>(req);
|
||||
|
||||
return resp.Data;
|
||||
}
|
||||
|
||||
public SearchContainer<MovieResult> GetMovieList(MovieListType type, int page = 0)
|
||||
public async Task<SearchContainer<MovieResult>> GetMovieList(MovieListType type, int page = 0)
|
||||
{
|
||||
return GetMovieList(type, DefaultLanguage, page);
|
||||
return await GetMovieList(type, DefaultLanguage, page);
|
||||
}
|
||||
|
||||
public SearchContainer<MovieResult> GetMovieList(MovieListType type, string language, int page = 0)
|
||||
public async Task<SearchContainer<MovieResult>> GetMovieList(MovieListType type, string language, int page = 0)
|
||||
{
|
||||
RestRequest req;
|
||||
switch (type)
|
||||
@ -298,7 +299,7 @@ namespace TMDbLib.Client
|
||||
|
||||
req.DateFormat = "yyyy-MM-dd";
|
||||
|
||||
IRestResponse<SearchContainer<MovieResult>> resp = _client.Get<SearchContainer<MovieResult>>(req);
|
||||
IRestResponse<SearchContainer<MovieResult>> resp = await _client.ExecuteGetTaskAsync<SearchContainer<MovieResult>>(req);
|
||||
|
||||
return resp.Data;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Globalization;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using TMDbLib.Objects.TvShows;
|
||||
|
||||
@ -10,12 +11,12 @@ namespace TMDbLib.Client
|
||||
/// Retrieves a network by it's TMDb id. A network is a distributer of media content ex. HBO, AMC
|
||||
/// </summary>
|
||||
/// <param name="networkId">The id of the network object to retrieve</param>
|
||||
public Network GetNetwork(int networkId)
|
||||
public async Task<Network> GetNetwork(int networkId)
|
||||
{
|
||||
RestRequest request = new RestRequest("network/{networkId}");
|
||||
request.AddUrlSegment("networkId", networkId.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
IRestResponse<Network> response = _client.Get<Network>(request);
|
||||
IRestResponse<Network> response = await _client.ExecuteGetTaskAsync<Network>(request);
|
||||
|
||||
return response.Data;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using TMDbLib.Objects.Movies;
|
||||
using TMDbLib.Objects.People;
|
||||
@ -12,7 +13,7 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public Person GetPerson(int personId, PersonMethods extraMethods = PersonMethods.Undefined)
|
||||
public async Task<Person> GetPerson(int personId, PersonMethods extraMethods = PersonMethods.Undefined)
|
||||
{
|
||||
RestRequest req = new RestRequest("person/{personId}");
|
||||
req.AddUrlSegment("personId", personId.ToString());
|
||||
@ -29,7 +30,7 @@ namespace TMDbLib.Client
|
||||
|
||||
req.DateFormat = "yyyy-MM-dd";
|
||||
|
||||
IRestResponse<Person> resp = _client.Get<Person>(req);
|
||||
IRestResponse<Person> resp = await _client.ExecuteGetTaskAsync<Person>(req);
|
||||
|
||||
// Patch up data, so that the end user won't notice that we share objects between request-types.
|
||||
if (resp.Data != null)
|
||||
@ -44,7 +45,7 @@ namespace TMDbLib.Client
|
||||
return resp.Data;
|
||||
}
|
||||
|
||||
private T GetPersonMethod<T>(int personId, PersonMethods personMethod, string dateFormat = null, string country = null, string language = null,
|
||||
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) where T : new()
|
||||
{
|
||||
RestRequest req = new RestRequest("person/{personId}/{method}");
|
||||
@ -66,33 +67,33 @@ namespace TMDbLib.Client
|
||||
if (endDate != null)
|
||||
req.AddParameter("endDate", endDate.Value.ToString("yyyy-MM-dd"));
|
||||
|
||||
IRestResponse<T> resp = _client.Get<T>(req);
|
||||
IRestResponse<T> resp = await _client.ExecuteGetTaskAsync<T>(req);
|
||||
|
||||
return resp.Data;
|
||||
}
|
||||
|
||||
public Credits GetPersonCredits(int personId)
|
||||
public async Task<Credits> GetPersonCredits(int personId)
|
||||
{
|
||||
return GetPersonCredits(personId, DefaultLanguage);
|
||||
return await GetPersonCredits(personId, DefaultLanguage);
|
||||
}
|
||||
|
||||
public Credits GetPersonCredits(int personId, string language)
|
||||
public async Task<Credits> GetPersonCredits(int personId, string language)
|
||||
{
|
||||
return GetPersonMethod<Credits>(personId, PersonMethods.Credits, language: language);
|
||||
return await GetPersonMethod<Credits>(personId, PersonMethods.Credits, language: language);
|
||||
}
|
||||
|
||||
public ProfileImages GetPersonImages(int personId)
|
||||
public async Task<ProfileImages> GetPersonImages(int personId)
|
||||
{
|
||||
return GetPersonMethod<ProfileImages>(personId, PersonMethods.Images);
|
||||
return await GetPersonMethod<ProfileImages>(personId, PersonMethods.Images);
|
||||
}
|
||||
|
||||
public List<Change> GetPersonChanges(int personId, DateTime? startDate = null, DateTime? endDate = null)
|
||||
public async Task<List<Change>> GetPersonChanges(int personId, DateTime? startDate = null, DateTime? endDate = null)
|
||||
{
|
||||
ChangesContainer changesContainer = GetPersonMethod<ChangesContainer>(personId, PersonMethods.Changes, startDate: startDate, endDate: endDate, dateFormat: "yyyy-MM-dd HH:mm:ss UTC");
|
||||
ChangesContainer changesContainer = await GetPersonMethod<ChangesContainer>(personId, PersonMethods.Changes, startDate: startDate, endDate: endDate, dateFormat: "yyyy-MM-dd HH:mm:ss UTC");
|
||||
return changesContainer.Changes;
|
||||
}
|
||||
|
||||
public SearchContainer<PersonResult> GetPersonList(PersonListType type, int page = 0)
|
||||
public async Task<SearchContainer<PersonResult>> GetPersonList(PersonListType type, int page = 0)
|
||||
{
|
||||
RestRequest req;
|
||||
switch (type)
|
||||
@ -109,12 +110,12 @@ namespace TMDbLib.Client
|
||||
|
||||
req.DateFormat = "yyyy-MM-dd";
|
||||
|
||||
IRestResponse<SearchContainer<PersonResult>> resp = _client.Get<SearchContainer<PersonResult>>(req);
|
||||
IRestResponse<SearchContainer<PersonResult>> resp = await _client.ExecuteGetTaskAsync<SearchContainer<PersonResult>>(req);
|
||||
|
||||
return resp.Data;
|
||||
}
|
||||
|
||||
public Person GetPersonItem(PersonItemType type)
|
||||
public async Task<Person> GetPersonItem(PersonItemType type)
|
||||
{
|
||||
RestRequest req;
|
||||
switch (type)
|
||||
@ -128,7 +129,7 @@ namespace TMDbLib.Client
|
||||
|
||||
req.DateFormat = "yyyy-MM-dd";
|
||||
|
||||
IRestResponse<Person> resp = _client.Get<Person>(req);
|
||||
IRestResponse<Person> resp = await _client.ExecuteGetTaskAsync<Person>(req);
|
||||
|
||||
return resp.Data;
|
||||
}
|
||||
|
@ -1,18 +1,19 @@
|
||||
using RestSharp;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using TMDbLib.Objects.Reviews;
|
||||
|
||||
namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
public Review GetReview(string reviewId)
|
||||
public async Task<Review> GetReview(string reviewId)
|
||||
{
|
||||
RestRequest request = new RestRequest("review/{reviewId}");
|
||||
request.AddUrlSegment("reviewId", reviewId);
|
||||
|
||||
request.DateFormat = "yyyy-MM-dd";
|
||||
|
||||
IRestResponse<Review> resp = _client.Get<Review>(request);
|
||||
IRestResponse<Review> resp = await _client.ExecuteGetTaskAsync<Review>(request);
|
||||
|
||||
return resp.Data;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using RestSharp;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.Search;
|
||||
using TMDbLib.Objects.TvShows;
|
||||
@ -7,7 +8,7 @@ namespace TMDbLib.Client
|
||||
{
|
||||
public partial class TMDbClient
|
||||
{
|
||||
private T SearchMethod<T>(string method, string query, int page, string language = null, bool? includeAdult = null, int year = 0, string dateFormat = null) where T : new()
|
||||
private async Task<T> SearchMethod<T>(string method, string query, int page, string language = null, bool? includeAdult = null, int year = 0, string dateFormat = null) where T : new()
|
||||
{
|
||||
RestRequest req = new RestRequest("search/{method}");
|
||||
req.AddUrlSegment("method", method);
|
||||
@ -26,64 +27,64 @@ namespace TMDbLib.Client
|
||||
if (dateFormat != null)
|
||||
req.DateFormat = dateFormat;
|
||||
|
||||
IRestResponse<T> resp = _client.Get<T>(req);
|
||||
IRestResponse<T> resp = await _client.ExecuteGetTaskAsync<T>(req);
|
||||
|
||||
return resp.Data;
|
||||
}
|
||||
|
||||
public SearchContainer<SearchMovie> SearchMovie(string query, int page = 0, bool includeAdult = false, int year = 0)
|
||||
public async Task<SearchContainer<SearchMovie>> SearchMovie(string query, int page = 0, bool includeAdult = false, int year = 0)
|
||||
{
|
||||
return SearchMovie(query, DefaultLanguage, page, includeAdult, year);
|
||||
return await SearchMovie(query, DefaultLanguage, page, includeAdult, year);
|
||||
}
|
||||
|
||||
public SearchContainer<SearchMovie> SearchMovie(string query, string language, int page = 0, bool includeAdult = false, int year = 0)
|
||||
public async Task<SearchContainer<SearchMovie>> SearchMovie(string query, string language, int page = 0, bool includeAdult = false, int year = 0)
|
||||
{
|
||||
return SearchMethod<SearchContainer<SearchMovie>>("movie", query, page, language, includeAdult, year, "yyyy-MM-dd");
|
||||
return await SearchMethod<SearchContainer<SearchMovie>>("movie", query, page, language, includeAdult, year, "yyyy-MM-dd");
|
||||
}
|
||||
|
||||
public SearchContainer<SearchMulti> SearchMulti(string query, int page = 0, bool includeAdult = false, int year = 0)
|
||||
public async Task<SearchContainer<SearchMulti>> SearchMulti(string query, int page = 0, bool includeAdult = false, int year = 0)
|
||||
{
|
||||
return SearchMulti(query, DefaultLanguage, page, includeAdult, year);
|
||||
return await SearchMulti(query, DefaultLanguage, page, includeAdult, year);
|
||||
}
|
||||
|
||||
public SearchContainer<SearchMulti> SearchMulti(string query, string language, int page = 0, bool includeAdult = false, int year = 0)
|
||||
public async Task<SearchContainer<SearchMulti>> SearchMulti(string query, string language, int page = 0, bool includeAdult = false, int year = 0)
|
||||
{
|
||||
return SearchMethod<SearchContainer<SearchMulti>>("multi", query, page, language, includeAdult, year, "yyyy-MM-dd");
|
||||
return await SearchMethod<SearchContainer<SearchMulti>>("multi", query, page, language, includeAdult, year, "yyyy-MM-dd");
|
||||
}
|
||||
|
||||
public SearchContainer<SearchResultCollection> SearchCollection(string query, int page = 0)
|
||||
public async Task<SearchContainer<SearchResultCollection>> SearchCollection(string query, int page = 0)
|
||||
{
|
||||
return SearchCollection(query, DefaultLanguage, page);
|
||||
return await SearchCollection(query, DefaultLanguage, page);
|
||||
}
|
||||
|
||||
public SearchContainer<SearchResultCollection> SearchCollection(string query, string language, int page = 0)
|
||||
public async Task<SearchContainer<SearchResultCollection>> SearchCollection(string query, string language, int page = 0)
|
||||
{
|
||||
return SearchMethod<SearchContainer<SearchResultCollection>>("collection", query, page, language);
|
||||
return await SearchMethod<SearchContainer<SearchResultCollection>>("collection", query, page, language);
|
||||
}
|
||||
|
||||
public SearchContainer<SearchPerson> SearchPerson(string query, int page = 0, bool includeAdult = false)
|
||||
public async Task<SearchContainer<SearchPerson>> SearchPerson(string query, int page = 0, bool includeAdult = false)
|
||||
{
|
||||
return SearchMethod<SearchContainer<SearchPerson>>("person", query, page, includeAdult: includeAdult);
|
||||
return await SearchMethod<SearchContainer<SearchPerson>>("person", query, page, includeAdult: includeAdult);
|
||||
}
|
||||
|
||||
public SearchContainer<SearchList> SearchList(string query, int page = 0, bool includeAdult = false)
|
||||
public async Task<SearchContainer<SearchList>> SearchList(string query, int page = 0, bool includeAdult = false)
|
||||
{
|
||||
return SearchMethod<SearchContainer<SearchList>>("list", query, page, includeAdult: includeAdult);
|
||||
return await SearchMethod<SearchContainer<SearchList>>("list", query, page, includeAdult: includeAdult);
|
||||
}
|
||||
|
||||
public SearchContainer<SearchCompany> SearchCompany(string query, int page = 0)
|
||||
public async Task<SearchContainer<SearchCompany>> SearchCompany(string query, int page = 0)
|
||||
{
|
||||
return SearchMethod<SearchContainer<SearchCompany>>("company", query, page);
|
||||
return await SearchMethod<SearchContainer<SearchCompany>>("company", query, page);
|
||||
}
|
||||
|
||||
public SearchContainer<SearchKeyword> SearchKeyword(string query, int page = 0)
|
||||
public async Task<SearchContainer<SearchKeyword>> SearchKeyword(string query, int page = 0)
|
||||
{
|
||||
return SearchMethod<SearchContainer<SearchKeyword>>("keyword", query, page);
|
||||
return await SearchMethod<SearchContainer<SearchKeyword>>("keyword", query, page);
|
||||
}
|
||||
|
||||
public SearchContainer<TvShowBase> SearchTvShow(string query, int page = 0)
|
||||
public async Task<SearchContainer<TvShowBase>> SearchTvShow(string query, int page = 0)
|
||||
{
|
||||
return SearchMethod<SearchContainer<TvShowBase>>("tv", query, page);
|
||||
return await SearchMethod<SearchContainer<TvShowBase>>("tv", query, page);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.TvShows;
|
||||
@ -18,7 +19,7 @@ namespace TMDbLib.Client
|
||||
/// <param name="episodeNumber">The episode number of the episode you want to retrieve.</param>
|
||||
/// <param name="extraMethods">Enum flags indicating any additional data that should be fetched in the same request.</param>
|
||||
/// <param name="language">If specified the api will attempt to return a localized result. ex: en,it,es </param>
|
||||
public TvEpisode GetTvEpisode(int tvShowId, int seasonNumber, int episodeNumber, TvEpisodeMethods extraMethods = TvEpisodeMethods.Undefined, string language = null)
|
||||
public async Task<TvEpisode> GetTvEpisode(int tvShowId, int seasonNumber, int episodeNumber, TvEpisodeMethods extraMethods = TvEpisodeMethods.Undefined, string language = null)
|
||||
{
|
||||
RestRequest req = new RestRequest("tv/{id}/season/{season_number}/episode/{episode_number}");
|
||||
req.AddUrlSegment("id", tvShowId.ToString(CultureInfo.InvariantCulture));
|
||||
@ -38,7 +39,7 @@ namespace TMDbLib.Client
|
||||
if (appends != string.Empty)
|
||||
req.AddParameter("append_to_response", appends);
|
||||
|
||||
IRestResponse<TvEpisode> response = _client.Get<TvEpisode>(req);
|
||||
IRestResponse<TvEpisode> response = await _client.ExecuteGetTaskAsync<TvEpisode>(req);
|
||||
|
||||
return response.Data;
|
||||
}
|
||||
@ -50,9 +51,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="language">If specified the api will attempt to return a localized result. ex: en,it,es </param>
|
||||
public Credits GetTvEpisodeCredits(int tvShowId, int seasonNumber, int episodeNumber, string language = null)
|
||||
public async Task<Credits> GetTvEpisodeCredits(int tvShowId, int seasonNumber, int episodeNumber, string language = null)
|
||||
{
|
||||
return GetTvEpisodeMethod<Credits>(tvShowId, seasonNumber, episodeNumber, TvEpisodeMethods.Credits, dateFormat: "yyyy-MM-dd", language: language);
|
||||
return await GetTvEpisodeMethod<Credits>(tvShowId, seasonNumber, episodeNumber, TvEpisodeMethods.Credits, dateFormat: "yyyy-MM-dd", language: language);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -65,9 +66,9 @@ namespace TMDbLib.Client
|
||||
/// If specified the api will attempt to return a localized result. ex: en,it,es.
|
||||
/// For images this means that the image might contain language specifc text
|
||||
/// </param>
|
||||
public StillImages GetTvEpisodeImages(int tvShowId, int seasonNumber, int episodeNumber, string language = null)
|
||||
public async Task<StillImages> GetTvEpisodeImages(int tvShowId, int seasonNumber, int episodeNumber, string language = null)
|
||||
{
|
||||
return GetTvEpisodeMethod<StillImages>(tvShowId, seasonNumber, episodeNumber, TvEpisodeMethods.Images, language: language);
|
||||
return await GetTvEpisodeMethod<StillImages>(tvShowId, seasonNumber, episodeNumber, TvEpisodeMethods.Images, language: language);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -76,12 +77,12 @@ namespace TMDbLib.Client
|
||||
/// <param name="tvShowId">The TMDb id of the target tv show.</param>
|
||||
/// <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>
|
||||
public ExternalIds GetTvEpisodeExternalIds(int tvShowId, int seasonNumber, int episodeNumber)
|
||||
public async Task<ExternalIds> GetTvEpisodeExternalIds(int tvShowId, int seasonNumber, int episodeNumber)
|
||||
{
|
||||
return GetTvEpisodeMethod<ExternalIds>(tvShowId, seasonNumber, episodeNumber, TvEpisodeMethods.ExternalIds);
|
||||
return await GetTvEpisodeMethod<ExternalIds>(tvShowId, seasonNumber, episodeNumber, TvEpisodeMethods.ExternalIds);
|
||||
}
|
||||
|
||||
private T GetTvEpisodeMethod<T>(int tvShowId, int seasonNumber, int episodeNumber, TvEpisodeMethods tvShowMethod, string dateFormat = null, string language = null) where T : new()
|
||||
private async Task<T> GetTvEpisodeMethod<T>(int tvShowId, int seasonNumber, int episodeNumber, TvEpisodeMethods tvShowMethod, string dateFormat = null, string language = null) where T : new()
|
||||
{
|
||||
RestRequest req = new RestRequest("tv/{id}/season/{season_number}/episode/{episode_number}/{method}");
|
||||
req.AddUrlSegment("id", tvShowId.ToString(CultureInfo.InvariantCulture));
|
||||
@ -96,7 +97,7 @@ namespace TMDbLib.Client
|
||||
if (language != null)
|
||||
req.AddParameter("language", language);
|
||||
|
||||
IRestResponse<T> resp = _client.Get<T>(req);
|
||||
IRestResponse<T> resp = await _client.ExecuteGetTaskAsync<T>(req);
|
||||
|
||||
return resp.Data;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ namespace TMDbLib.Client
|
||||
if (appends != string.Empty)
|
||||
req.AddParameter("append_to_response", appends);
|
||||
|
||||
return await _client.GetTaskAsync<TvSeason>(req);
|
||||
return (await _client.ExecuteGetTaskAsync<TvSeason>(req)).Data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -89,7 +89,7 @@ namespace TMDbLib.Client
|
||||
if (language != null)
|
||||
req.AddParameter("language", language);
|
||||
|
||||
return await _client.GetTaskAsync<T>(req);
|
||||
return (await _client.ExecuteGetTaskAsync<T>(req)).Data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
using TMDbLib.Objects.General;
|
||||
using TMDbLib.Objects.TvShows;
|
||||
@ -17,7 +18,7 @@ namespace TMDbLib.Client
|
||||
/// <param name="extraMethods">Enum flags indicating any additional data that should be fetched in the same request.</param>
|
||||
/// <param name="language">If specified the api will attempt to return a localized result. ex: en,it,es </param>
|
||||
/// <returns>The requested Tv Show</returns>
|
||||
public TvShow GetTvShow(int id, TvShowMethods extraMethods = TvShowMethods.Undefined, string language = null)
|
||||
public async Task<TvShow> GetTvShow(int id, TvShowMethods extraMethods = TvShowMethods.Undefined, string language = null)
|
||||
{
|
||||
RestRequest req = new RestRequest("tv/{id}");
|
||||
req.AddUrlSegment("id", id.ToString(CultureInfo.InvariantCulture));
|
||||
@ -35,7 +36,7 @@ namespace TMDbLib.Client
|
||||
if (appends != string.Empty)
|
||||
req.AddParameter("append_to_response", appends);
|
||||
|
||||
IRestResponse<TvShow> response = _client.Get<TvShow>(req);
|
||||
IRestResponse<TvShow> response = await _client.ExecuteGetTaskAsync<TvShow>(req);
|
||||
|
||||
return response.Data;
|
||||
}
|
||||
@ -47,9 +48,9 @@ namespace TMDbLib.Client
|
||||
/// Returns the basic information about a tv show.
|
||||
/// For additional data use the main GetTvShow method using the tv show id as parameter.
|
||||
/// </returns>
|
||||
public SearchContainer<TvShowBase> GetTvShowsPopular(int page = -1, string language = null)
|
||||
public async Task<SearchContainer<TvShowBase>> GetTvShowsPopular(int page = -1, string language = null)
|
||||
{
|
||||
return GetTvShowList(page, language, "popular");
|
||||
return await GetTvShowList(page, language, "popular");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -59,12 +60,12 @@ namespace TMDbLib.Client
|
||||
/// Returns the basic information about a tv show.
|
||||
/// For additional data use the main GetTvShow method using the tv show id as parameter
|
||||
/// </returns>
|
||||
public SearchContainer<TvShowBase> GetTvShowsTopRated(int page = -1, string language = null)
|
||||
public async Task<SearchContainer<TvShowBase>> GetTvShowsTopRated(int page = -1, string language = null)
|
||||
{
|
||||
return GetTvShowList(page, language, "top_rated");
|
||||
return await GetTvShowList(page, language, "top_rated");
|
||||
}
|
||||
|
||||
private SearchContainer<TvShowBase> GetTvShowList(int page, string language, string tvShowListType)
|
||||
private async Task<SearchContainer<TvShowBase>> GetTvShowList(int page, string language, string tvShowListType)
|
||||
{
|
||||
RestRequest req = new RestRequest("tv/" + tvShowListType);
|
||||
|
||||
@ -74,7 +75,7 @@ namespace TMDbLib.Client
|
||||
if (page >= 1)
|
||||
req.AddParameter("page", page);
|
||||
|
||||
IRestResponse<SearchContainer<TvShowBase>> response = _client.Get<SearchContainer<TvShowBase>>(req);
|
||||
IRestResponse<SearchContainer<TvShowBase>> response = await _client.ExecuteGetTaskAsync<SearchContainer<TvShowBase>>(req);
|
||||
|
||||
return response.Data;
|
||||
}
|
||||
@ -84,9 +85,9 @@ namespace TMDbLib.Client
|
||||
/// </summary>
|
||||
/// <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>
|
||||
public Credits GetTvShowCredits(int id, string language = null)
|
||||
public async Task<Credits> GetTvShowCredits(int id, string language = null)
|
||||
{
|
||||
return GetTvShowMethod<Credits>(id, TvShowMethods.Credits, dateFormat: "yyyy-MM-dd", language: language);
|
||||
return await GetTvShowMethod<Credits>(id, TvShowMethods.Credits, dateFormat: "yyyy-MM-dd", language: language);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -97,36 +98,36 @@ namespace TMDbLib.Client
|
||||
/// If specified the api will attempt to return a localized result. ex: en,it,es.
|
||||
/// For images this means that the image might contain language specifc text
|
||||
/// </param>
|
||||
public ImagesWithId GetTvShowImages(int id, string language = null)
|
||||
public async Task<ImagesWithId> GetTvShowImages(int id, string language = null)
|
||||
{
|
||||
return GetTvShowMethod<ImagesWithId>(id, TvShowMethods.Images, language: language);
|
||||
return await GetTvShowMethod<ImagesWithId>(id, TvShowMethods.Images, language: language);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an object that contains all known exteral id's for the tv show related to the specified TMDB id.
|
||||
/// </summary>
|
||||
/// <param name="id">The TMDb id of the target tv show.</param>
|
||||
public ExternalIds GetTvShowExternalIds(int id)
|
||||
public async Task<ExternalIds> GetTvShowExternalIds(int id)
|
||||
{
|
||||
return GetTvShowMethod<ExternalIds>(id, TvShowMethods.ExternalIds);
|
||||
return await GetTvShowMethod<ExternalIds>(id, TvShowMethods.ExternalIds);
|
||||
}
|
||||
|
||||
public ResultContainer<ContentRating> GetTvShowContentRatings(int id)
|
||||
public async Task<ResultContainer<ContentRating>> GetTvShowContentRatings(int id)
|
||||
{
|
||||
return GetTvShowMethod<ResultContainer<ContentRating>>(id, TvShowMethods.ContentRatings);
|
||||
return await GetTvShowMethod<ResultContainer<ContentRating>>(id, TvShowMethods.ContentRatings);
|
||||
}
|
||||
|
||||
public ResultContainer<AlternativeTitle> GetTvShowAlternativeTitles(int id)
|
||||
public async Task<ResultContainer<AlternativeTitle>> GetTvShowAlternativeTitles(int id)
|
||||
{
|
||||
return GetTvShowMethod<ResultContainer<AlternativeTitle>>(id, TvShowMethods.AlternativeTitles);
|
||||
return await GetTvShowMethod<ResultContainer<AlternativeTitle>>(id, TvShowMethods.AlternativeTitles);
|
||||
}
|
||||
|
||||
public ResultContainer<Keyword> GetTvShowKeywords(int id)
|
||||
public async Task<ResultContainer<Keyword>> GetTvShowKeywords(int id)
|
||||
{
|
||||
return GetTvShowMethod<ResultContainer<Keyword>>(id, TvShowMethods.Keywords);
|
||||
return await GetTvShowMethod<ResultContainer<Keyword>>(id, TvShowMethods.Keywords);
|
||||
}
|
||||
|
||||
private T GetTvShowMethod<T>(int id, TvShowMethods tvShowMethod, string dateFormat = null, string language = null) where T : new()
|
||||
private async Task<T> GetTvShowMethod<T>(int id, TvShowMethods tvShowMethod, string dateFormat = null, string language = null) where T : new()
|
||||
{
|
||||
RestRequest req = new RestRequest("tv/{id}/{method}");
|
||||
req.AddUrlSegment("id", id.ToString(CultureInfo.InvariantCulture));
|
||||
@ -138,7 +139,7 @@ namespace TMDbLib.Client
|
||||
if (language != null)
|
||||
req.AddParameter("language", language);
|
||||
|
||||
IRestResponse<T> resp = _client.Get<T>(req);
|
||||
IRestResponse<T> resp = await _client.ExecuteGetTaskAsync<T>(req);
|
||||
|
||||
return resp.Data;
|
||||
}
|
||||
|
@ -173,6 +173,7 @@
|
||||
<Compile Include="Objects\General\TMDbConfig.cs" />
|
||||
<Compile Include="TMDbRestClient.cs" />
|
||||
<Compile Include="Utilities\EnumExtensions.cs" />
|
||||
<Compile Include="Utilities\RestSharpExtensions.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
@ -29,7 +29,6 @@ namespace TMDbLib.Utilities
|
||||
}
|
||||
//If we have no description attribute, just return the ToString of the enum
|
||||
return enumerationValue.ToString();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
33
TMDbLib/Utilities/RestSharpExtensions.cs
Normal file
33
TMDbLib/Utilities/RestSharpExtensions.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using RestSharp;
|
||||
|
||||
namespace TMDbLib.Utilities
|
||||
{
|
||||
public static class RestSharpExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Executes a POST-style request asynchronously, authenticating if needed
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Target deserialization type</typeparam><param name="request">Request to be executed</param>
|
||||
public static Task<IRestResponse<T>> ExecuteDeleteTaskAsync<T>(this IRestClient client, IRestRequest request)
|
||||
{
|
||||
return client.ExecuteDeleteTaskAsync<T>(request, CancellationToken.None);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes a POST-style request asynchronously, authenticating if needed
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Target deserialization type</typeparam><param name="request">Request to be executed</param><param name="token">The cancellation token</param>
|
||||
public static Task<IRestResponse<T>> ExecuteDeleteTaskAsync<T>(this IRestClient client, IRestRequest request, CancellationToken token)
|
||||
{
|
||||
if (request == null)
|
||||
throw new ArgumentNullException("request");
|
||||
request.Method = Method.DELETE;
|
||||
return client.ExecuteTaskAsync<T>(request, token);
|
||||
}
|
||||
}
|
||||
}
|
@ -34,7 +34,7 @@ namespace TMDbLibTests
|
||||
public void TestAccountGetDetailsGuestAccount()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.GuestTestSessionId, SessionType.GuestSession);
|
||||
AccountDetails account = _config.Client.AccountGetDetails();
|
||||
AccountDetails account = _config.Client.AccountGetDetails().Result;
|
||||
|
||||
// Should always throw exception
|
||||
Assert.Fail();
|
||||
@ -44,7 +44,7 @@ namespace TMDbLibTests
|
||||
public void TestAccountGetDetailsUserAccount()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
AccountDetails account = _config.Client.AccountGetDetails();
|
||||
AccountDetails account = _config.Client.AccountGetDetails().Result;
|
||||
|
||||
// Naturally the specified account must have these values populated for the test to pass
|
||||
Assert.IsNotNull(account);
|
||||
@ -59,8 +59,8 @@ namespace TMDbLibTests
|
||||
public void TestAccountAccountGetLists()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
TestHelpers.SearchPages(i => _config.Client.AccountGetLists(i));
|
||||
List list = _config.Client.AccountGetLists().Results[0];
|
||||
TestHelpers.SearchPages(i => _config.Client.AccountGetLists(i).Result);
|
||||
List list = _config.Client.AccountGetLists().Result.Results[0];
|
||||
|
||||
Assert.IsNotNull(list.Id);
|
||||
Assert.IsNotNull(list.Name);
|
||||
@ -76,8 +76,8 @@ namespace TMDbLibTests
|
||||
public void TestAccountGetFavoriteMovies()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
TestHelpers.SearchPages(i => _config.Client.AccountGetFavoriteMovies(i));
|
||||
SearchMovie movie = _config.Client.AccountGetFavoriteMovies().Results[0];
|
||||
TestHelpers.SearchPages(i => _config.Client.AccountGetFavoriteMovies(i).Result);
|
||||
SearchMovie movie = _config.Client.AccountGetFavoriteMovies().Result.Results[0];
|
||||
|
||||
// Requires that you have marked at least one movie as favorite else this test will fail
|
||||
Assert.IsTrue(movie.Id > 0);
|
||||
@ -95,8 +95,8 @@ namespace TMDbLibTests
|
||||
public void TestAccountGetMovieWatchlist()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
TestHelpers.SearchPages(i => _config.Client.AccountGetFavoriteMovies(i));
|
||||
SearchMovie movie = _config.Client.AccountGetFavoriteMovies().Results[0];
|
||||
TestHelpers.SearchPages(i => _config.Client.AccountGetFavoriteMovies(i).Result);
|
||||
SearchMovie movie = _config.Client.AccountGetFavoriteMovies().Result.Results[0];
|
||||
|
||||
// Requires that you have added at least one movie to your watchlist else this test will fail
|
||||
Assert.IsTrue(movie.Id > 0);
|
||||
@ -114,8 +114,8 @@ namespace TMDbLibTests
|
||||
public void TestAccountGetRatedMovies()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
TestHelpers.SearchPages(i => _config.Client.AccountGetFavoriteMovies(i));
|
||||
SearchMovie movie = _config.Client.AccountGetFavoriteMovies().Results[0];
|
||||
TestHelpers.SearchPages(i => _config.Client.AccountGetFavoriteMovies(i).Result);
|
||||
SearchMovie movie = _config.Client.AccountGetFavoriteMovies().Result.Results[0];
|
||||
|
||||
// Requires that you have rated at least one movie else this test will fail
|
||||
Assert.IsTrue(movie.Id > 0);
|
||||
@ -138,13 +138,13 @@ namespace TMDbLibTests
|
||||
Assert.Fail("Test movie '{0}' was already marked as favorite unable to perform test correctly", Terminator);
|
||||
|
||||
// Try to mark is as a favorite
|
||||
Assert.IsTrue(_config.Client.AccountChangeMovieFavoriteStatus(Terminator, true));
|
||||
Assert.IsTrue(_config.Client.AccountChangeMovieFavoriteStatus(Terminator, true).Result);
|
||||
|
||||
// Check if it worked
|
||||
Assert.IsTrue(DoesFavoriteListContainSpecificMovie(Terminator));
|
||||
|
||||
// Try to un-mark is as a favorite
|
||||
Assert.IsTrue(_config.Client.AccountChangeMovieFavoriteStatus(Terminator, false));
|
||||
Assert.IsTrue(_config.Client.AccountChangeMovieFavoriteStatus(Terminator, false).Result);
|
||||
|
||||
// Check if it worked
|
||||
Assert.IsFalse(DoesFavoriteListContainSpecificMovie(Terminator));
|
||||
@ -159,13 +159,13 @@ namespace TMDbLibTests
|
||||
Assert.Fail("Test movie '{0}' was already on watchlist unable to perform test correctly", Terminator);
|
||||
|
||||
// Try to add an item to the watchlist
|
||||
Assert.IsTrue(_config.Client.AccountChangeMovieWatchlistStatus(Terminator, true));
|
||||
Assert.IsTrue(_config.Client.AccountChangeMovieWatchlistStatus(Terminator, true).Result);
|
||||
|
||||
// Check if it worked
|
||||
Assert.IsTrue(DoesWatchListContainSpecificMovie(Terminator));
|
||||
|
||||
// Try to remove item from watchlist
|
||||
Assert.IsTrue(_config.Client.AccountChangeMovieWatchlistStatus(Terminator, false));
|
||||
Assert.IsTrue(_config.Client.AccountChangeMovieWatchlistStatus(Terminator, false).Result);
|
||||
|
||||
// Check if it worked
|
||||
Assert.IsFalse(DoesWatchListContainSpecificMovie(Terminator));
|
||||
@ -173,12 +173,12 @@ namespace TMDbLibTests
|
||||
|
||||
private bool DoesFavoriteListContainSpecificMovie(int movieId)
|
||||
{
|
||||
return DoesListContainSpecificMovie(movieId, page => _config.Client.AccountGetFavoriteMovies(page));
|
||||
return DoesListContainSpecificMovie(movieId, page => _config.Client.AccountGetFavoriteMovies(page).Result);
|
||||
}
|
||||
|
||||
private bool DoesWatchListContainSpecificMovie(int movieId)
|
||||
{
|
||||
return DoesListContainSpecificMovie(movieId, page => _config.Client.AccountGetMovieWatchlist(page));
|
||||
return DoesListContainSpecificMovie(movieId, page => _config.Client.AccountGetMovieWatchlist(page).Result);
|
||||
}
|
||||
|
||||
private bool DoesListContainSpecificMovie(int movieId, Func<int, SearchContainer<SearchMovie>> listGetter)
|
||||
|
@ -28,7 +28,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestAuthenticationRequestNewToken()
|
||||
{
|
||||
Token token = _config.Client.AuthenticationRequestAutenticationToken();
|
||||
Token token = _config.Client.AuthenticationRequestAutenticationToken().Result;
|
||||
|
||||
Assert.IsNotNull(token);
|
||||
Assert.IsTrue(token.Success);
|
||||
@ -72,7 +72,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestAuthenticationGetUserSessionApiUserValidationSuccess()
|
||||
{
|
||||
Token token = _config.Client.AuthenticationRequestAutenticationToken();
|
||||
Token token = _config.Client.AuthenticationRequestAutenticationToken().Result;
|
||||
|
||||
_config.Client.AuthenticationValidateUserToken(token.RequestToken, _config.Username, _config.Password);
|
||||
}
|
||||
@ -81,7 +81,7 @@ namespace TMDbLibTests
|
||||
[ExpectedException(typeof(UnauthorizedAccessException))]
|
||||
public void TestAuthenticationGetUserSessionApiUserValidationInvalidLogin()
|
||||
{
|
||||
Token token = _config.Client.AuthenticationRequestAutenticationToken();
|
||||
Token token = _config.Client.AuthenticationRequestAutenticationToken().Result;
|
||||
|
||||
_config.Client.AuthenticationValidateUserToken(token.RequestToken, "bla", "bla");
|
||||
|
||||
@ -95,7 +95,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void AuthenticationGetUserSessionWithLoginSuccess()
|
||||
{
|
||||
UserSession session =_config.Client.AuthenticationGetUserSession(_config.Username, _config.Password);
|
||||
UserSession session = _config.Client.AuthenticationGetUserSession(_config.Username, _config.Password).Result;
|
||||
|
||||
Assert.IsNotNull(session);
|
||||
Assert.IsTrue(session.Success);
|
||||
@ -116,7 +116,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestAuthenticationCreateGuestSession()
|
||||
{
|
||||
GuestSession guestSession = _config.Client.AuthenticationCreateGuestSession();
|
||||
GuestSession guestSession = _config.Client.AuthenticationCreateGuestSession().Result;
|
||||
|
||||
Assert.IsNotNull(guestSession);
|
||||
Assert.IsTrue(guestSession.Success);
|
||||
|
@ -24,7 +24,7 @@ namespace TMDbLibTests
|
||||
public void TestChangesMovies()
|
||||
{
|
||||
// Basic check
|
||||
SearchContainer<ChangesListItem> changesPage1 = _config.Client.GetChangesMovies();
|
||||
SearchContainer<ChangesListItem> changesPage1 = _config.Client.GetChangesMovies().Result;
|
||||
|
||||
Assert.IsNotNull(changesPage1);
|
||||
Assert.IsTrue(changesPage1.Results.Count > 0);
|
||||
@ -32,14 +32,14 @@ namespace TMDbLibTests
|
||||
Assert.AreEqual(1, changesPage1.Page);
|
||||
|
||||
// Page 2
|
||||
SearchContainer<ChangesListItem> changesPage2 = _config.Client.GetChangesMovies(2);
|
||||
SearchContainer<ChangesListItem> changesPage2 = _config.Client.GetChangesMovies(2).Result;
|
||||
|
||||
Assert.IsNotNull(changesPage2);
|
||||
Assert.AreEqual(2, changesPage2.Page);
|
||||
|
||||
// Check date range (max)
|
||||
DateTime higher = DateTime.UtcNow.AddDays(-7);
|
||||
SearchContainer<ChangesListItem> changesMaxDate = _config.Client.GetChangesMovies(endDate: higher);
|
||||
SearchContainer<ChangesListItem> changesMaxDate = _config.Client.GetChangesMovies(endDate: higher).Result;
|
||||
|
||||
Assert.IsNotNull(changesMaxDate);
|
||||
Assert.AreEqual(1, changesMaxDate.Page);
|
||||
@ -47,7 +47,7 @@ namespace TMDbLibTests
|
||||
|
||||
// Check date range (lower)
|
||||
DateTime lower = DateTime.UtcNow.AddDays(-6); // Use 6 days to avoid clashes with the 'higher'
|
||||
SearchContainer<ChangesListItem> changesLowDate = _config.Client.GetChangesMovies(startDate: lower);
|
||||
SearchContainer<ChangesListItem> changesLowDate = _config.Client.GetChangesMovies(startDate: lower).Result;
|
||||
|
||||
Assert.IsNotNull(changesLowDate);
|
||||
Assert.AreEqual(1, changesLowDate.Page);
|
||||
@ -58,7 +58,7 @@ namespace TMDbLibTests
|
||||
public void TestChangesPeople()
|
||||
{
|
||||
// Basic check
|
||||
SearchContainer<ChangesListItem> changesPage1 = _config.Client.GetChangesPeople();
|
||||
SearchContainer<ChangesListItem> changesPage1 = _config.Client.GetChangesPeople().Result;
|
||||
|
||||
Assert.IsNotNull(changesPage1);
|
||||
Assert.IsTrue(changesPage1.Results.Count > 0);
|
||||
@ -66,14 +66,14 @@ namespace TMDbLibTests
|
||||
Assert.AreEqual(1, changesPage1.Page);
|
||||
|
||||
// Page 2
|
||||
SearchContainer<ChangesListItem> changesPage2 = _config.Client.GetChangesPeople(2);
|
||||
SearchContainer<ChangesListItem> changesPage2 = _config.Client.GetChangesPeople(2).Result;
|
||||
|
||||
Assert.IsNotNull(changesPage2);
|
||||
Assert.AreEqual(2, changesPage2.Page);
|
||||
|
||||
// Check date range (max)
|
||||
DateTime higher = DateTime.UtcNow.AddDays(-7);
|
||||
SearchContainer<ChangesListItem> changesMaxDate = _config.Client.GetChangesPeople(endDate: higher);
|
||||
SearchContainer<ChangesListItem> changesMaxDate = _config.Client.GetChangesPeople(endDate: higher).Result;
|
||||
|
||||
Assert.IsNotNull(changesMaxDate);
|
||||
Assert.AreEqual(1, changesMaxDate.Page);
|
||||
@ -81,7 +81,7 @@ namespace TMDbLibTests
|
||||
|
||||
// Check date range (lower)
|
||||
DateTime lower = DateTime.UtcNow.AddDays(-6); // Use 6 days to avoid clashes with the 'higher'
|
||||
SearchContainer<ChangesListItem> changesLowDate = _config.Client.GetChangesPeople(startDate: lower);
|
||||
SearchContainer<ChangesListItem> changesLowDate = _config.Client.GetChangesPeople(startDate: lower).Result;
|
||||
|
||||
Assert.IsNotNull(changesLowDate);
|
||||
Assert.AreEqual(1, changesLowDate.Page);
|
||||
@ -97,7 +97,7 @@ namespace TMDbLibTests
|
||||
public void TestChangesTvShows()
|
||||
{
|
||||
// Basic check
|
||||
SearchContainer<ChangesListItem> changesPage1 = _config.Client.GetChangesTv();
|
||||
SearchContainer<ChangesListItem> changesPage1 = _config.Client.GetChangesTv().Result;
|
||||
|
||||
Assert.IsNotNull(changesPage1);
|
||||
Assert.IsNotNull(changesPage1.Results);
|
||||
@ -109,7 +109,7 @@ namespace TMDbLibTests
|
||||
{
|
||||
Assert.IsTrue(changesPage1.TotalResults > changesPage1.Results.Count);
|
||||
// Page 2
|
||||
SearchContainer<ChangesListItem> changesPage2 = _config.Client.GetChangesTv(2);
|
||||
SearchContainer<ChangesListItem> changesPage2 = _config.Client.GetChangesTv(2).Result;
|
||||
|
||||
Assert.IsNotNull(changesPage2);
|
||||
Assert.AreEqual(2, changesPage2.Page);
|
||||
@ -117,7 +117,7 @@ namespace TMDbLibTests
|
||||
|
||||
// Check date range (max)
|
||||
DateTime higher = DateTime.UtcNow.AddDays(-8);
|
||||
SearchContainer<ChangesListItem> changesMaxDate = _config.Client.GetChangesTv(endDate: higher);
|
||||
SearchContainer<ChangesListItem> changesMaxDate = _config.Client.GetChangesTv(endDate: higher).Result;
|
||||
|
||||
Assert.IsNotNull(changesMaxDate);
|
||||
Assert.AreEqual(1, changesMaxDate.Page);
|
||||
@ -125,7 +125,7 @@ namespace TMDbLibTests
|
||||
|
||||
// Check date range (lower)
|
||||
DateTime lower = DateTime.UtcNow.AddDays(-6); // Use 6 days to avoid clashes with the 'higher'
|
||||
SearchContainer<ChangesListItem> changesLowDate = _config.Client.GetChangesTv(startDate: lower);
|
||||
SearchContainer<ChangesListItem> changesLowDate = _config.Client.GetChangesTv(startDate: lower).Result;
|
||||
|
||||
Assert.IsNotNull(changesLowDate);
|
||||
Assert.AreEqual(1, changesLowDate.Page);
|
||||
|
@ -37,7 +37,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestCollectionsExtrasNone()
|
||||
{
|
||||
Collection collection = _config.Client.GetCollection(JamesBondCollection);
|
||||
Collection collection = _config.Client.GetCollection(JamesBondCollection).Result;
|
||||
|
||||
// TODO: Test all properties
|
||||
Assert.IsNotNull(collection);
|
||||
@ -55,14 +55,14 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestCollectionsExtrasExclusive()
|
||||
{
|
||||
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetCollection(id, extras), JamesBondCollection);
|
||||
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetCollection(id, extras).Result, JamesBondCollection);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestCollectionsExtrasAll()
|
||||
{
|
||||
CollectionMethods combinedEnum = _methods.Keys.Aggregate((methods, movieMethods) => methods | movieMethods);
|
||||
Collection item = _config.Client.GetCollection(JamesBondCollection, combinedEnum);
|
||||
Collection item = _config.Client.GetCollection(JamesBondCollection, combinedEnum).Result;
|
||||
|
||||
TestMethodsHelper.TestAllNotNull(_methods, item);
|
||||
}
|
||||
@ -74,7 +74,7 @@ namespace TMDbLibTests
|
||||
_config.Client.GetConfig();
|
||||
|
||||
// Test image url generator
|
||||
ImagesWithId images = _config.Client.GetCollectionImages(JamesBondCollection);
|
||||
ImagesWithId images = _config.Client.GetCollectionImages(JamesBondCollection).Result;
|
||||
|
||||
Assert.AreEqual(JamesBondCollection, images.Id);
|
||||
TestImagesHelpers.TestImages(_config, images);
|
||||
|
@ -38,7 +38,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestCompaniesExtrasNone()
|
||||
{
|
||||
Company company = _config.Client.GetCompany(TwentiethCenturyFox);
|
||||
Company company = _config.Client.GetCompany(TwentiethCenturyFox).Result;
|
||||
|
||||
Assert.IsNotNull(company);
|
||||
|
||||
@ -55,14 +55,14 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestCompaniesExtrasExclusive()
|
||||
{
|
||||
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetCompany(id, extras), TwentiethCenturyFox);
|
||||
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetCompany(id, extras).Result, TwentiethCenturyFox);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestCompaniesExtrasAll()
|
||||
{
|
||||
CompanyMethods combinedEnum = _methods.Keys.Aggregate((methods, movieMethods) => methods | movieMethods);
|
||||
Company item = _config.Client.GetCompany(TwentiethCenturyFox, combinedEnum);
|
||||
Company item = _config.Client.GetCompany(TwentiethCenturyFox, combinedEnum).Result;
|
||||
|
||||
TestMethodsHelper.TestAllNotNull(_methods, item);
|
||||
}
|
||||
@ -71,9 +71,9 @@ namespace TMDbLibTests
|
||||
public void TestCompaniesGetters()
|
||||
{
|
||||
//GetCompanyMovies(int id, string language, int page = -1)
|
||||
SearchContainerWithId<MovieResult> resp = _config.Client.GetCompanyMovies(TwentiethCenturyFox);
|
||||
SearchContainerWithId<MovieResult> respPage2 = _config.Client.GetCompanyMovies(TwentiethCenturyFox, 2);
|
||||
SearchContainerWithId<MovieResult> respItalian = _config.Client.GetCompanyMovies(TwentiethCenturyFox, "it");
|
||||
SearchContainerWithId<MovieResult> resp = _config.Client.GetCompanyMovies(TwentiethCenturyFox).Result;
|
||||
SearchContainerWithId<MovieResult> respPage2 = _config.Client.GetCompanyMovies(TwentiethCenturyFox, 2).Result;
|
||||
SearchContainerWithId<MovieResult> respItalian = _config.Client.GetCompanyMovies(TwentiethCenturyFox, "it").Result;
|
||||
|
||||
Assert.IsNotNull(resp);
|
||||
Assert.IsNotNull(respPage2);
|
||||
@ -102,7 +102,7 @@ namespace TMDbLibTests
|
||||
_config.Client.GetConfig();
|
||||
|
||||
// Test image url generator
|
||||
Company company = _config.Client.GetCompany(TwentiethCenturyFox);
|
||||
Company company = _config.Client.GetCompany(TwentiethCenturyFox).Result;
|
||||
|
||||
Uri url = _config.Client.GetImageUrl("original", company.LogoPath);
|
||||
Uri urlSecure = _config.Client.GetImageUrl("original", company.LogoPath, true);
|
||||
|
@ -24,9 +24,9 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestDiscoverTvShowsNoParams()
|
||||
{
|
||||
TestHelpers.SearchPages(i => _config.Client.DiscoverTvShows(i));
|
||||
TestHelpers.SearchPages(i => _config.Client.DiscoverTvShows(i).Result);
|
||||
|
||||
SearchContainer<TvShowBase> result = _config.Client.DiscoverTvShows();
|
||||
SearchContainer<TvShowBase> result = _config.Client.DiscoverTvShows().Result;
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.AreEqual(1, result.Page);
|
||||
@ -37,9 +37,9 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestDiscoverMoviesNoParams()
|
||||
{
|
||||
TestHelpers.SearchPages(i => _config.Client.DiscoverMovies(i));
|
||||
TestHelpers.SearchPages(i => _config.Client.DiscoverMovies(i).Result);
|
||||
|
||||
SearchContainer<SearchMovie> result = _config.Client.DiscoverMovies();
|
||||
SearchContainer<SearchMovie> result = _config.Client.DiscoverMovies().Result;
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.AreEqual(1, result.Page);
|
||||
|
@ -29,48 +29,48 @@ namespace TMDbLibTests
|
||||
public void TestFindImdbMovie()
|
||||
{
|
||||
var result = _config.Client.Find(FindExternalSource.Imdb, imdbTerminatorId);
|
||||
Assert.AreEqual(1, result.MovieResults.Count);
|
||||
Assert.AreEqual(tmdbTerminatorId, result.MovieResults[0].Id);
|
||||
Assert.AreEqual(1, result.Result.MovieResults.Count);
|
||||
Assert.AreEqual(tmdbTerminatorId, result.Result.MovieResults[0].Id);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestFindTvdbTvShow()
|
||||
{
|
||||
var result = _config.Client.Find(FindExternalSource.TvDb, tvdbBreakingBadId);
|
||||
Assert.AreEqual(1, result.TvResults.Count);
|
||||
Assert.AreEqual(tmdbBreakingBadId, result.TvResults[0].Id);
|
||||
Assert.AreEqual(1, result.Result.TvResults.Count);
|
||||
Assert.AreEqual(tmdbBreakingBadId, result.Result.TvResults[0].Id);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestFindImdbTvShow()
|
||||
{
|
||||
var result = _config.Client.Find(FindExternalSource.Imdb, imdbBreakingBadId);
|
||||
Assert.AreEqual(1, result.TvResults.Count);
|
||||
Assert.AreEqual(tmdbBreakingBadId, result.TvResults[0].Id);
|
||||
Assert.AreEqual(1, result.Result.TvResults.Count);
|
||||
Assert.AreEqual(tmdbBreakingBadId, result.Result.TvResults[0].Id);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestFindTvRageTvShow()
|
||||
{
|
||||
var result = _config.Client.Find(FindExternalSource.TvRage, tvRageBreakingBadId);
|
||||
Assert.AreEqual(1, result.TvResults.Count);
|
||||
Assert.AreEqual(tmdbBreakingBadId, result.TvResults[0].Id);
|
||||
Assert.AreEqual(1, result.Result.TvResults.Count);
|
||||
Assert.AreEqual(tmdbBreakingBadId, result.Result.TvResults[0].Id);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestFindFreebaseTvShow()
|
||||
{
|
||||
var result = _config.Client.Find(FindExternalSource.FreeBaseId, freebaseBreakingBadId);
|
||||
Assert.AreEqual(1, result.TvResults.Count);
|
||||
Assert.AreEqual(tmdbBreakingBadId, result.TvResults[0].Id);
|
||||
Assert.AreEqual(1, result.Result.TvResults.Count);
|
||||
Assert.AreEqual(tmdbBreakingBadId, result.Result.TvResults[0].Id);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestFindFreebaseMidTvShow()
|
||||
{
|
||||
var result = _config.Client.Find(FindExternalSource.FreeBaseMid, freebaseMidBreakingBadId);
|
||||
Assert.AreEqual(1, result.TvResults.Count);
|
||||
Assert.AreEqual(tmdbBreakingBadId, result.TvResults[0].Id);
|
||||
Assert.AreEqual(1, result.Result.TvResults.Count);
|
||||
Assert.AreEqual(tmdbBreakingBadId, result.Result.TvResults[0].Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,13 +23,13 @@ namespace TMDbLibTests
|
||||
public void TestGenreList()
|
||||
{
|
||||
// Default language
|
||||
List<Genre> genres = _config.Client.GetGenres();
|
||||
List<Genre> genres = _config.Client.GetGenres().Result;
|
||||
|
||||
Assert.IsNotNull(genres);
|
||||
Assert.IsTrue(genres.Count > 0);
|
||||
|
||||
// Another language
|
||||
List<Genre> genresDanish = _config.Client.GetGenres("da");
|
||||
List<Genre> genresDanish = _config.Client.GetGenres("da").Result;
|
||||
|
||||
Assert.IsNotNull(genresDanish);
|
||||
Assert.IsTrue(genresDanish.Count > 0);
|
||||
@ -44,12 +44,12 @@ namespace TMDbLibTests
|
||||
public void TestGenreMovies()
|
||||
{
|
||||
// Get first genre
|
||||
Genre genre = _config.Client.GetGenres().First();
|
||||
Genre genre = _config.Client.GetGenres().Result.First();
|
||||
|
||||
// Get movies
|
||||
SearchContainerWithId<MovieResult> movies = _config.Client.GetGenreMovies(genre.Id);
|
||||
SearchContainerWithId<MovieResult> moviesPage2 = _config.Client.GetGenreMovies(genre.Id, "it", 2, includeAllMovies: false);
|
||||
SearchContainerWithId<MovieResult> moviesAll = _config.Client.GetGenreMovies(genre.Id, includeAllMovies: true);
|
||||
SearchContainerWithId<MovieResult> movies = _config.Client.GetGenreMovies(genre.Id).Result;
|
||||
SearchContainerWithId<MovieResult> moviesPage2 = _config.Client.GetGenreMovies(genre.Id, "it", 2, includeAllMovies: false).Result;
|
||||
SearchContainerWithId<MovieResult> moviesAll = _config.Client.GetGenreMovies(genre.Id, includeAllMovies: true).Result;
|
||||
|
||||
Assert.AreEqual(1, movies.Page);
|
||||
Assert.AreEqual(2, moviesPage2.Page);
|
||||
@ -64,7 +64,7 @@ namespace TMDbLibTests
|
||||
Assert.IsTrue(moviesAll.Results.All(s => s != null));
|
||||
|
||||
Assert.AreEqual(movies.TotalResults, moviesPage2.TotalResults); // Should be the same, despite the use of 'includeAllMovies' and Italian
|
||||
Assert.IsTrue(moviesAll.TotalResults > movies.TotalResults);
|
||||
Assert.IsTrue(moviesAll.TotalResults >= movies.TotalResults);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestJobList()
|
||||
{
|
||||
List<Job> jobs = _config.Client.GetJobs();
|
||||
List<Job> jobs = _config.Client.GetJobs().Result;
|
||||
|
||||
Assert.IsNotNull(jobs);
|
||||
Assert.IsTrue(jobs.Count > 0);
|
||||
|
@ -23,7 +23,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestKeywordGet()
|
||||
{
|
||||
KeywordsContainer keywords = _config.Client.GetMovieKeywords(AGoodDayToDieHard);
|
||||
KeywordsContainer keywords = _config.Client.GetMovieKeywords(AGoodDayToDieHard).Result;
|
||||
|
||||
Assert.IsNotNull(keywords);
|
||||
Assert.IsNotNull(keywords.Keywords);
|
||||
@ -32,7 +32,7 @@ namespace TMDbLibTests
|
||||
// Try to get all keywords
|
||||
foreach (Keyword testKeyword in keywords.Keywords)
|
||||
{
|
||||
Keyword getKeyword = _config.Client.GetKeyword(testKeyword.Id);
|
||||
Keyword getKeyword = _config.Client.GetKeyword(testKeyword.Id).Result;
|
||||
|
||||
Assert.IsNotNull(getKeyword);
|
||||
|
||||
@ -44,7 +44,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestKeywordMovies()
|
||||
{
|
||||
KeywordsContainer keywords = _config.Client.GetMovieKeywords(AGoodDayToDieHard);
|
||||
KeywordsContainer keywords = _config.Client.GetMovieKeywords(AGoodDayToDieHard).Result;
|
||||
|
||||
Assert.IsNotNull(keywords);
|
||||
Assert.IsNotNull(keywords.Keywords);
|
||||
@ -54,9 +54,9 @@ namespace TMDbLibTests
|
||||
Keyword testKeyword = keywords.Keywords.First();
|
||||
|
||||
// Get movies
|
||||
SearchContainer<MovieResult> movies = _config.Client.GetKeywordMovies(testKeyword.Id);
|
||||
SearchContainer<MovieResult> moviesItalian = _config.Client.GetKeywordMovies(testKeyword.Id, "it");
|
||||
SearchContainer<MovieResult> moviesPage2 = _config.Client.GetKeywordMovies(testKeyword.Id, 2);
|
||||
SearchContainer<MovieResult> movies = _config.Client.GetKeywordMovies(testKeyword.Id).Result;
|
||||
SearchContainer<MovieResult> moviesItalian = _config.Client.GetKeywordMovies(testKeyword.Id, "it").Result;
|
||||
SearchContainer<MovieResult> moviesPage2 = _config.Client.GetKeywordMovies(testKeyword.Id, 2).Result;
|
||||
|
||||
Assert.IsNotNull(movies);
|
||||
Assert.IsNotNull(moviesItalian);
|
||||
|
@ -29,7 +29,7 @@ namespace TMDbLibTests
|
||||
public void TestList()
|
||||
{
|
||||
// Get list
|
||||
List list = _config.Client.GetList(TestListId);
|
||||
List list = _config.Client.GetList(TestListId).Result;
|
||||
|
||||
Assert.IsNotNull(list);
|
||||
Assert.AreEqual(TestListId, list.Id);
|
||||
@ -41,7 +41,7 @@ namespace TMDbLibTests
|
||||
|
||||
// Ensure all movies point to this list
|
||||
int page = 1;
|
||||
SearchContainer<ListResult> movieLists = _config.Client.GetMovieLists(movieResult.Id);
|
||||
SearchContainer<ListResult> movieLists = _config.Client.GetMovieLists(movieResult.Id).Result;
|
||||
while (movieLists != null)
|
||||
{
|
||||
// Check if the current result page contains the relevant list
|
||||
@ -53,7 +53,7 @@ namespace TMDbLibTests
|
||||
|
||||
// See if there is an other page we could try, if not the test fails
|
||||
if (movieLists.Page < movieLists.TotalPages)
|
||||
movieLists = _config.Client.GetMovieLists(movieResult.Id, ++page);
|
||||
movieLists = _config.Client.GetMovieLists(movieResult.Id, ++page).Result;
|
||||
else
|
||||
Assert.Fail("Movie '{0}' was not linked to the test list", movieResult.Title);
|
||||
}
|
||||
@ -63,13 +63,13 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestListIsMoviePresentSuccess()
|
||||
{
|
||||
Assert.IsTrue(_config.Client.GetListIsMoviePresent(TestListId, Avatar));
|
||||
Assert.IsTrue(_config.Client.GetListIsMoviePresent(TestListId, Avatar).Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestListIsMoviePresentFailure()
|
||||
{
|
||||
Assert.IsFalse(_config.Client.GetListIsMoviePresent(TestListId, Terminator));
|
||||
Assert.IsFalse(_config.Client.GetListIsMoviePresent(TestListId, Terminator).Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -78,10 +78,10 @@ namespace TMDbLibTests
|
||||
const string listName = "Test List 123";
|
||||
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
string newListId = _config.Client.ListCreate(listName);
|
||||
string newListId = _config.Client.ListCreate(listName).Result;
|
||||
Assert.IsFalse(string.IsNullOrWhiteSpace(newListId));
|
||||
|
||||
List newlyAddedList = _config.Client.GetList(newListId);
|
||||
List newlyAddedList = _config.Client.GetList(newListId).Result;
|
||||
Assert.IsNotNull(newlyAddedList);
|
||||
Assert.AreEqual(listName, newlyAddedList.Name);
|
||||
Assert.AreEqual("", newlyAddedList.Description); // "" is the default value
|
||||
@ -90,7 +90,7 @@ namespace TMDbLibTests
|
||||
Assert.AreEqual(0, newlyAddedList.Items.Count);
|
||||
Assert.IsFalse(string.IsNullOrWhiteSpace(newlyAddedList.CreatedBy));
|
||||
|
||||
Assert.IsTrue(_config.Client.ListDelete(newListId));
|
||||
Assert.IsTrue(_config.Client.ListDelete(newListId).Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -98,7 +98,7 @@ namespace TMDbLibTests
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
// Try removing a list with an incorrect id
|
||||
Assert.IsFalse(_config.Client.ListDelete("bla"));
|
||||
Assert.IsFalse(_config.Client.ListDelete("bla").Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -106,20 +106,20 @@ namespace TMDbLibTests
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
// Add a new movie to the list
|
||||
Assert.IsTrue(_config.Client.ListAddMovie(TestListId, EvanAlmighty));
|
||||
Assert.IsTrue(_config.Client.ListAddMovie(TestListId, EvanAlmighty).Result);
|
||||
|
||||
// Try again, this time it should fail since the list already contains this movie
|
||||
Assert.IsFalse(_config.Client.ListAddMovie(TestListId, EvanAlmighty));
|
||||
Assert.IsFalse(_config.Client.ListAddMovie(TestListId, EvanAlmighty).Result);
|
||||
|
||||
// Get list and check if the item was added
|
||||
List listAfterAdd = _config.Client.GetList(TestListId);
|
||||
List listAfterAdd = _config.Client.GetList(TestListId).Result;
|
||||
Assert.IsTrue(listAfterAdd.Items.Any(m => m.Id == EvanAlmighty));
|
||||
|
||||
// Remove the previously added movie from the list
|
||||
Assert.IsTrue(_config.Client.ListRemoveMovie(TestListId, EvanAlmighty));
|
||||
Assert.IsTrue(_config.Client.ListRemoveMovie(TestListId, EvanAlmighty).Result);
|
||||
|
||||
// Get list and check if the item was removed
|
||||
List listAfterRemove = _config.Client.GetList(TestListId);
|
||||
List listAfterRemove = _config.Client.GetList(TestListId).Result;
|
||||
Assert.IsFalse(listAfterRemove.Items.Any(m => m.Id == EvanAlmighty));
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestMoviesExtrasNone()
|
||||
{
|
||||
Movie movie = _config.Client.GetMovie(AGoodDayToDieHard);
|
||||
Movie movie = _config.Client.GetMovie(AGoodDayToDieHard).Result;
|
||||
|
||||
Assert.IsNotNull(movie);
|
||||
|
||||
@ -74,7 +74,7 @@ namespace TMDbLibTests
|
||||
public void TestMoviesExtrasExclusive()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetMovie(id, extras), AGoodDayToDieHard);
|
||||
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetMovie(id, extras).Result, AGoodDayToDieHard);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -87,7 +87,7 @@ namespace TMDbLibTests
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
|
||||
MovieMethods combinedEnum = tmpMethods.Keys.Aggregate((methods, movieMethods) => methods | movieMethods);
|
||||
Movie item = _config.Client.GetMovie(TheDarkKnightRisesImdb, combinedEnum);
|
||||
Movie item = _config.Client.GetMovie(TheDarkKnightRisesImdb, combinedEnum).Result;
|
||||
|
||||
TestMethodsHelper.TestAllNotNull(tmpMethods, item);
|
||||
}
|
||||
@ -97,7 +97,7 @@ namespace TMDbLibTests
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
MovieMethods combinedEnum = _methods.Keys.Aggregate((methods, movieMethods) => methods | movieMethods);
|
||||
Movie item = _config.Client.GetMovie(AGoodDayToDieHard, combinedEnum);
|
||||
Movie item = _config.Client.GetMovie(AGoodDayToDieHard, combinedEnum).Result;
|
||||
|
||||
TestMethodsHelper.TestAllNotNull(_methods, item);
|
||||
}
|
||||
@ -105,8 +105,8 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestMoviesLanguage()
|
||||
{
|
||||
Movie movie = _config.Client.GetMovie(AGoodDayToDieHard);
|
||||
Movie movieItalian = _config.Client.GetMovie(AGoodDayToDieHard, "it");
|
||||
Movie movie = _config.Client.GetMovie(AGoodDayToDieHard).Result;
|
||||
Movie movieItalian = _config.Client.GetMovie(AGoodDayToDieHard, "it").Result;
|
||||
|
||||
Assert.IsNotNull(movie);
|
||||
Assert.IsNotNull(movieItalian);
|
||||
@ -126,10 +126,10 @@ namespace TMDbLibTests
|
||||
public void TestMoviesGetMovieAlternativeTitles()
|
||||
{
|
||||
//GetMovieAlternativeTitles(int id, string country)
|
||||
AlternativeTitles respUs = _config.Client.GetMovieAlternativeTitles(AGoodDayToDieHard, "US");
|
||||
AlternativeTitles respUs = _config.Client.GetMovieAlternativeTitles(AGoodDayToDieHard, "US").Result;
|
||||
Assert.IsNotNull(respUs);
|
||||
|
||||
AlternativeTitles respFrench = _config.Client.GetMovieAlternativeTitles(AGoodDayToDieHard, "FR");
|
||||
AlternativeTitles respFrench = _config.Client.GetMovieAlternativeTitles(AGoodDayToDieHard, "FR").Result;
|
||||
Assert.IsNotNull(respFrench);
|
||||
|
||||
Assert.IsFalse(respUs.Titles.Any(s => s.Title == "Duro de matar 5"));
|
||||
@ -143,12 +143,12 @@ namespace TMDbLibTests
|
||||
public void TestMoviesGetMovieAlternativeTitlesCountry()
|
||||
{
|
||||
//GetMovieAlternativeTitles(int id, string country)
|
||||
AlternativeTitles respUs = _config.Client.GetMovieAlternativeTitles(AGoodDayToDieHard, "US");
|
||||
AlternativeTitles respUs = _config.Client.GetMovieAlternativeTitles(AGoodDayToDieHard, "US").Result;
|
||||
Assert.IsNotNull(respUs);
|
||||
|
||||
_config.Client.DefaultCountry = "US";
|
||||
|
||||
AlternativeTitles respUs2 = _config.Client.GetMovieAlternativeTitles(AGoodDayToDieHard);
|
||||
AlternativeTitles respUs2 = _config.Client.GetMovieAlternativeTitles(AGoodDayToDieHard).Result;
|
||||
Assert.IsNotNull(respUs2);
|
||||
|
||||
Assert.AreEqual(respUs.Titles.Count, respUs2.Titles.Count);
|
||||
@ -158,7 +158,7 @@ namespace TMDbLibTests
|
||||
public void TestMoviesGetMovieCasts()
|
||||
{
|
||||
//GetMovieCasts(int id)
|
||||
Credits resp = _config.Client.GetMovieCredits(AGoodDayToDieHard);
|
||||
Credits resp = _config.Client.GetMovieCredits(AGoodDayToDieHard).Result;
|
||||
Assert.IsNotNull(resp);
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ namespace TMDbLibTests
|
||||
public void TestMoviesGetMovieImages()
|
||||
{
|
||||
//GetMovieImages(int id, string language)
|
||||
ImagesWithId resp = _config.Client.GetMovieImages(AGoodDayToDieHard);
|
||||
ImagesWithId resp = _config.Client.GetMovieImages(AGoodDayToDieHard).Result;
|
||||
Assert.IsNotNull(resp);
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ namespace TMDbLibTests
|
||||
public void TestMoviesGetMovieKeywords()
|
||||
{
|
||||
//GetMovieKeywords(int id)
|
||||
KeywordsContainer resp = _config.Client.GetMovieKeywords(AGoodDayToDieHard);
|
||||
KeywordsContainer resp = _config.Client.GetMovieKeywords(AGoodDayToDieHard).Result;
|
||||
Assert.IsNotNull(resp);
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ namespace TMDbLibTests
|
||||
public void TestMoviesGetMovieReleases()
|
||||
{
|
||||
//GetMovieReleases(int id)
|
||||
Releases resp = _config.Client.GetMovieReleases(AGoodDayToDieHard);
|
||||
Releases resp = _config.Client.GetMovieReleases(AGoodDayToDieHard).Result;
|
||||
Assert.IsNotNull(resp);
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ namespace TMDbLibTests
|
||||
public void TestMoviesGetMovieTrailers()
|
||||
{
|
||||
//GetMovieTrailers(int id)
|
||||
Trailers resp = _config.Client.GetMovieTrailers(AGoodDayToDieHard);
|
||||
Trailers resp = _config.Client.GetMovieTrailers(AGoodDayToDieHard).Result;
|
||||
Assert.IsNotNull(resp);
|
||||
}
|
||||
|
||||
@ -198,17 +198,17 @@ namespace TMDbLibTests
|
||||
public void TestMoviesGetMovieTranslations()
|
||||
{
|
||||
//GetMovieTranslations(int id)
|
||||
TranslationsContainer resp = _config.Client.GetMovieTranslations(AGoodDayToDieHard);
|
||||
TranslationsContainer resp = _config.Client.GetMovieTranslations(AGoodDayToDieHard).Result;
|
||||
Assert.IsNotNull(resp);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMoviesGetMovieSimilarMovies()
|
||||
{
|
||||
SearchContainer<MovieResult> resp = _config.Client.GetMovieSimilarMovies(AGoodDayToDieHard);
|
||||
SearchContainer<MovieResult> resp = _config.Client.GetMovieSimilarMovies(AGoodDayToDieHard).Result;
|
||||
Assert.IsNotNull(resp);
|
||||
|
||||
SearchContainer<MovieResult> respGerman = _config.Client.GetMovieSimilarMovies(AGoodDayToDieHard, language: "de");
|
||||
SearchContainer<MovieResult> respGerman = _config.Client.GetMovieSimilarMovies(AGoodDayToDieHard, language: "de").Result;
|
||||
Assert.IsNotNull(respGerman);
|
||||
|
||||
Assert.AreEqual(resp.Results.Count, respGerman.Results.Count);
|
||||
@ -228,7 +228,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestMoviesGetMovieReviews()
|
||||
{
|
||||
SearchContainer<Review> resp = _config.Client.GetMovieReviews(TheDarkKnightRises);
|
||||
SearchContainer<Review> resp = _config.Client.GetMovieReviews(TheDarkKnightRises).Result;
|
||||
Assert.IsNotNull(resp);
|
||||
|
||||
Assert.AreNotEqual(0, resp.Results.Count);
|
||||
@ -239,10 +239,10 @@ namespace TMDbLibTests
|
||||
public void TestMoviesGetMovieLists()
|
||||
{
|
||||
//GetMovieLists(int id, string language, int page = -1)
|
||||
SearchContainer<ListResult> resp = _config.Client.GetMovieLists(AGoodDayToDieHard);
|
||||
SearchContainer<ListResult> resp = _config.Client.GetMovieLists(AGoodDayToDieHard).Result;
|
||||
Assert.IsNotNull(resp);
|
||||
|
||||
SearchContainer<ListResult> respPage2 = _config.Client.GetMovieLists(AGoodDayToDieHard, 2);
|
||||
SearchContainer<ListResult> respPage2 = _config.Client.GetMovieLists(AGoodDayToDieHard, 2).Result;
|
||||
Assert.IsNotNull(respPage2);
|
||||
|
||||
Assert.AreEqual(1, resp.Page);
|
||||
@ -260,7 +260,7 @@ namespace TMDbLibTests
|
||||
// Fetch changelog
|
||||
DateTime lower = DateTime.UtcNow.AddDays(-13);
|
||||
DateTime higher = DateTime.UtcNow.AddDays(1);
|
||||
List<Change> respRange = _config.Client.GetMovieChanges(latestChanged, lower, higher);
|
||||
List<Change> respRange = _config.Client.GetMovieChanges(latestChanged, lower, higher).Result;
|
||||
|
||||
Assert.IsNotNull(respRange);
|
||||
Assert.IsTrue(respRange.Count > 0);
|
||||
@ -285,7 +285,7 @@ namespace TMDbLibTests
|
||||
_config.Client.GetConfig();
|
||||
|
||||
// Test image url generator
|
||||
ImagesWithId images = _config.Client.GetMovieImages(AGoodDayToDieHard);
|
||||
ImagesWithId images = _config.Client.GetMovieImages(AGoodDayToDieHard).Result;
|
||||
|
||||
Assert.AreEqual(AGoodDayToDieHard, images.Id);
|
||||
TestImagesHelpers.TestImages(_config, images);
|
||||
@ -297,19 +297,19 @@ namespace TMDbLibTests
|
||||
//GetMovieList(MovieListType type, string language, int page = -1)
|
||||
foreach (MovieListType type in Enum.GetValues(typeof(MovieListType)).OfType<MovieListType>())
|
||||
{
|
||||
SearchContainer<MovieResult> list = _config.Client.GetMovieList(type);
|
||||
SearchContainer<MovieResult> list = _config.Client.GetMovieList(type).Result;
|
||||
|
||||
Assert.IsNotNull(list);
|
||||
Assert.IsTrue(list.Results.Count > 0);
|
||||
Assert.AreEqual(1, list.Page);
|
||||
|
||||
SearchContainer<MovieResult> listPage2 = _config.Client.GetMovieList(type, 2);
|
||||
SearchContainer<MovieResult> listPage2 = _config.Client.GetMovieList(type, 2).Result;
|
||||
|
||||
Assert.IsNotNull(listPage2);
|
||||
Assert.IsTrue(listPage2.Results.Count > 0);
|
||||
Assert.AreEqual(2, listPage2.Page);
|
||||
|
||||
SearchContainer<MovieResult> listDe = _config.Client.GetMovieList(type, "de");
|
||||
SearchContainer<MovieResult> listDe = _config.Client.GetMovieList(type, "de").Result;
|
||||
|
||||
Assert.IsNotNull(listDe);
|
||||
Assert.IsTrue(listDe.Results.Count > 0);
|
||||
@ -324,7 +324,7 @@ namespace TMDbLibTests
|
||||
public void TestMoviesAccountStateRatingSet()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
MovieAccountState accountState = _config.Client.GetMovieAccountState(Avatar);
|
||||
MovieAccountState accountState = _config.Client.GetMovieAccountState(Avatar).Result;
|
||||
|
||||
// For this test to pass the movie Avatar need to be rated, added to the favorite list and watchlist
|
||||
Assert.AreEqual(Avatar, accountState.Id);
|
||||
@ -337,7 +337,7 @@ namespace TMDbLibTests
|
||||
public void TestMoviesAccountStateRatingNotSet()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
MovieAccountState accountState = _config.Client.GetMovieAccountState(AGoodDayToDieHard);
|
||||
MovieAccountState accountState = _config.Client.GetMovieAccountState(AGoodDayToDieHard).Result;
|
||||
|
||||
// For this test to pass the movie A Good Day To Die Hard need to be NOT rated, and REMOVED from the favorite list and watchlist
|
||||
Assert.AreEqual(AGoodDayToDieHard, accountState.Id);
|
||||
@ -351,21 +351,21 @@ namespace TMDbLibTests
|
||||
public void TestMoviesSetRatingBadRating()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
Assert.IsFalse(_config.Client.MovieSetRating(Avatar, 7.1));
|
||||
Assert.IsFalse(_config.Client.MovieSetRating(Avatar, 7.1).Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMoviesSetRatingRatingOutOfBounds()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
Assert.IsFalse(_config.Client.MovieSetRating(Avatar, 10.5));
|
||||
Assert.IsFalse(_config.Client.MovieSetRating(Avatar, 10.5).Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMoviesSetRatingRatingLowerBoundsTest()
|
||||
{
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
Assert.IsFalse(_config.Client.MovieSetRating(Avatar, 0));
|
||||
Assert.IsFalse(_config.Client.MovieSetRating(Avatar, 0).Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -374,29 +374,29 @@ namespace TMDbLibTests
|
||||
_config.Client.SetSessionInformation(_config.UserSessionId, SessionType.UserSession);
|
||||
|
||||
// Ensure that the test movie has a different rating than our test rating
|
||||
var rating = _config.Client.GetMovieAccountState(Avatar).Rating;
|
||||
var rating = _config.Client.GetMovieAccountState(Avatar).Result.Rating;
|
||||
Assert.IsNotNull(rating);
|
||||
|
||||
double originalRating = rating.Value;
|
||||
double newRating = Math.Abs(originalRating - 7.5) < double.Epsilon ? 2.5 : 7.5;
|
||||
|
||||
// Try changing the rating
|
||||
Assert.IsTrue(_config.Client.MovieSetRating(Avatar, newRating));
|
||||
Assert.IsTrue(_config.Client.MovieSetRating(Avatar, newRating).Result);
|
||||
|
||||
// Allow TMDb to not cache our data
|
||||
Thread.Sleep(1000);
|
||||
|
||||
// Check if it worked
|
||||
Assert.AreEqual(newRating, _config.Client.GetMovieAccountState(Avatar).Rating);
|
||||
Assert.AreEqual(newRating, _config.Client.GetMovieAccountState(Avatar).Result.Rating);
|
||||
|
||||
// Try changing it back to the previous rating
|
||||
Assert.IsTrue(_config.Client.MovieSetRating(Avatar, originalRating));
|
||||
Assert.IsTrue(_config.Client.MovieSetRating(Avatar, originalRating).Result);
|
||||
|
||||
// Allow TMDb to not cache our data
|
||||
Thread.Sleep(1000);
|
||||
|
||||
// Check if it worked
|
||||
Assert.AreEqual(originalRating, _config.Client.GetMovieAccountState(Avatar).Rating);
|
||||
Assert.AreEqual(originalRating, _config.Client.GetMovieAccountState(Avatar).Result.Rating);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@ -405,16 +405,16 @@ namespace TMDbLibTests
|
||||
// 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);
|
||||
// Try changing the rating
|
||||
Assert.IsTrue(_config.Client.MovieSetRating(Avatar, 7.5));
|
||||
Assert.IsTrue(_config.Client.MovieSetRating(Avatar, 7.5).Result);
|
||||
|
||||
// Try changing it back to the previous rating
|
||||
Assert.IsTrue(_config.Client.MovieSetRating(Avatar, 8));
|
||||
Assert.IsTrue(_config.Client.MovieSetRating(Avatar, 8).Result);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestMoviesGet()
|
||||
{
|
||||
Movie item = _config.Client.GetMovie(AGoodDayToDieHard);
|
||||
Movie item = _config.Client.GetMovie(AGoodDayToDieHard).Result;
|
||||
|
||||
Assert.IsNotNull(item);
|
||||
Assert.AreEqual(AGoodDayToDieHard, item.Id);
|
||||
|
@ -21,7 +21,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestNetworkGetById()
|
||||
{
|
||||
Network network = _config.Client.GetNetwork(Hbo);
|
||||
Network network = _config.Client.GetNetwork(Hbo).Result;
|
||||
|
||||
Assert.IsNotNull(network);
|
||||
Assert.AreEqual("HBO", network.Name);
|
||||
|
@ -42,7 +42,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestPersonsExtrasNone()
|
||||
{
|
||||
Person person = _config.Client.GetPerson(BruceWillis);
|
||||
Person person = _config.Client.GetPerson(BruceWillis).Result;
|
||||
|
||||
Assert.IsNotNull(person);
|
||||
|
||||
@ -59,14 +59,14 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestPersonsExtrasExclusive()
|
||||
{
|
||||
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetPerson(id, extras), BruceWillis);
|
||||
TestMethodsHelper.TestGetExclusive(_methods, (id, extras) => _config.Client.GetPerson(id, extras).Result, BruceWillis);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestPersonsExtrasAll()
|
||||
{
|
||||
PersonMethods combinedEnum = _methods.Keys.Aggregate((methods, movieMethods) => methods | movieMethods);
|
||||
Person item = _config.Client.GetPerson(BruceWillis, combinedEnum);
|
||||
Person item = _config.Client.GetPerson(BruceWillis, combinedEnum).Result;
|
||||
|
||||
TestMethodsHelper.TestAllNotNull(_methods, item);
|
||||
}
|
||||
@ -75,10 +75,10 @@ namespace TMDbLibTests
|
||||
public void TestPersonsGetPersonCredits()
|
||||
{
|
||||
//GetPersonCredits(int id, string language)
|
||||
Credits resp = _config.Client.GetPersonCredits(BruceWillis);
|
||||
Credits resp = _config.Client.GetPersonCredits(BruceWillis).Result;
|
||||
Assert.IsNotNull(resp);
|
||||
|
||||
Credits respItalian = _config.Client.GetPersonCredits(BruceWillis, "it");
|
||||
Credits respItalian = _config.Client.GetPersonCredits(BruceWillis, "it").Result;
|
||||
Assert.IsNotNull(respItalian);
|
||||
|
||||
Assert.AreEqual(resp.Cast.Count, respItalian.Cast.Count);
|
||||
@ -113,12 +113,12 @@ namespace TMDbLibTests
|
||||
{
|
||||
//GetPersonChanges(int id, DateTime? startDate = null, DateTime? endDate = null)
|
||||
// Find latest changed person
|
||||
int latestChanged = _config.Client.GetChangesPeople().Results.First().Id;
|
||||
int latestChanged = _config.Client.GetChangesPeople().Result.Results.First().Id;
|
||||
|
||||
// Fetch changelog
|
||||
DateTime lower = DateTime.UtcNow.AddDays(-14);
|
||||
DateTime higher = DateTime.UtcNow;
|
||||
List<Change> respRange = _config.Client.GetPersonChanges(latestChanged, lower, higher);
|
||||
List<Change> respRange = _config.Client.GetPersonChanges(latestChanged, lower, higher).Result;
|
||||
|
||||
Assert.IsNotNull(respRange);
|
||||
Assert.IsTrue(respRange.Count > 0);
|
||||
@ -143,7 +143,7 @@ namespace TMDbLibTests
|
||||
_config.Client.GetConfig();
|
||||
|
||||
// Test image url generator
|
||||
ProfileImages images = _config.Client.GetPersonImages(BruceWillis);
|
||||
ProfileImages images = _config.Client.GetPersonImages(BruceWillis).Result;
|
||||
|
||||
Assert.AreEqual(BruceWillis, images.Id);
|
||||
Assert.IsTrue(images.Profiles.Count > 0);
|
||||
@ -156,19 +156,19 @@ namespace TMDbLibTests
|
||||
{
|
||||
foreach (PersonListType type in Enum.GetValues(typeof(PersonListType)).OfType<PersonListType>())
|
||||
{
|
||||
SearchContainer<PersonResult> list = _config.Client.GetPersonList(type);
|
||||
SearchContainer<PersonResult> list = _config.Client.GetPersonList(type).Result;
|
||||
|
||||
Assert.IsNotNull(list);
|
||||
Assert.IsTrue(list.Results.Count > 0);
|
||||
Assert.AreEqual(1, list.Page);
|
||||
|
||||
SearchContainer<PersonResult> listPage2 = _config.Client.GetPersonList(type, 2);
|
||||
SearchContainer<PersonResult> listPage2 = _config.Client.GetPersonList(type, 2).Result;
|
||||
|
||||
Assert.IsNotNull(listPage2);
|
||||
Assert.IsTrue(listPage2.Results.Count > 0);
|
||||
Assert.AreEqual(2, listPage2.Page);
|
||||
|
||||
SearchContainer<PersonResult> list2 = _config.Client.GetPersonList(type);
|
||||
SearchContainer<PersonResult> list2 = _config.Client.GetPersonList(type).Result;
|
||||
|
||||
Assert.IsNotNull(list2);
|
||||
Assert.IsTrue(list2.Results.Count > 0);
|
||||
@ -184,7 +184,7 @@ namespace TMDbLibTests
|
||||
{
|
||||
foreach (PersonItemType type in Enum.GetValues(typeof(PersonItemType)).OfType<PersonItemType>())
|
||||
{
|
||||
Person item = _config.Client.GetPersonItem(type);
|
||||
Person item = _config.Client.GetPersonItem(type).Result;
|
||||
|
||||
Assert.IsNotNull(item);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestReviewFullDetails()
|
||||
{
|
||||
Review review = _config.Client.GetReview(TheDarkKnightRisesReviewId);
|
||||
Review review = _config.Client.GetReview(TheDarkKnightRisesReviewId).Result;
|
||||
|
||||
Assert.IsNotNull(review);
|
||||
|
||||
|
@ -24,11 +24,11 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestSearchMovie()
|
||||
{
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchMovie("007", i));
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchMovie("007", i).Result);
|
||||
|
||||
// Search pr. Year
|
||||
// 1962: First James Bond movie, "Dr. No"
|
||||
SearchContainer<SearchMovie> result = _config.Client.SearchMovie("007", year: 1962);
|
||||
SearchContainer<SearchMovie> result = _config.Client.SearchMovie("007", year: 1962).Result;
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.AreEqual(1, result.Page);
|
||||
@ -39,9 +39,9 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestSearchCollection()
|
||||
{
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchCollection("007", i));
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchCollection("007", i).Result);
|
||||
|
||||
SearchContainer<SearchResultCollection> result = _config.Client.SearchCollection("James Bond");
|
||||
SearchContainer<SearchResultCollection> result = _config.Client.SearchCollection("James Bond").Result;
|
||||
|
||||
Assert.IsTrue(result.Results.Any(s => s.Id == 645));
|
||||
Assert.IsTrue(result.Results.Any(s => s.Name == "James Bond Collection"));
|
||||
@ -50,9 +50,9 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestSearchPerson()
|
||||
{
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchPerson("Willis", i));
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchPerson("Willis", i).Result);
|
||||
|
||||
SearchContainer<SearchPerson> result = _config.Client.SearchPerson("Willis");
|
||||
SearchContainer<SearchPerson> result = _config.Client.SearchPerson("Willis").Result;
|
||||
|
||||
Assert.IsTrue(result.Results.Any(s => s.Id == 62));
|
||||
Assert.IsTrue(result.Results.Any(s => s.Name == "Bruce Willis"));
|
||||
@ -61,9 +61,9 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestSearchList()
|
||||
{
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchList("to watch", i));
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchList("to watch", i).Result);
|
||||
|
||||
SearchContainer<SearchList> result = _config.Client.SearchList("2013");
|
||||
SearchContainer<SearchList> result = _config.Client.SearchList("2013").Result;
|
||||
|
||||
Assert.IsTrue(result.Results.Any(s => s.Id == "50cbe90b19c2956de8047b4f"));
|
||||
Assert.IsTrue(result.Results.Any(s => s.Name == "Sci-Fi films to see in 2013"));
|
||||
@ -72,9 +72,9 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestSearchCompany()
|
||||
{
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchCompany("20th", i));
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchCompany("20th", i).Result);
|
||||
|
||||
SearchContainer<SearchCompany> result = _config.Client.SearchCompany("20th");
|
||||
SearchContainer<SearchCompany> result = _config.Client.SearchCompany("20th").Result;
|
||||
|
||||
Assert.IsTrue(result.Results.Any(s => s.Id == 25));
|
||||
Assert.IsTrue(result.Results.Any(s => s.Name == "20th Century Fox"));
|
||||
@ -83,9 +83,9 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestSearchKeyword()
|
||||
{
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchKeyword("plot", i));
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchKeyword("plot", i).Result);
|
||||
|
||||
SearchContainer<SearchKeyword> result = _config.Client.SearchKeyword("plot");
|
||||
SearchContainer<SearchKeyword> result = _config.Client.SearchKeyword("plot").Result;
|
||||
|
||||
Assert.IsTrue(result.Results.Any(s => s.Id == 11422));
|
||||
Assert.IsTrue(result.Results.Any(s => s.Name == "plot twist"));
|
||||
@ -94,9 +94,9 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestSearchTvShow()
|
||||
{
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchTvShow("Breaking Bad", i));
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchTvShow("Breaking Bad", i).Result);
|
||||
|
||||
SearchContainer<TvShowBase> result = _config.Client.SearchTvShow("Breaking Bad");
|
||||
SearchContainer<TvShowBase> result = _config.Client.SearchTvShow("Breaking Bad").Result;
|
||||
|
||||
Assert.IsTrue(result.Results.Any(s => s.Id == 1396));
|
||||
Assert.IsTrue(result.Results.Any(s => s.Name == "Breaking Bad"));
|
||||
@ -105,9 +105,9 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestSearchMulti()
|
||||
{
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchMulti("Arrow", i));
|
||||
TestHelpers.SearchPages(i => _config.Client.SearchMulti("Arrow", i).Result);
|
||||
|
||||
SearchContainer<SearchMulti> result = _config.Client.SearchMulti("Arrow");
|
||||
SearchContainer<SearchMulti> result = _config.Client.SearchMulti("Arrow").Result;
|
||||
Assert.IsTrue(result.Results.Any(s => s.Type == MediaType.TVShow && s.Name == "Arrow"));
|
||||
Assert.IsTrue(result.Results.Any(s => s.Type == MediaType.Movie && s.Name == "Broken Arrow"));
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestTvEpisodeSeparateExtrasCredits()
|
||||
{
|
||||
Credits credits = _config.Client.GetTvEpisodeCredits(BreakingBad, 1, 1);
|
||||
Credits credits = _config.Client.GetTvEpisodeCredits(BreakingBad, 1, 1).Result;
|
||||
Assert.IsNotNull(credits);
|
||||
Assert.IsNotNull(credits.Cast);
|
||||
Assert.AreEqual("Walter White", credits.Cast[0].Character);
|
||||
@ -63,7 +63,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestTvEpisodeSeparateExtrasExternalIds()
|
||||
{
|
||||
ExternalIds externalIds = _config.Client.GetTvEpisodeExternalIds(BreakingBad, 1, 1);
|
||||
ExternalIds externalIds = _config.Client.GetTvEpisodeExternalIds(BreakingBad, 1, 1).Result;
|
||||
Assert.IsNotNull(externalIds);
|
||||
Assert.IsTrue(string.IsNullOrEmpty(externalIds.FreebaseId));
|
||||
Assert.AreEqual(62085, externalIds.Id);
|
||||
@ -76,7 +76,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestTvEpisodeSeparateExtrasImages()
|
||||
{
|
||||
StillImages images = _config.Client.GetTvEpisodeImages(BreakingBad, 1, 1);
|
||||
StillImages images = _config.Client.GetTvEpisodeImages(BreakingBad, 1, 1).Result;
|
||||
Assert.IsNotNull(images);
|
||||
Assert.IsNotNull(images.Stills);
|
||||
}
|
||||
@ -84,7 +84,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestTvEpisodeExtrasNone()
|
||||
{
|
||||
TvEpisode tvEpisode = _config.Client.GetTvEpisode(BreakingBad, 1, 1);
|
||||
TvEpisode tvEpisode = _config.Client.GetTvEpisode(BreakingBad, 1, 1).Result;
|
||||
|
||||
TestBreakingBadSeasonOneEpisodeOneBaseProperties(tvEpisode);
|
||||
|
||||
@ -99,7 +99,7 @@ namespace TMDbLibTests
|
||||
public void TestTvSeasonExtrasAll()
|
||||
{
|
||||
TvEpisodeMethods combinedEnum = _methods.Keys.Aggregate((methods, tvEpisodeMethods) => methods | tvEpisodeMethods);
|
||||
TvEpisode tvEpisode = _config.Client.GetTvEpisode(BreakingBad, 1, 1, combinedEnum);
|
||||
TvEpisode tvEpisode = _config.Client.GetTvEpisode(BreakingBad, 1, 1, combinedEnum).Result;
|
||||
|
||||
TestBreakingBadSeasonOneEpisodeOneBaseProperties(tvEpisode);
|
||||
|
||||
|
@ -43,7 +43,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestTvShowSeparateExtrasCredits()
|
||||
{
|
||||
Credits credits = _config.Client.GetTvShowCredits(BreakingBad);
|
||||
Credits credits = _config.Client.GetTvShowCredits(BreakingBad).Result;
|
||||
Assert.IsNotNull(credits);
|
||||
Assert.IsNotNull(credits.Cast);
|
||||
Assert.AreEqual("Walter White", credits.Cast[0].Character);
|
||||
@ -68,7 +68,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestTvShowSeparateExtrasExternalIds()
|
||||
{
|
||||
ExternalIds externalIds = _config.Client.GetTvShowExternalIds(BreakingBad);
|
||||
ExternalIds externalIds = _config.Client.GetTvShowExternalIds(BreakingBad).Result;
|
||||
Assert.IsNotNull(externalIds);
|
||||
Assert.AreEqual(1396, externalIds.Id);
|
||||
Assert.AreEqual("/en/breaking_bad", externalIds.FreebaseId);
|
||||
@ -85,7 +85,7 @@ namespace TMDbLibTests
|
||||
var contentRatings = _config.Client.GetTvShowContentRatings(BreakingBad);
|
||||
Assert.IsNotNull(contentRatings);
|
||||
Assert.AreEqual(BreakingBad, contentRatings.Id);
|
||||
ContentRating contentRating = contentRatings.Results.FirstOrDefault(r => r.Iso_3166_1.Equals("US"));
|
||||
ContentRating contentRating = contentRatings.Result.Results.FirstOrDefault(r => r.Iso_3166_1.Equals("US"));
|
||||
Assert.IsNotNull(contentRating);
|
||||
Assert.AreEqual("TV-MA", contentRating.Rating);
|
||||
}
|
||||
@ -96,7 +96,7 @@ namespace TMDbLibTests
|
||||
var alternativeTitles = _config.Client.GetTvShowAlternativeTitles(BreakingBad);
|
||||
Assert.IsNotNull(alternativeTitles);
|
||||
Assert.AreEqual(BreakingBad, alternativeTitles.Id);
|
||||
AlternativeTitle alternativeTitle = alternativeTitles.Results.FirstOrDefault(r => r.Iso_3166_1.Equals("HU"));
|
||||
AlternativeTitle alternativeTitle = alternativeTitles.Result.Results.FirstOrDefault(r => r.Iso_3166_1.Equals("HU"));
|
||||
Assert.IsNotNull(alternativeTitle);
|
||||
Assert.AreEqual("Totál szívás", alternativeTitle.Title);
|
||||
}
|
||||
@ -107,7 +107,7 @@ namespace TMDbLibTests
|
||||
var keywords = _config.Client.GetTvShowKeywords(BreakingBad);
|
||||
Assert.IsNotNull(keywords);
|
||||
Assert.AreEqual(BreakingBad, keywords.Id);
|
||||
Keyword keyword = keywords.Results.FirstOrDefault(r => r.Id == 41525);
|
||||
Keyword keyword = keywords.Result.Results.FirstOrDefault(r => r.Id == 41525);
|
||||
Assert.IsNotNull(keyword);
|
||||
Assert.AreEqual("high school teacher", keyword.Name);
|
||||
}
|
||||
@ -115,7 +115,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestTvShowSeparateExtrasImages()
|
||||
{
|
||||
ImagesWithId images = _config.Client.GetTvShowImages(BreakingBad);
|
||||
ImagesWithId images = _config.Client.GetTvShowImages(BreakingBad).Result;
|
||||
Assert.IsNotNull(images);
|
||||
Assert.IsNotNull(images.Backdrops);
|
||||
Assert.IsNotNull(images.Posters);
|
||||
@ -124,7 +124,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestTvShowExtrasNone()
|
||||
{
|
||||
TvShow tvShow = _config.Client.GetTvShow(BreakingBad);
|
||||
TvShow tvShow = _config.Client.GetTvShow(BreakingBad).Result;
|
||||
|
||||
TestBreakingBadBaseProperties(tvShow);
|
||||
|
||||
@ -139,7 +139,7 @@ namespace TMDbLibTests
|
||||
public void TestTvShowExtrasAll()
|
||||
{
|
||||
TvShowMethods combinedEnum = _methods.Keys.Aggregate((methods, tvShowMethods) => methods | tvShowMethods);
|
||||
TvShow tvShow = _config.Client.GetTvShow(BreakingBad, combinedEnum);
|
||||
TvShow tvShow = _config.Client.GetTvShow(BreakingBad, combinedEnum).Result;
|
||||
|
||||
TestBreakingBadBaseProperties(tvShow);
|
||||
|
||||
@ -200,9 +200,9 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestTvShowPopular()
|
||||
{
|
||||
TestHelpers.SearchPages(i => _config.Client.GetTvShowsPopular(i));
|
||||
TestHelpers.SearchPages(i => _config.Client.GetTvShowsPopular(i).Result);
|
||||
|
||||
SearchContainer<TvShowBase> result = _config.Client.GetTvShowsPopular();
|
||||
SearchContainer<TvShowBase> result = _config.Client.GetTvShowsPopular().Result;
|
||||
Assert.IsNotNull(result.Results[0].Id);
|
||||
Assert.IsNotNull(result.Results[0].Name);
|
||||
Assert.IsNotNull(result.Results[0].OriginalName);
|
||||
@ -214,14 +214,14 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestTvShowSeasonCount()
|
||||
{
|
||||
TvShow tvShow = _config.Client.GetTvShow(1668);
|
||||
TvShow tvShow = _config.Client.GetTvShow(1668).Result;
|
||||
Assert.AreEqual(tvShow.Seasons[1].EpisodeCount, 24);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestTvShowVideos()
|
||||
{
|
||||
TvShow tvShow = _config.Client.GetTvShow(1668, TvShowMethods.Videos);
|
||||
TvShow tvShow = _config.Client.GetTvShow(1668, TvShowMethods.Videos).Result;
|
||||
Assert.IsNotNull(tvShow.Videos);
|
||||
Assert.IsNotNull(tvShow.Videos.Results);
|
||||
Assert.IsNotNull(tvShow.Videos.Results[0]);
|
||||
@ -232,7 +232,7 @@ namespace TMDbLibTests
|
||||
[TestMethod]
|
||||
public void TestTvShowSimilars()
|
||||
{
|
||||
TvShow tvShow = _config.Client.GetTvShow(1668, TvShowMethods.Similar);
|
||||
TvShow tvShow = _config.Client.GetTvShow(1668, TvShowMethods.Similar).Result;
|
||||
Assert.IsNotNull(tvShow.Similar);
|
||||
Assert.IsNotNull(tvShow.Similar.Results);
|
||||
Assert.IsNotNull(tvShow.Similar.Results[0]);
|
||||
@ -249,9 +249,9 @@ namespace TMDbLibTests
|
||||
// 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.
|
||||
// With so few ratings for TV shows right now it's set really low.
|
||||
TestHelpers.SearchPages(i => _config.Client.GetTvShowsTopRated(i));
|
||||
TestHelpers.SearchPages(i => _config.Client.GetTvShowsTopRated(i).Result);
|
||||
|
||||
SearchContainer<TvShowBase> result = _config.Client.GetTvShowsTopRated();
|
||||
SearchContainer<TvShowBase> result = _config.Client.GetTvShowsTopRated().Result;
|
||||
Assert.IsNotNull(result.Results[0].Id);
|
||||
Assert.IsNotNull(result.Results[0].Name);
|
||||
Assert.IsNotNull(result.Results[0].OriginalName);
|
||||
|
@ -14,9 +14,9 @@ namespace TMDbLibTests
|
||||
|
||||
public TMDbClient Client { get; set; }
|
||||
|
||||
public string Username = "";
|
||||
public string Username = "TMDbTestAccount";
|
||||
|
||||
public string Password = "";
|
||||
public string Password = "TJX6vP7bPC%!ZrJwAqtCU5FshHEKAwzr6YvR3%CU9s7BrjqUWmjC8AMuXju*eTEu524zsxDQK5ySY6EmjAC3e54B%WvkS9FNPE3K";
|
||||
|
||||
public TestConfig(bool useSsl = false)
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
|
||||
</startup>
|
||||
</configuration>
|
||||
|
@ -80,7 +80,7 @@ namespace TestApplication
|
||||
// Note: Each method normally corresponds to a property on the resulting object. If you haven't requested the information, the property will most likely be null.
|
||||
|
||||
// Also note, that while we could have used 'client.GetMovieImages()' - it was better to do it like this because we also wanted the Title of the movie.
|
||||
Movie movie = client.GetMovie(movieId, MovieMethods.Images);
|
||||
Movie movie = client.GetMovie(movieId, MovieMethods.Images).Result;
|
||||
|
||||
Console.WriteLine("Fetching images for '" + movie.Title + "'");
|
||||
|
||||
@ -125,7 +125,7 @@ namespace TestApplication
|
||||
|
||||
// This example shows the fetching of a movie.
|
||||
// Say the user searches for "Thor" in order to find "Thor: The Dark World" or "Thor"
|
||||
SearchContainer<SearchMovie> results = client.SearchMovie(query);
|
||||
SearchContainer<SearchMovie> results = client.SearchMovie(query).Result;
|
||||
|
||||
// The results is a list, currently on page 1 because we didn't specify any page.
|
||||
Console.WriteLine("Searched for movies: '" + query + "', found " + results.TotalResults + " results in " +
|
||||
|
@ -9,7 +9,7 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TestApplication</RootNamespace>
|
||||
<AssemblyName>TestApplication</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
@ -22,6 +22,7 @@
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@ -31,6 +32,7 @@
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
|
Loading…
Reference in New Issue
Block a user