public override async Task <bool> UpdateFromOnlineSeriesPersonAsync(SeriesInfo seriesInfo, PersonInfo person, string language, bool cacheOnly) { try { TvMazePerson personDetail = null; if (person.TvMazeId > 0) { personDetail = await _tvMazeHandler.GetPersonAsync(person.TvMazeId, cacheOnly).ConfigureAwait(false); } if (personDetail == null) { return(false); } person.TvMazeId = personDetail.Id; person.Name = personDetail.Name; if (!person.DataProviders.Contains(_name)) { person.DataProviders.Add(_name); } return(true); } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Debug("TvMazeWrapper: Exception while processing person {0}", ex, person.ToString()); return(false); } }
public override bool UpdateFromOnlineSeriesPerson(SeriesInfo seriesInfo, PersonInfo person, string language, bool cacheOnly) { try { TvMazePerson personDetail = null; if (person.TvMazeId > 0) { personDetail = _tvMazeHandler.GetPerson(person.TvMazeId, cacheOnly); } if (personDetail == null) { return(false); } person.TvMazeId = personDetail.Id; person.Name = personDetail.Name; return(true); } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Debug("TvMazeWrapper: Exception while processing person {0}", ex, person.ToString()); return(false); } }
protected async Task <ApiWrapperImageCollection <TvMazeImageCollection> > GetCharactorFanArtAsync(CharacterInfo character) { if (character == null || character.TvMazeId < 1) { return(null); } TvMazePerson personDetail = await _tvMazeHandler.GetCharacterAsync(character.TvMazeId, false).ConfigureAwait(false); if (personDetail == null) { return(null); } ApiWrapperImageCollection <TvMazeImageCollection> images = new ApiWrapperImageCollection <TvMazeImageCollection>(); images.Id = character.TvMazeId.ToString(); images.Thumbnails.Add(personDetail.Images); return(images); }
private async Task ProcessPersonAndCastInformation(int showId, IEnumerable <TvMazeCastModel> cast) { var tvMazePersonModelCollection = cast.Where(x => x.ShowId == showId) .Distinct(tvMazeCastModelEqualityComparer) .Select(x => x.Person); var showCast = await tvMazeShowCastRepository.GetByShowIdAsync(showId); foreach (var people in tvMazePersonModelCollection) { var person = await tvMazePersonRepository.GetByTvMazeIdAsync(people.Id); if (person == null) { person = new TvMazePerson { TvMazeId = people.Id, Name = people.Name, Birthday = people.Birthday }; await tvMazePersonRepository.AddAsync(person); } var personInCast = showCast.FirstOrDefault(x => x.TvMazePersonId == people.Id); if (personInCast == null) { personInCast = new TvMazeShowCast { TvMazePersonId = person.TvMazeId, TvMazeShowId = showId }; await tvMazeShowCastRepository.AddAsync(personInCast); } } }
public override bool GetFanArt <T>(T infoObject, string language, string fanartMediaType, out ApiWrapperImageCollection <TvMazeImageCollection> images) { images = new ApiWrapperImageCollection <TvMazeImageCollection>(); try { if (fanartMediaType == FanArtMediaTypes.Series) { EpisodeInfo episode = infoObject as EpisodeInfo; SeasonInfo season = infoObject as SeasonInfo; SeriesInfo series = infoObject as SeriesInfo; if (series == null && season != null) { series = season.CloneBasicInstance <SeriesInfo>(); } if (series == null && episode != null) { series = episode.CloneBasicInstance <SeriesInfo>(); } if (series != null && series.TvMazeId > 0) { // Download all image information, filter later! TvMazeSeries seriesDetail = _tvMazeHandler.GetSeries(series.TvMazeId, false); if (seriesDetail != null) { images.Id = series.TvMazeId.ToString(); images.Posters.Add(seriesDetail.Images); return(true); } } } else if (fanartMediaType == FanArtMediaTypes.Episode) { EpisodeInfo episode = infoObject as EpisodeInfo; if (episode != null && episode.SeriesTvMazeId > 0 && episode.SeasonNumber.HasValue && episode.EpisodeNumbers.Count > 0) { // Download all image information, filter later! TvMazeEpisode episodeDetail = _tvMazeHandler.GetSeriesEpisode(episode.SeriesTvMazeId, episode.SeasonNumber.Value, episode.FirstEpisodeNumber, false); if (episodeDetail != null) { images.Id = episode.SeriesTvMazeId.ToString(); images.Thumbnails.Add(episodeDetail.Images); return(true); } } } else if (fanartMediaType == FanArtMediaTypes.Actor) { PersonInfo person = infoObject as PersonInfo; if (person != null && person.TvMazeId > 0) { // Download all image information, filter later! TvMazePerson personDetail = _tvMazeHandler.GetPerson(person.TvMazeId, false); if (personDetail != null) { images.Id = person.TvMazeId.ToString(); images.Thumbnails.Add(personDetail.Images); return(true); } } } else if (fanartMediaType == FanArtMediaTypes.Character) { CharacterInfo character = infoObject as CharacterInfo; if (character != null && character.TvMazeId > 0) { // Download all image information, filter later! TvMazePerson personDetail = _tvMazeHandler.GetCharacter(character.TvMazeId, false); if (personDetail != null) { images.Id = character.TvMazeId.ToString(); images.Thumbnails.Add(personDetail.Images); return(true); } } } else { return(true); } } catch (Exception ex) { ServiceRegistration.Get <ILogger>().Debug(GetType().Name + ": Exception downloading images", ex); } return(false); }