Example #1
0
        public static async Task UpdateNicoVideoInfo(NicoVideoInfo info, WatchApiResponse watchApiRes)
        {
            info.DescriptionWithHtml = watchApiRes.videoDetail.description;

            info.ThreadId     = watchApiRes.ThreadId.ToString();
            info.ViewCount    = (uint)watchApiRes.videoDetail.viewCount.Value;
            info.MylistCount  = (uint)watchApiRes.videoDetail.mylistCount.Value;
            info.CommentCount = (uint)watchApiRes.videoDetail.commentCount.Value;

            info.PrivateReasonType = watchApiRes.PrivateReason;

            await UpdateAsync(info);
        }
        public PreparePlayVideoResult(string contentId, NiconicoSession niconicoSession, NicoVideoSessionOwnershipManager ownershipManager, WatchApiResponse watchApiResponse)
            : this(contentId, niconicoSession)
        {
            _ownershipManager = ownershipManager;
            _watchApiResponse = watchApiResponse;
            IsSuccess         = _watchApiResponse != null;
            var quality = _watchApiResponse.VideoUrl.OriginalString.EndsWith("low") ? NicoVideoQuality.Smile_Low : NicoVideoQuality.Smile_Original;

            AvailableQualities = new[]
            {
                new NicoVideoQualityEntity(true, quality, quality.ToString())
            }
            .ToImmutableArray();

            // Note: スマイル鯖はいずれ無くなると見て対応を限定的にしてしまう
        }
        Task <ICommentSession> CreateCommentSession(string contentId, WatchApiResponse watchApiRes)
        {
            var commentClient = new CommentClient(_niconicoSession, contentId);

            commentClient.CommentServerInfo = new CommentServerInfo()
            {
                ServerUrl         = watchApiRes.CommentServerUrl.OriginalString,
                VideoId           = contentId,
                DefaultThreadId   = (int)watchApiRes.ThreadId,
                CommunityThreadId = (int)watchApiRes.OptionalThreadId,
                ViewerUserId      = watchApiRes.viewerInfo.id,
                ThreadKeyRequired = watchApiRes.IsKeyRequired
            };
            commentClient.VideoOwnerId = watchApiRes.UploaderInfo?.id;

            return(Task.FromResult(new VideoCommentService(commentClient) as ICommentSession));
        }
 public WatchApiVideoDetails(WatchApiResponse watchApiRes)
 {
     _watchApiRes = watchApiRes;
     Tags         = _watchApiRes.videoDetail.tagList.Select(x => new NicoVideoTag(x.tag)).ToArray();
 }
Example #5
0
        private async Task <WatchApiResponse> GetWatchApiResponse(bool forceLoqQuality = false)
        {
            if (!HohoemaApp.IsLoggedIn)
            {
                return(null);
            }


            WatchApiResponse watchApiRes = null;

            try
            {
                watchApiRes = await HohoemaApp.ContentFinder.GetWatchApiResponse(RawVideoId, forceLoqQuality, HarmfulContentReactionType);
            }
            catch (AggregateException ea) when(ea.Flatten().InnerExceptions.Any(e => e is ContentZoningException))
            {
                IsBlockedHarmfulVideo = true;
            }
            catch (ContentZoningException)
            {
                IsBlockedHarmfulVideo = true;
            }
            catch { }

            if (!forceLoqQuality && watchApiRes != null)
            {
                NowLowQualityOnly = watchApiRes.VideoUrl.AbsoluteUri.EndsWith("low");
            }

            _VisitedPageType = watchApiRes.VideoUrl.AbsoluteUri.EndsWith("low") ? NicoVideoQuality.Low : NicoVideoQuality.Original;

            if (watchApiRes != null)
            {
                LegacyVideoUrl = watchApiRes.VideoUrl;

                ProtocolType = MediaProtocolTypeHelper.ParseMediaProtocolType(watchApiRes.VideoUrl);

                DescriptionWithHtml = watchApiRes.videoDetail.description;
                ThreadId            = watchApiRes.ThreadId.ToString();
                PrivateReasonType   = watchApiRes.PrivateReason;
                VideoLength         = watchApiRes.Length;

                if (!_thumbnailInitialized)
                {
                    RawVideoId = watchApiRes.videoDetail.id;
                    await UpdateWithThumbnail();
                }
                IsCommunity = watchApiRes.flashvars.is_community_video == "1";

                var commentServerInfo = new CommentServerInfo()
                {
                    ServerUrl         = watchApiRes.CommentServerUrl.OriginalString,
                    DefaultThreadId   = (int)watchApiRes.ThreadId,
                    ThreadKeyRequired = watchApiRes.IsKeyRequired
                };

                CommentClient.CommentServerInfo = commentServerInfo;

                // TODO:
                //				Tags = watchApiRes.videoDetail.tagList.Select(x => new Tag()
                //				{

                //				}).ToList();

                if (watchApiRes.UploaderInfo != null)
                {
                    OwnerId = uint.Parse(watchApiRes.UploaderInfo.id);
                }


                this.IsDeleted = watchApiRes.IsDeleted;
                if (IsDeleted)
                {
                    await DeletedTeardown();
                }
            }

            return(watchApiRes);
        }