Beispiel #1
0
        public Task <RecommendContent> GetRecommendAsync(RecommendResponse res, RecommendContent prevInfo = null)
        {
            var user_tags = res.UserTagParam;
            var seed      = res.Seed;
            var page      = prevInfo?.RecommendInfo.Page ?? res.Page;

            return(Context.Video.GetRecommendAsync(user_tags, seed, page));
        }
Beispiel #2
0
        protected override async Task <IAsyncEnumerable <RecommendVideoListItem> > GetPagedItemsImpl(int head, int count)
        {
            if (_EndOfRecommend)
            {
                return(AsyncEnumerable.Empty <RecommendVideoListItem>());
            }

            // 初回はページアクセスで得られるデータを使う
            if (_PrevRecommendContent == null)
            {
                _PrevRecommendContent = _RecommendResponse?.FirstData;
            }
            else
            {
                _PrevRecommendContent = await LoginUserRecommendProvider.GetRecommendAsync(_RecommendResponse, _PrevRecommendContent);
            }


            if (_PrevRecommendContent != null && _PrevRecommendContent.Status == "ok")
            {
                _EndOfRecommend = _PrevRecommendContent?.RecommendInfo.EndOfRecommend ?? true;

                AddRecommendTags(
                    _PrevRecommendContent.Items.Select(x => x.AdditionalInfo?.Sherlock.Tag)
                    .Where(x => x != null)
                    );


                return(_PrevRecommendContent.Items.Select(x =>
                {
                    var video = Database.NicoVideoDb.Get(x.Id);
                    video.ThumbnailUrl = x.ThumbnailUrl;
                    video.Title = x.ParseTitle();
                    video.Length = x.ParseLengthToTimeSpan();
                    video.ViewCount = x.ViewCounter;
                    video.CommentCount = x.NumRes;
                    video.MylistCount = x.MylistCounter;
                    video.PostedAt = x.ParseForstRetroeveToDateTimeOffset().DateTime;
                    Database.NicoVideoDb.AddOrUpdate(video);

                    var vm = new RecommendVideoListItem(x);
                    vm.SetupFromThumbnail(video);
                    return vm;
                })
                       .ToAsyncEnumerable()
                       );
            }
            else
            {
                return(AsyncEnumerable.Empty <RecommendVideoListItem>());
            }
        }
        public async Task <RecommendContent> GetRecommendAsync(RecommendResponse res, RecommendContent prevInfo = null)
        {
            var user_tags = res.UserTagParam;
            var seed      = res.Seed;
            var page      = prevInfo?.RecommendInfo.Page ?? res.Page;

            return(await ContextActionAsync(async context =>
            {
                return await context.Video.GetRecommendAsync(user_tags, seed, page);
            }));
        }