Пример #1
0
        private async Task <DmcWatchResponse> GetDmcWatchResponse()
        {
            if (!HohoemaApp.IsLoggedIn)
            {
                return(null);
            }

            DmcWatchResponse dmcWatchResponse = null;

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

            if (dmcWatchResponse != null)
            {
                NowLowQualityOnly = dmcWatchResponse.Video.SmileInfo.IsSlowLine;
            }

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


            if (dmcWatchResponse != null)
            {
                if (dmcWatchResponse.Video.DmcInfo.Quality == null)
                {
                    throw new Exception("Dmcサーバーからの再生が出来ません。");
                }

                ProtocolType = MediaProtocolType.RTSPoverHTTP;

                if (dmcWatchResponse.Video.SmileInfo.Url != null)
                {
                    LegacyVideoUrl = new Uri(dmcWatchResponse.Video.SmileInfo.Url);
                    ProtocolType   = MediaProtocolTypeHelper.ParseMediaProtocolType(LegacyVideoUrl);
                }


                DescriptionWithHtml = dmcWatchResponse.Video.Description;
                ThreadId            = dmcWatchResponse.Thread.Ids.Default;
                //PrivateReasonType = watchApiRes.PrivateReason;
                VideoLength       = TimeSpan.FromSeconds(dmcWatchResponse.Video.Duration);
                NowLowQualityOnly = dmcWatchResponse.Video.SmileInfo?.IsSlowLine ?? false;
                //IsOriginalQualityOnly = dmcWatchResponse.Video.SmileInfo?.QualityIds?.Count == 1;

                if (!_thumbnailInitialized)
                {
                    RawVideoId = dmcWatchResponse.Video.Id;
                    await UpdateWithThumbnail();
                }
                IsCommunity = dmcWatchResponse.Video.IsCommunityMemberOnly == "1";

                if (CommentClient.CommentServerInfo == null)
                {
                    if (dmcWatchResponse.Video.DmcInfo != null)
                    {
                        var commentServerInfo = new CommentServerInfo()
                        {
                            ServerUrl         = dmcWatchResponse.Video.DmcInfo.Thread.ServerUrl,
                            DefaultThreadId   = dmcWatchResponse.Video.DmcInfo.Thread.ThreadId,
                            ThreadKeyRequired = dmcWatchResponse.Video.DmcInfo?.Thread.ThreadKeyRequired ?? false
                        };

                        CommentClient.CommentServerInfo = commentServerInfo;
                    }
                    else
                    {
                        var commentServerInfo = new CommentServerInfo()
                        {
                            ServerUrl         = dmcWatchResponse.Thread.ServerUrl,
                            DefaultThreadId   = int.Parse(dmcWatchResponse.Thread.Ids.Default),
                            ThreadKeyRequired = dmcWatchResponse.Video.IsOfficial
                        };

                        if (int.TryParse((string)dmcWatchResponse.Thread.Ids.Community, out var comThreadId))
                        {
                            commentServerInfo.CommunityThreadId = comThreadId;
                        }

                        CommentClient.CommentServerInfo = commentServerInfo;
                    }
                }

                foreach (var divided in GetAllQuality())
                {
                    if (divided is DmcQualityNicoVideo)
                    {
                        (divided as DmcQualityNicoVideo).DmcWatchResponse = dmcWatchResponse;
                    }
                }

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

                //				}).ToList();

                if (dmcWatchResponse.Owner != null)
                {
                    OwnerId        = uint.Parse(dmcWatchResponse.Owner.Id);
                    OwnerIconUrl   = dmcWatchResponse.Owner.IconURL;
                    this.OwnerName = dmcWatchResponse.Owner.Nickname;
                }


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

            return(dmcWatchResponse);
        }
Пример #2
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);
        }
Пример #3
0
 public CommentClient(NiconicoContext context, CommentServerInfo serverInfo)
 {
     RawVideoId        = serverInfo.VideoId;
     Context           = context;
     CommentServerInfo = serverInfo;
 }