Ejemplo n.º 1
0
        private async Task <MetadataResult <BoxSet> > GetShokoGroupedMetadata(BoxSetInfo info, CancellationToken cancellationToken)
        {
            var result = new MetadataResult <BoxSet>();
            var config = Plugin.Instance.Configuration;

            Ordering.GroupFilterType filterByType = config.FilterOnLibraryTypes ? Ordering.GroupFilterType.Movies : Ordering.GroupFilterType.Default;
            var group = await ApiManager.GetGroupInfoByPath(info.Path, filterByType);

            if (group == null)
            {
                Logger.LogWarning($"Unable to find box-set info for path {info.Path}");
                return(result);
            }

            var series = group.DefaultSeries;

            if (series.AniDB.Type != API.Models.SeriesType.Movie)
            {
                Logger.LogWarning($"File found, but not a movie! Skipping.");
                return(result);
            }

            var tags = await ApiManager.GetTags(series.Id);

            var(displayTitle, alternateTitle) = Text.GetSeriesTitles(series.AniDB.Titles, series.Shoko.Name, info.MetadataLanguage);

            result.Item = new BoxSet {
                Name            = displayTitle,
                OriginalTitle   = alternateTitle,
                Overview        = Text.SanitizeTextSummary(series.AniDB.Description),
                PremiereDate    = series.AniDB.AirDate,
                EndDate         = series.AniDB.EndDate,
                ProductionYear  = series.AniDB.AirDate?.Year,
                Tags            = tags,
                CommunityRating = (float)((series.AniDB.Rating.Value * 10) / series.AniDB.Rating.MaxValue)
            };
            result.Item.SetProviderId("Shoko Series", series.Id);
            result.Item.SetProviderId("Shoko Group", group.Id);
            if (config.AddAniDBId)
            {
                result.Item.SetProviderId("AniDB", series.AniDB.ID.ToString());
            }

            result.HasMetadata = true;
            ApiManager.MarkSeriesAsFound(series.Id, group.Id);

            result.ResetPeople();
            foreach (var person in await ApiManager.GetPeople(series.Id))
            {
                result.AddPerson(person);
            }

            return(result);
        }
Ejemplo n.º 2
0
        private async Task <MetadataResult <Series> > GetShokoGroupedMetadata(SeriesInfo info, CancellationToken cancellationToken)
        {
            var result        = new MetadataResult <Series>();
            var filterLibrary = Plugin.Instance.Configuration.FilterOnLibraryTypes;
            var group         = await ApiManager.GetGroupInfoByPath(info.Path, filterLibrary?Ordering.GroupFilterType.Others : Ordering.GroupFilterType.Default);

            if (group == null)
            {
                Logger.LogWarning($"Unable to find series info for path {info.Path}");
                return(result);
            }
            Logger.LogInformation($"Found series info for path {info.Path}");

            var series = group.DefaultSeries;

            var tags = await ApiManager.GetTags(series.Id);

            var(displayTitle, alternateTitle) = Text.GetSeriesTitles(series.AniDB.Titles, series.Shoko.Name, info.MetadataLanguage);

            result.Item = new Series {
                Name            = displayTitle,
                OriginalTitle   = alternateTitle,
                Overview        = Text.SanitizeTextSummary(series.AniDB.Description),
                PremiereDate    = series.AniDB.AirDate,
                EndDate         = series.AniDB.EndDate,
                ProductionYear  = series.AniDB.AirDate?.Year,
                Status          = series.AniDB.EndDate == null ? SeriesStatus.Continuing : SeriesStatus.Ended,
                Tags            = tags,
                CommunityRating = series.AniDB.Rating.ToFloat(10),
            };
            // NOTE: This next line will remain here till they fix the series merging for providers outside the MetadataProvider enum.
            result.Item.SetProviderId(MetadataProvider.Imdb, $"INVALID-BUT-DO-NOT-TOUCH:{series.Id}");
            result.Item.SetProviderId("Shoko Series", series.Id);
            result.Item.SetProviderId("Shoko Group", group.Id);
            if (Plugin.Instance.Configuration.AddAniDBId)
            {
                result.Item.SetProviderId("AniDB", series.AniDB.ID.ToString());
            }

            result.HasMetadata = true;
            ApiManager.MarkSeriesAsFound(series.Id, group.Id);

            result.ResetPeople();
            foreach (var person in await ApiManager.GetPeople(series.Id))
            {
                result.AddPerson(person);
            }

            return(result);
        }