Exemple #1
0
        /// <summary>
        /// threadを取得(過去ログ)
        /// </summary>
        private ComApi.RequestItems GetThread(WatchPage::CommentCompositeItems.Thread thread, WatchPage::BaseJson data, int _when)
        {
            var command = new ComApi.RequestItems();

            command.thread         = new ComApi.CommentItems.Thread();
            command.thread.thread  = $"{thread.id}";
            command.thread.fork    = thread.fork;
            command.thread.user_id = $"{data.video.dmcInfo.user.user_id}";

            //公式動画・ユーザー動画で分岐
            if (thread.isThreadkeyRequired)
            {
                command.thread.threadkey = crInfo.Threadkey;
                command.thread.force_184 = crInfo.Force184;
            }
            else
            {
                //command.thread.userkey = data.context.userkey;
            }

            command.thread.waybackkey = crInfo.WayBackKey;
            command.thread.whencom    = _when;

            return(command);
        }
Exemple #2
0
        /// <summary>
        /// Leafを取得(過去ログ)
        /// </summary>
        private ComApi.RequestItems GetLeaf(WatchPage::CommentCompositeItems.Thread thread, WatchPage::BaseJson data, int _when)
        {
            var command = new ComApi.RequestItems();

            command.thread_leaves         = new ComApi.CommentItems.Leaf();
            command.thread_leaves.thread  = $"{thread.id}";
            command.thread_leaves.user_id = $"{data.video.dmcInfo.user.user_id}";
            int minute = (int)Math.Ceiling(data.video.duration / 60);

            command.thread_leaves.content = $"0-{minute}:100,1000,nicoru:100";

            if (thread.isThreadkeyRequired)
            {
                command.thread_leaves.threadkey = crInfo.Threadkey;
                command.thread_leaves.force_184 = crInfo.Force184;
            }
            else
            {
                //command.thread_leaves.userkey = data.context.userkey;
            }

            command.thread_leaves.waybackkey = crInfo.WayBackKey;
            command.thread_leaves.whencom    = _when;

            return(command);
        }
Exemple #3
0
        /// <summary>
        /// リクエストデータを取得する
        /// </summary>
        private List <ComApi.RequestItems> GetCommentRequest(WatchPage::BaseJson data, int?_when)
        {
            var logger = NicoLogger.GetLogger();

            logger.Debug("コメントリクエストデータの作成を開始", moduleName);


            var request = new List <ComApi.RequestItems>();

            void insertStart(string type = "ps")
            {
                var s = new ComApi.RequestItems();

                s.ping = new ComApi.CommentItems.Ping();
                switch (type)
                {
                case "ps":
                    s.ping.content = $"ps:{crInfo.ComCommandCount}";
                    break;

                case "rs":
                    s.ping.content = $"rs:{crInfo.ComRequestCount}";
                    break;
                }
                request.Add(s);
            }

            void insertEnd(string type = "pf")
            {
                var e = new ComApi.RequestItems();

                e.ping = new ComApi.CommentItems.Ping();
                switch (type)
                {
                case "pf":
                    e.ping.content = $"pf:{crInfo.ComCommandCount}";
                    ++crInfo.ComCommandCount;
                    break;

                case "rf":
                    e.ping.content = $"rf:{crInfo.ComRequestCount}";
                    ++crInfo.ComRequestCount;
                    break;
                }
                request.Add(e);
            }

            //rs
            insertStart("rs");

            foreach (var thread in data.commentComposite.threads)
            {
                if (!thread.isActive)
                {
                    continue;
                }

                insertStart(); if (_when == null)
                {
                    request.Add(GetThread(thread, data));
                }
                else
                {
                    request.Add(GetThread(thread, data, (int)_when));
                }
                insertEnd();

                if (thread.isLeafRequired)
                {
                    insertStart();
                    if (_when == null)
                    {
                        request.Add(GetLeaf(thread, data));
                    }
                    else
                    {
                        request.Add(GetLeaf(thread, data, (int)_when));
                    }
                    insertEnd();
                }
            }

            //rf
            insertEnd("rf");
            logger.Debug("コメントリクエストデータの作成が完了", moduleName);

            return(request);
        }