예제 #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
            }));
        }
        public static Task <IList <WebRecordingBasic> > ProcessAsync(IOwinContext context, int start, int end, WebSortField?sort, WebSortOrder?order, string filter = null)
        {
            if (!ServiceRegistration.IsRegistered <ITvProvider>())
            {
                throw new BadRequestException("GetRecordingsByRange: ITvProvider not found");
            }

            IList <MediaItem> items = MediaLibraryAccess.GetMediaItemsByAspect(context, BasicNecessaryMIATypeIds, BasicOptionalMIATypeIds);

            List <WebRecordingBasic> output = items.Select(item => RecordingBasic(item)).ToList();

            // sort and filter
            if (sort != null && order != null)
            {
                output = output.Filter(filter).SortRecordingList(sort, order).ToList();
            }
            else
            {
                output = output.Filter(filter).ToList();
            }

            // Get Range
            output = output.TakeRange(start, end).ToList();

            return(System.Threading.Tasks.Task.FromResult <IList <WebRecordingBasic> >(output));
        }
예제 #3
0
        public static Task <WebIntResult> ProcessAsync(IOwinContext context)
        {
            if (!ServiceRegistration.IsRegistered <ITvProvider>())
            {
                throw new BadRequestException("GetRecordingCount: ITvProvider not found");
            }

            IList <MediaItem> items = MediaLibraryAccess.GetMediaItemsByAspect(context, BasicNecessaryMIATypeIds, BasicOptionalMIATypeIds);

            return(Task.FromResult(new WebIntResult {
                Result = items.Count
            }));
        }
        public static Task <IList <WebCategory> > ProcessAsync(IOwinContext context)
        {
            IList <MediaItem> items = MediaLibraryAccess.GetMediaItemsByAspect(context, BasicNecessaryMIATypeIds, BasicOptionalMIATypeIds);

            if (items.Count == 0)
            {
                return(Task.FromResult <IList <WebCategory> >(new List <WebCategory>()));
            }

            var output = items.Select(i => (i.GetAspect(MediaAspect.Metadata).GetAttributeValue <DateTime>(MediaAspect.ATTR_RECORDINGTIME)).ToString("yyyy")).
                         Distinct().Select(y => new WebCategory {
                Id = y, Title = y
            }).ToList();

            return(Task.FromResult <IList <WebCategory> >(output));
        }
예제 #5
0
        public static Task <IList <WebTVEpisodeBasic> > ProcessAsync(IOwinContext context, WebSortField?sort, WebSortOrder?order)
        {
            IList <MediaItem> items = MediaLibraryAccess.GetMediaItemsByAspect(context, BasicNecessaryMIATypeIds, BasicOptionalMIATypeIds, null);

            if (items.Count == 0)
            {
                return(Task.FromResult <IList <WebTVEpisodeBasic> >(new List <WebTVEpisodeBasic>()));
            }

            var output = items.Select(item => EpisodeBasic(item));

            // sort
            if (sort != null && order != null)
            {
                output = output.SortWebTVEpisodeBasic(sort, order);
            }

            return(Task.FromResult <IList <WebTVEpisodeBasic> >(output.ToList()));
        }
예제 #6
0
        public static Task <IList <WebMovieBasic> > ProcessAsync(IOwinContext context, string filter, WebSortField?sort, WebSortOrder?order)
        {
            IList <MediaItem> items = MediaLibraryAccess.GetMediaItemsByAspect(context, BasicNecessaryMIATypeIds, BasicOptionalMIATypeIds, null);

            if (items.Count == 0)
            {
                return(System.Threading.Tasks.Task.FromResult <IList <WebMovieBasic> >(new List <WebMovieBasic>()));
            }

            var output = items.Select(item => MovieBasic(item))
                         .Filter(filter);

            // sort and filter
            if (sort != null && order != null)
            {
                output = output.Filter(filter).SortWebMovieBasic(sort, order);
            }

            return(System.Threading.Tasks.Task.FromResult <IList <WebMovieBasic> >(output.ToList()));
        }
예제 #7
0
        public static Task <IList <WebPictureDetailed> > ProcessAsync(IOwinContext context, string filter, WebSortField?sort, WebSortOrder?order)
        {
            IList <MediaItem> items = MediaLibraryAccess.GetMediaItemsByAspect(context, BasicNecessaryMIATypeIds, BasicOptionalMIATypeIds);

            if (items.Count == 0)
            {
                return(System.Threading.Tasks.Task.FromResult <IList <WebPictureDetailed> >(new List <WebPictureDetailed>()));
            }

            var output = items.Select(i => PictureDetailed(i)).ToList();

            // sort and filter
            if (sort != null && order != null)
            {
                output = output.AsQueryable().Filter(filter).SortMediaItemList(sort, order).ToList();
            }
            else
            {
                output = output.Filter(filter).ToList();
            }

            return(System.Threading.Tasks.Task.FromResult <IList <WebPictureDetailed> >(output));
        }