コード例 #1
0
        public static Task <WebIntResult> ProcessAsync(IOwinContext context, string filter)
        {
            ISet <Guid> necessaryMIATypes = new HashSet <Guid>();

            necessaryMIATypes.Add(MediaAspect.ASPECT_ID);
            necessaryMIATypes.Add(SeriesAspect.ASPECT_ID);

            var output = new List <WebTVShowBasic>();

            IList <MediaItem> items = MediaLibraryAccess.GetMediaItemsByAspect(context, necessaryMIATypes, null);

            if (items.Count == 0)
            {
                return(System.Threading.Tasks.Task.FromResult(new WebIntResult {
                    Result = output.Count
                }));
            }

            foreach (var item in items)
            {
                var            seriesAspect   = item.GetAspect(SeriesAspect.Metadata);
                WebTVShowBasic webTVShowBasic = new WebTVShowBasic();
                webTVShowBasic.Title = (string)seriesAspect[SeriesAspect.ATTR_SERIES_NAME];

                output.Add(webTVShowBasic);
            }

            // Filter
            output = output.Filter(filter).ToList();
            return(System.Threading.Tasks.Task.FromResult(new WebIntResult {
                Result = output.Count
            }));
        }
コード例 #2
0
        /// <summary>
        /// Dynamically discover sub-categories for a given parent category
        /// </summary>
        /// <param name="parentCategory">parent category</param>
        /// <returns>Count of sub-categories</returns>
        public override int DiscoverSubCategories(Category parentCategory)
        {
            parentCategory.SubCategories = new List <Category>();
            String url = ((RssLink)parentCategory).Url;

            if (url.Equals("series"))
            {
                WebBackendProvider provider = (WebBackendProvider)parentCategory.Other;
                if (((RssLink)parentCategory).Url.Equals("series"))
                {
                    GetSeries(parentCategory, provider);
                }
            }
            else if (url.Equals("tvshow"))
            {
                WebTVShowBasic series = (WebTVShowBasic)parentCategory.Other;
                GetSeasons(parentCategory, series);
            }
            else if (url.Equals("tv"))
            {
                GetTvGroups(parentCategory);
            }

            parentCategory.SubCategoriesDiscovered = true;
            return(parentCategory.SubCategories.Count);
        }
コード例 #3
0
        private void GetSeasons(Category parentCategory, WebTVShowBasic series)
        {
            WebTVSeasonDetailed[] seasons = mediaAccess.GetTVSeasonsDetailedForTVShow(series.PID, true, series.Id, MpExtendedService.WebSortField.TVSeasonNumber, true, MpExtendedService.WebSortOrder.Asc, true);

            foreach (WebTVSeasonDetailed s in seasons)
            {
                RssLink cat = new RssLink();
                cat.Name                = "Season " + s.SeasonNumber;
                cat.Description         = s.YearSpecified && s.Year > 0 ? string.Format("{0}: {1}", Translation.Instance.DateOfRelease, s.Year) : "";
                cat.EstimatedVideoCount = s.EpisodeCountSpecified ? (uint?)s.EpisodeCount : null;
                if (s.Artwork.Any(a => a.Type == MpExtendedService.WebFileType.Banner))
                {
                    cat.Thumb = String.Format("http://{0}:{1}/MPExtended/StreamingService/stream/GetArtworkResized?id={2}&provider={3}&artworktype=2&offset=0&mediatype=6&maxWidth=160&maxHeight=160", mServer, mPort, s.Id, s.PID);
                }
                cat.Url = "tvseason";
                cat.HasSubCategories = false;
                cat.Other            = s;
                parentCategory.SubCategories.Add(cat);
                cat.ParentCategory = parentCategory;
            }
        }
コード例 #4
0
        private void GetSeasons(Category parentCategory, WebTVShowBasic series)
        {
            WebTVSeasonDetailed[] seasons = mediaAccess.GetTVSeasonsDetailedForTVShow(series.PID, true, series.Id, MpExtendedService.WebSortField.TVSeasonNumber, true, MpExtendedService.WebSortOrder.Asc, true);

            foreach (WebTVSeasonDetailed s in seasons)
            {
                RssLink cat = new RssLink();
                cat.Name = "Season " + s.SeasonNumber;
				cat.Description = s.YearSpecified && s.Year > 0 ? string.Format("{0}: {1}", Translation.Instance.DateOfRelease, s.Year) : "";
				cat.EstimatedVideoCount = s.EpisodeCountSpecified ? (uint?)s.EpisodeCount : null;
				if (s.Artwork.Any(a => a.Type == MpExtendedService.WebFileType.Banner)) cat.Thumb = String.Format("http://{0}:{1}/MPExtended/StreamingService/stream/GetArtworkResized?id={2}&provider={3}&artworktype=2&offset=0&mediatype=6&maxWidth=160&maxHeight=160", mServer, mPort, s.Id, s.PID);
                cat.Url = "tvseason";
                cat.HasSubCategories = false;
                cat.Other = s;
                parentCategory.SubCategories.Add(cat);
                cat.ParentCategory = parentCategory;
            }
        }
