Exemplo n.º 1
0
        public static Comment[] Comment(APIs.download_comment.Serial.chat[] Serial)
        {
            var result = new Comment[(Serial != null) ? Serial.Length : 0];

            for (int i = 0; i < result.Length; i++)
            {
                result[i] = new Comment()
                {
                    IsAnonymity = Serial[i].anonymity,
                    Body = Serial[i].body,
                    Command = Serial[i].mail,
                    Leaf = Serial[i].leaf,
                    No = Serial[i].no,
                    PlayTime = TimeSpan.FromMilliseconds(double.Parse(Serial[i].vpos + '0')),
                    IsPremium = Serial[i].premium,
                    UserID = Serial[i].user_id,
                    WriteTime = unixTime.AddSeconds(double.Parse(Serial[i].date)).ToLocalTime(),
                    IsYourPost = Serial[i].yourpost,
                };

                try
                {
                    result[i].Scores = int.Parse(Serial[i].scores ?? "0");
                }
                catch (Exception) { }
            }

            return result;
        }
Exemplo n.º 2
0
        /// <summary>
        /// コメントをアップロードする
        /// </summary>
        /// <param name="Comment">投稿するコメント</param>
        public Session<Response> UploadComment(Comment Comment)
        {
            var session = new Session<Response>();
            var accessorList = new List<Func<byte[], APIs.IAccesser>>();

            if (!videoCache.IsAvailab)
                accessorList.Add((data) =>
                {
                    var accesser = new APIs.getflv.Accesser();
                    accesser.Setting(
                        context.CookieContainer,
                        target.ID);

                    return accesser;
                });

            if (postkey == "")
                accessorList.Add((data) =>
                {
                    if (data != null)
                        videoCache.Value = new APIs.getflv.Parser().Parse(data);

                    var accesser = new APIs.getpostkey.Accesser();
                    accesser.Setting(
                        context.CookieContainer,
                        block_no,
                        videoCache.Value["thread_id"]);

                    return accesser;
                });

            accessorList.Add((data) =>
            {
                if (postkey == "")
                    postkey = new APIs.getpostkey.Parser().Parse(data);

                var accesser = new APIs.upload_comment.Accesser();
                accesser.Setting(
                    context.CookieContainer,
                    videoCache.Value["ms"],
                    videoCache.Value["thread_id"],
                    ((int)(Comment.PlayTime.TotalMilliseconds / 10)).ToString(),
                    Comment.Command,
                    ticket,
                    videoCache.Value["user_id"],
                    postkey,
                    Comment.Body);

                return accesser;
            });


            session.SetAccessers(
                accessorList.ToArray(),
                (data) =>
                    Converter.Response(new APIs.upload_comment.Parser().Parse(data)));

            return session;
        }