Esempio n. 1
0
        private async Task <ChannelItemResult> GetChannelItemsInternal(InternalChannelItemQuery query,
                                                                       CancellationToken cancellationToken)
        {
            var downloader = new VimeoListingDownloader(_logger, _jsonSerializer, _httpClient);
            var catSplit   = query.FolderId.Split('_');
            var videos     = new Videos();

            if (catSplit.Count() == 3)
            {
                if (catSplit[1] == "allVideos")
                {
                    videos = await downloader.GetCategoryVideoList(catSplit[2], query.StartIndex, query.Limit, cancellationToken).ConfigureAwait(false);
                }
                else
                {
                    videos = await downloader.GetVimeoList(catSplit[2], query.StartIndex, query.Limit, cancellationToken).ConfigureAwait(false);
                }
            }
            else
            {
                videos = await downloader.GetVimeoList(catSplit[1], query.StartIndex, query.Limit, cancellationToken).ConfigureAwait(false);
            }

            var items = videos.Select(i => new ChannelItemInfo
            {
                ContentType      = ChannelMediaContentType.Clip,
                ImageUrl         = i.thumbnails[2].Url,
                IsInfiniteStream = false,
                MediaType        = ChannelMediaType.Video,
                Name             = i.title,
                Overview         = i.description,
                Type             = ChannelItemType.Media,
                Id           = i.id,
                RunTimeTicks = TimeSpan.FromSeconds(i.duration).Ticks,
                Tags         = i.tags == null ? new List <string>() : i.tags.Select(t => t.title).ToList(),
                DateCreated  = DateTime.Parse(i.upload_date)
            });

            return(new ChannelItemResult
            {
                Items = items.ToList(),
                TotalRecordCount = videos.total
            });
        }
        private async Task<ChannelItemResult> GetChannelItemsInternal(InternalChannelItemQuery query, CancellationToken cancellationToken)
        {
            var downloader = new VimeoListingDownloader(_logger, _jsonSerializer, _httpClient);
            var videos = await downloader.GetVimeoList(query.CategoryId, query.StartIndex, query.Limit, cancellationToken)
                .ConfigureAwait(false);

            var items = videos.Select(i => new ChannelItemInfo
            {
                ContentType = ChannelMediaContentType.Clip,
                ImageUrl = i.thumbnails[2].Url,
                IsInfiniteStream = false,
                MediaType = ChannelMediaType.Video,
                Name = i.title,
                Overview = i.description,
                Type = ChannelItemType.Media,
                Id = i.id,
                RunTimeTicks = TimeSpan.FromSeconds(i.duration).Ticks,
                Tags = i.tags == null ? new List<string>() : i.tags.Select(t => t.title).ToList()

            });

            return new ChannelItemResult
            {
                Items = items.ToList(),
                CacheLength = TimeSpan.FromDays(1),
                TotalRecordCount = videos.total
            };
        }
Esempio n. 3
0
        private async Task<ChannelItemResult> GetChannelItemsInternal(InternalChannelItemQuery query,
            CancellationToken cancellationToken)
        {
            var downloader = new VimeoListingDownloader(_logger, _jsonSerializer, _httpClient);
            var catSplit = query.FolderId.Split('_');
            var videos = new Videos();

            if (catSplit.Count() == 3)
            {
                if (catSplit[1] == "allVideos")
                    videos = await downloader.GetCategoryVideoList(catSplit[2], query.StartIndex, query.Limit, cancellationToken).ConfigureAwait(false);
                else
                    videos = await downloader.GetVimeoList(catSplit[2], query.StartIndex, query.Limit, cancellationToken).ConfigureAwait(false);
            }
            else
                videos = await downloader.GetVimeoList(catSplit[1], query.StartIndex, query.Limit, cancellationToken).ConfigureAwait(false);

            var items = videos.Select(i => new ChannelItemInfo
                {
                    ContentType = ChannelMediaContentType.Clip,
                    ImageUrl = i.thumbnails[2].Url,
                    IsInfiniteStream = false,
                    MediaType = ChannelMediaType.Video,
                    Name = i.title,
                    Overview = i.description,
                    Type = ChannelItemType.Media,
                    Id = i.id,
                    RunTimeTicks = TimeSpan.FromSeconds(i.duration).Ticks,
                    Tags = i.tags == null ? new List<string>() : i.tags.Select(t => t.title).ToList(),
                    DateCreated = DateTime.Parse(i.upload_date)

                });

            return new ChannelItemResult
            {
                Items = items.ToList(),
                TotalRecordCount = videos.total
            };
        }