コード例 #5
0
        internal static WebTVShowBasic TVShowBasic(IOwinContext context, MediaItem item)
        {
            ISet <Guid> necessaryMIATypespisodes = new HashSet <Guid>();

            necessaryMIATypespisodes.Add(MediaAspect.ASPECT_ID);
            necessaryMIATypespisodes.Add(EpisodeAspect.ASPECT_ID);

            IFilter unwatchedEpisodeFilter = BooleanCombinationFilter.CombineFilters(BooleanOperator.And,
                                                                                     new RelationshipFilter(EpisodeAspect.ROLE_EPISODE, SeriesAspect.ROLE_SERIES, item.MediaItemId),
                                                                                     new RelationalUserDataFilter(Guid.Empty, UserDataKeysKnown.KEY_PLAY_PERCENTAGE, RelationalOperator.LT,
                                                                                                                  UserDataKeysKnown.GetSortablePlayPercentageString(100), true));

            int unwatchedCount = MediaLibraryAccess.CountMediaItems(context, necessaryMIATypespisodes, unwatchedEpisodeFilter);

            var              mediaAspect    = item.GetAspect(MediaAspect.Metadata);
            var              seriesAspect   = item.GetAspect(SeriesAspect.Metadata);
            var              importerAspect = item.GetAspect(ImporterAspect.Metadata);
            DateTime?        firstAired     = mediaAspect.GetAttributeValue <DateTime?>(MediaAspect.ATTR_RECORDINGTIME);
            IList <WebActor> actors         = seriesAspect.GetCollectionAttribute <string>(SeriesAspect.ATTR_ACTORS)?.Distinct().Select(a => new WebActor(a)).ToList() ?? new List <WebActor>();
            WebArtwork       aw             = new WebArtwork();

            var show = new WebTVShowBasic()
            {
                Id                    = item.MediaItemId.ToString(),
                Title                 = seriesAspect.GetAttributeValue <string>(SeriesAspect.ATTR_SERIES_NAME),
                DateAdded             = importerAspect.GetAttributeValue <DateTime>(ImporterAspect.ATTR_DATEADDED),
                EpisodeCount          = seriesAspect.GetAttributeValue <int>(SeriesAspect.ATTR_AVAILABLE_EPISODES),
                SeasonCount           = seriesAspect.GetAttributeValue <int>(SeriesAspect.ATTR_AVAILABLE_SEASONS),
                Rating                = Convert.ToSingle(seriesAspect.GetAttributeValue <double>(SeriesAspect.ATTR_TOTAL_RATING)),
                ContentRating         = seriesAspect.GetAttributeValue <string>(SeriesAspect.ATTR_CERTIFICATION),
                Actors                = actors,
                UnwatchedEpisodeCount = unwatchedCount,
                Year                  = firstAired.HasValue ? firstAired.Value.Year : 0,
            };

            IList <MediaItemAspect> genres;

            if (item.Aspects.TryGetValue(GenreAspect.ASPECT_ID, out genres))
            {
                show.Genres = genres.Select(g => g.GetAttributeValue <string>(GenreAspect.ATTR_GENRE)).ToList();
            }

            string tvDbId;

            MediaItemAspect.TryGetExternalAttribute(item.Aspects, ExternalIdentifierAspect.SOURCE_TVDB, ExternalIdentifierAspect.TYPE_SERIES, out tvDbId);
            if (tvDbId != null)
            {
                show.ExternalId.Add(new WebExternalId {
                    Site = "TVDB", Id = tvDbId
                });
            }
            string imdbId;

            MediaItemAspect.TryGetExternalAttribute(item.Aspects, ExternalIdentifierAspect.SOURCE_IMDB, ExternalIdentifierAspect.TYPE_SERIES, out imdbId);
            if (imdbId != null)
            {
                show.ExternalId.Add(new WebExternalId {
                    Site = "IMDB", Id = imdbId
                });
            }

            return(show);
        }