Esempio n. 1
0
        public override async Task <bool> UpdateFromOnlineMoviePersonAsync(MovieInfo movieInfo, PersonInfo person, string language, bool cacheOnly)
        {
            try
            {
                language = language ?? PreferredLanguage;

                SimApiPerson personDetail = null;
                if (!string.IsNullOrEmpty(person.ImdbId))
                {
                    personDetail = await _simApiHandler.GetPersonAsync(person.ImdbId, cacheOnly).ConfigureAwait(false);
                }
                if (personDetail == null)
                {
                    return(false);
                }

                person.ImdbId      = personDetail.ImdbID;
                person.Name        = personDetail.Name;
                person.DateOfBirth = personDetail.BirthYear.HasValue ? (DateTime?)new DateTime(personDetail.BirthYear.Value, 1, 1) : null;
                person.Orign       = personDetail.BirthPlace;

                return(true);
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Debug("TheMovieDbWrapper: Exception while processing person {0}", ex, person.ToString());
                return(false);
            }
        }
Esempio n. 2
0
        protected async Task <ApiWrapperImageCollection <string> > GetPersonFanArtAsync(PersonInfo person)
        {
            if (person == null || string.IsNullOrEmpty(person.ImdbId))
            {
                return(null);
            }
            SimApiPerson personDetail = await _simApiHandler.GetPersonAsync(person.ImdbId, false).ConfigureAwait(false);

            if (personDetail == null || string.IsNullOrEmpty(personDetail.ImageUrl))
            {
                return(null);
            }
            ApiWrapperImageCollection <string> images = new ApiWrapperImageCollection <string>();

            images.Id = person.ImdbId;
            images.Posters.Add(personDetail.ImageUrl);
            return(images);
        }
Esempio n. 3
0
        /// <summary>
        /// Returns detailed information for a single <see cref="SimApiPerson"/> with given <paramref name="id"/>. This method caches request
        /// to same person using the cache path given in <see cref="SimApiV1"/> constructor.
        /// </summary>
        /// <param name="id">IMDB id of series</param>
        /// <returns>Person information</returns>
        public async Task <SimApiPerson> GetPersonAsync(string id, bool cacheOnly)
        {
            string       cache       = CreateAndGetCacheName(id, "Person");
            SimApiPerson returnValue = null;

            if (!string.IsNullOrEmpty(cache) && File.Exists(cache))
            {
                returnValue = await _downloader.ReadCacheAsync <SimApiPerson>(cache).ConfigureAwait(false);
            }
            else
            {
                if (cacheOnly)
                {
                    return(null);
                }
                string url = GetUrl(URL_GETIMDBIDPERSON, id.StartsWith("nm", System.StringComparison.InvariantCultureIgnoreCase) ? id.Substring(2) : id);
                returnValue = await _downloader.DownloadAsync <SimApiPerson>(url, cache).ConfigureAwait(false);
            }
            if (returnValue == null)
            {
                return(null);
            }
            return(returnValue);
        }