public async Task <IEnumerable <RemoteSearchResult> > GetSearchResults(EpisodeInfo searchInfo, CancellationToken cancellationToken) { var list = new List <RemoteSearchResult>(); var id = AniDbEpisodeIdentity.Parse(searchInfo.ProviderIds.GetOrDefault(ProviderNames.AniDb)); if (id == null) { return(list); } await AniDbSeriesProvider.GetSeriesData( _configurationManager.ApplicationPaths, id.Value.SeriesId, cancellationToken).ConfigureAwait(false); try { var metadataResult = await GetMetadata(searchInfo, cancellationToken).ConfigureAwait(false); if (metadataResult.HasMetadata) { var item = metadataResult.Item; list.Add(new RemoteSearchResult { IndexNumber = item.IndexNumber, Name = item.Name, ParentIndexNumber = item.ParentIndexNumber, PremiereDate = item.PremiereDate, ProductionYear = item.ProductionYear, ProviderIds = item.ProviderIds, SearchProviderName = Name, IndexNumberEnd = item.IndexNumberEnd }); } } catch (FileNotFoundException) { // Don't fail the provider because this will just keep on going and going. } catch (DirectoryNotFoundException) { // Don't fail the provider because this will just keep on going and going. } return(list); }
public Task <IEnumerable <RemoteImageInfo> > GetImages(BaseItem item, CancellationToken cancellationToken) { var infos = new List <RemoteImageInfo>(); var person = AniDbSeriesProvider.GetPersonInfo(_paths.CachePath, item.Name); if (person != null) { infos.Add(new RemoteImageInfo { Url = person.Image, Type = ImageType.Primary, ProviderName = Name }); } return(Task.FromResult <IEnumerable <RemoteImageInfo> >(infos)); }
public Task <MetadataResult <Person> > GetMetadata(PersonLookupInfo info, CancellationToken cancellationToken) { var result = new MetadataResult <Person>(); if (!string.IsNullOrEmpty(info.ProviderIds.GetOrDefault(ProviderNames.AniDb))) { return(Task.FromResult(result)); } var person = AniDbSeriesProvider.GetPersonInfo(_paths.CachePath, info.Name); if (!string.IsNullOrEmpty(person?.Id)) { result.Item = new Person(); result.HasMetadata = true; result.Item.SetProviderId(ProviderNames.AniDb, person.Id); } return(Task.FromResult(result)); }
public async Task <IEnumerable <RemoteImageInfo> > GetImages(string aniDbId, CancellationToken cancellationToken) { var list = new List <RemoteImageInfo>(); if (!string.IsNullOrEmpty(aniDbId)) { var seriesDataPath = await AniDbSeriesProvider.GetSeriesData(_appPaths, aniDbId, cancellationToken); var imageUrl = await FindImageUrl(seriesDataPath).ConfigureAwait(false); if (!string.IsNullOrEmpty(imageUrl)) { list.Add(new RemoteImageInfo { ProviderName = Name, Url = imageUrl }); } } return(list); }
public AniDbSeasonProvider(IApplicationPaths appPaths) { _seriesProvider = new AniDbSeriesProvider(appPaths); }
public AniDbMovieProvider(IApplicationPaths appPaths, ILogger <AniDbMovieProvider> logger) { _seriesProvider = new AniDbSeriesProvider(appPaths); _logger = logger; }
private async Task <string> FindSeriesFolder(string seriesId, CancellationToken cancellationToken) { var seriesDataPath = await AniDbSeriesProvider.GetSeriesData(_configurationManager.ApplicationPaths, seriesId, cancellationToken).ConfigureAwait(false); return(Path.GetDirectoryName(seriesDataPath)); }
private async Task ParseEpisodeXml(FileInfo xml, Episode episode, string preferredMetadataLanguage) { var settings = new XmlReaderSettings { Async = true, CheckCharacters = false, IgnoreProcessingInstructions = true, IgnoreComments = true, ValidationType = ValidationType.None }; using (var streamReader = xml.OpenText()) using (var reader = XmlReader.Create(streamReader, settings)) { await reader.MoveToContentAsync().ConfigureAwait(false); var titles = new List <Title>(); while (await reader.ReadAsync().ConfigureAwait(false)) { if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "length": var length = await reader.ReadElementContentAsStringAsync().ConfigureAwait(false); if (!string.IsNullOrEmpty(length)) { long duration; if (long.TryParse(length, out duration)) { episode.RunTimeTicks = TimeSpan.FromMinutes(duration).Ticks; } } break; case "airdate": var airdate = await reader.ReadElementContentAsStringAsync().ConfigureAwait(false); if (!string.IsNullOrEmpty(airdate)) { DateTime date; if (DateTime.TryParse(airdate, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out date)) { episode.PremiereDate = date; } } break; case "rating": int count; float rating; if (int.TryParse(reader.GetAttribute("count"), NumberStyles.Any, CultureInfo.InvariantCulture, out count) && float.TryParse(reader.ReadElementContentAsString(), NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out rating)) { episode.CommunityRating = rating; } break; case "title": var language = reader.GetAttribute("xml:lang"); var name = reader.ReadElementContentAsString(); titles.Add(new Title { Language = language, Type = "main", Name = name }); break; case "summary": var overview = AniDbSeriesProvider.ReplaceNewLine(reader.ReadElementContentAsString()); episode.Overview = Plugin.Instance.Configuration.AniDbReplaceGraves ? overview.Replace('`', '\'') : overview; break; } } } var title = titles.Localize(Configuration.TitlePreferenceType.Localized, preferredMetadataLanguage).Name; if (!string.IsNullOrEmpty(title)) { episode.Name = Plugin.Instance.Configuration.AniDbReplaceGraves ? title.Replace('`', '\'') : title; } } }