private async Task <MetadataResult <Season> > GetShokoGroupedMetadata(SeasonInfo info, CancellationToken cancellationToken) { var result = new MetadataResult <Season>(); if (!info.SeriesProviderIds.ContainsKey("Shoko Group")) { Logger.LogWarning($"Shoko Group id not stored for series"); return(result); } var groupId = info.SeriesProviderIds["Shoko Group"]; var seasonNumber = info.IndexNumber ?? 1; var filterLibrary = Plugin.Instance.Configuration.FilterOnLibraryTypes; var series = await ApiManager.GetSeriesInfoFromGroup(groupId, seasonNumber, filterLibrary?Ordering.GroupFilterType.Others : Ordering.GroupFilterType.Default); if (series == null) { Logger.LogWarning($"Unable to find series info for G{groupId}:S{seasonNumber}"); return(result); } Logger.LogInformation($"Found series info for G{groupId}:S{seasonNumber}"); var tags = await ApiManager.GetTags(series.Id); var(displayTitle, alternateTitle) = Text.GetSeriesTitles(series.AniDB.Titles, series.Shoko.Name, info.MetadataLanguage); result.Item = new Season { Name = displayTitle, OriginalTitle = alternateTitle, IndexNumber = seasonNumber, Overview = Text.SanitizeTextSummary(series.AniDB.Description), PremiereDate = series.AniDB.AirDate, EndDate = series.AniDB.EndDate, ProductionYear = series.AniDB.AirDate?.Year, Tags = tags, CommunityRating = series.AniDB.Rating?.ToFloat(10), }; result.Item.ProviderIds.Add("Shoko Series", series.Id); if (Plugin.Instance.Configuration.AddAniDBId) { result.Item.ProviderIds.Add("AniDB", series.AniDB.ID.ToString()); } result.HasMetadata = true; ApiManager.MarkSeriesAsFound(series.Id, groupId); result.ResetPeople(); foreach (var person in await ApiManager.GetPeople(series.Id)) { result.AddPerson(person); } return(result); }
public async Task <IEnumerable <RemoteImageInfo> > GetImages(BaseItem item, CancellationToken cancellationToken) { var list = new List <RemoteImageInfo>(); try { Shokofin.API.Info.EpisodeInfo episode = null; Shokofin.API.Info.SeriesInfo series = null; if (item is Episode) { episode = await ApiManager.GetEpisodeInfo(item.GetProviderId("Shoko Episode")); } else if (item is Series) { var groupId = item.GetProviderId("Shoko Group"); if (string.IsNullOrEmpty(groupId)) { series = await ApiManager.GetSeriesInfo(item.GetProviderId("Shoko Series")); } else { series = (await ApiManager.GetGroupInfo(groupId))?.DefaultSeries; } } else if (item is BoxSet || item is Movie) { series = await ApiManager.GetSeriesInfo(item.GetProviderId("Shoko Series")); } else if (item is Season) { series = await ApiManager.GetSeriesInfoFromGroup(item.GetParent()?.GetProviderId("Shoko Group"), item.IndexNumber ?? 1); } if (episode != null) { Logger.LogInformation($"Getting episode images ({episode.Id} - {item.Name})"); AddImage(ref list, ImageType.Primary, episode?.TvDB?.Thumbnail); } if (series != null) { Logger.LogInformation($"Getting series images ({series.Id} - {item.Name})"); var images = series.Shoko.Images; AddImage(ref list, ImageType.Primary, series.AniDB.Poster); foreach (var image in images?.Posters) { AddImage(ref list, ImageType.Primary, image); } foreach (var image in images?.Fanarts) { AddImage(ref list, ImageType.Backdrop, image); } foreach (var image in images?.Banners) { AddImage(ref list, ImageType.Banner, image); } } Logger.LogInformation($"List got {list.Count} item(s)."); return(list); } catch (Exception e) { Logger.LogError(e, $"Threw unexpectedly; {e.Message}"); return(list); } }