public void TestPersonsExtrasAll() { PersonMethods combinedEnum = _methods.Keys.Aggregate((methods, movieMethods) => methods | movieMethods); Person item = _config.Client.GetPerson(BruceWillis, combinedEnum); TestMethodsHelper.TestAllNotNull(_methods, item); }
public async Task UpdatePersonAsync(PersonContainer container, CancellationToken cancellationToken) { PersonMethods methods = PersonMethods.MovieCredits | PersonMethods.TvCredits | PersonMethods.Images | PersonMethods.ExternalIds | PersonMethods.Translations; Person tmdbResult = await TMDbClient.GetPersonAsync(container.Id, methods, cancellationToken); container.Item = tmdbResult; People.Update(container); }
public void TestPersonsExtrasAll() { IgnoreMissingJson("external_ids / id", "images / id", "movie_credits / id", "tv_credits / id"); PersonMethods combinedEnum = _methods.Keys.Aggregate((methods, movieMethods) => methods | movieMethods); Person item = Config.Client.GetPersonAsync(IdHelper.BruceWillis, combinedEnum).Result; TestMethodsHelper.TestAllNotNull(_methods, item); }
public async Task <Person> GetPersonAsync(int personId, string language, PersonMethods extraMethods = PersonMethods.Undefined, CancellationToken cancellationToken = default(CancellationToken)) { RestRequest req = _client.Create("person/{personId}"); req.AddUrlSegment("personId", personId.ToString()); if (language != null) { req.AddParameter("language", language); } string appends = string.Join(",", Enum.GetValues(typeof(PersonMethods)) .OfType <PersonMethods>() .Except(new[] { PersonMethods.Undefined }) .Where(s => extraMethods.HasFlag(s)) .Select(s => s.GetDescription())); if (appends != string.Empty) { req.AddParameter("append_to_response", appends); } // TODO: Dateformat? //req.DateFormat = "yyyy-MM-dd"; RestResponse <Person> response = await req.ExecuteGet <Person>(cancellationToken).ConfigureAwait(false); if (!response.IsValid) { return(null); } Person item = await response.GetDataObject().ConfigureAwait(false); // Patch up data, so that the end user won't notice that we share objects between request-types. if (item != null) { if (item.Images != null) { item.Images.Id = item.Id; } if (item.TvCredits != null) { item.TvCredits.Id = item.Id; } if (item.MovieCredits != null) { item.MovieCredits.Id = item.Id; } } return(item); }
public async Task <PersonContainer> GetPersonAsync(int personId, CancellationToken cancellationToken) { PersonContainer container = People.FindById(personId); if (container != null) { return(container); } PersonMethods methods = PersonMethods.MovieCredits | PersonMethods.TvCredits | PersonMethods.Images | PersonMethods.ExternalIds | PersonMethods.Translations; Person tmdbResult = await TMDbClient.GetPersonAsync(personId, methods, cancellationToken); container = new PersonContainer(tmdbResult); return(container); }
public async Task <Person> GetPersonAsync(int personId, PersonMethods extraMethods = PersonMethods.Undefined, CancellationToken cancellationToken = default(CancellationToken)) { var result = await GetPersonAsync(personId, DefaultLanguage, extraMethods, cancellationToken); if (!string.IsNullOrWhiteSpace(result.Biography)) { return(await GetPersonAsync(personId, DefaultLanguage, extraMethods, cancellationToken)); } return(await GetPersonAsync(personId, "english", extraMethods, cancellationToken)); //return await GetPersonAsync(personId, DefaultLanguage, extraMethods, cancellationToken); }
public ViewResult Details(string Slug) { var person = _context.Persons.Include(mc => mc.FilmItemCredits).ThenInclude(c => c.FilmItem) .Include(m => m.Media) .FirstOrDefault(p => p.Slug == Slug); var user = _userManager.GetUserId(User); PersonDetailsViewModel personDetailsViewModel = new PersonDetailsViewModel { Person = person, FilmItemId = PersonMethods.GetRandomBackground(person), Age = PersonMethods.CalculatePersonAge(person), PersonWatchedByUser = PersonMethods.GetUserStats(_context, person, user), PartTypes = Enum.GetValues(typeof(PartType)) }; return(View(personDetailsViewModel)); }
private 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}"); req.AddUrlSegment("personId", personId.ToString()); req.AddUrlSegment("method", personMethod.GetDescription()); if (dateFormat != null) { req.DateFormat = dateFormat; } if (country != null) { req.AddParameter("country", country); } language = language ?? DefaultLanguage; if (!String.IsNullOrWhiteSpace(language)) { req.AddParameter("language", language); } if (page >= 1) { req.AddParameter("page", page); } if (startDate.HasValue) { req.AddParameter("startDate", startDate.Value.ToString("yyyy-MM-dd")); } if (endDate != null) { req.AddParameter("endDate", endDate.Value.ToString("yyyy-MM-dd")); } IRestResponse <T> resp = _client.Get <T>(req); return(resp.Data); }
private async Task <T> GetPersonMethodInternal <T>(int personId, PersonMethods personMethod, string dateFormat = null, string country = null, string language = null, int page = 0, DateTime?startDate = null, DateTime?endDate = null, CancellationToken cancellationToken = default) where T : new() { RestRequest req = _client.Create("person/{personId}/{method}"); req.AddUrlSegment("personId", personId.ToString()); req.AddUrlSegment("method", personMethod.GetDescription()); // TODO: Dateformat? //if (dateFormat != null) // req.DateFormat = dateFormat; if (country != null) { req.AddParameter("country", country); } language ??= DefaultLanguage; if (!string.IsNullOrWhiteSpace(language)) { req.AddParameter("language", language); } if (page >= 1) { req.AddParameter("page", page.ToString()); } if (startDate.HasValue) { req.AddParameter("startDate", startDate.Value.ToString("yyyy-MM-dd")); } if (endDate != null) { req.AddParameter("endDate", endDate.Value.ToString("yyyy-MM-dd")); } T resp = await req.GetOfT <T>(cancellationToken).ConfigureAwait(false); return(resp); }
public Person GetPerson(int personId, PersonMethods extraMethods = PersonMethods.Undefined) { RestRequest req = new RestRequest("person/{personId}"); req.AddUrlSegment("personId", personId.ToString()); string appends = string.Join(",", Enum.GetValues(typeof(PersonMethods)) .OfType <PersonMethods>() .Except(new[] { PersonMethods.Undefined }) .Where(s => extraMethods.HasFlag(s)) .Select(s => s.GetDescription())); if (appends != string.Empty) { req.AddParameter("append_to_response", appends); } req.DateFormat = "yyyy-MM-dd"; IRestResponse <Person> resp = _client.Get <Person>(req); // Patch up data, so that the end user won't notice that we share objects between request-types. if (resp.Data != null) { if (resp.Data.Images != null) { resp.Data.Images.Id = resp.Data.Id; } if (resp.Data.Credits != null) { resp.Data.Credits.Id = resp.Data.Id; } } return(resp.Data); }
public Task <Person> GetPersonAsync(int personId, PersonMethods extraMethods = PersonMethods.Undefined, CancellationToken cancellationToken = default) { base.Track(); return(tmdbClient.GetPersonAsync(personId, extraMethods, cancellationToken)); }
public async Task <Person> GetPersonAsync(int personId, PersonMethods extraMethods = PersonMethods.Undefined, CancellationToken cancellationToken = default(CancellationToken)) { return(await GetPersonAsync(personId, DefaultLanguage, extraMethods, cancellationToken)); }
public async Task <Person> GetPersonAsync(int personId, PersonMethods extraMethods = PersonMethods.Undefined, CancellationToken cancellationToken = default) { return(await TMDbServiceClient.Instance.GetPersonAsync(personId, extraMethods, cancellationToken)); }