GetTimeFromVpos() public static method

public static GetTimeFromVpos ( NicoNicoGetPlayerStatus status, int vpos ) : string
status NicoNicoGetPlayerStatus
vpos int
return string
Exemplo n.º 1
0
        private void OnReceive(object sender, XmlSocketReceivedEventArgs e)
        {
            var xml = new XmlDocument();

            try {
                xml.LoadXml(e.Xml);

                Console.WriteLine(e.Xml);

                var thread = xml.SelectSingleNode("/thread");
                if (thread != null)
                {
                    Ticket = thread.Attributes["ticket"].Value;
                    if (thread.Attributes["last_res"] != null)
                    {
                        LastRes = int.Parse(thread.Attributes["last_res"].Value);
                    }
                    ResFrom = LastRes + 1;

                    return;
                }

                var chat = xml.SelectSingleNode("/chat");
                if (chat != null)
                {
                    var comment = new NicoNicoCommentEntry();
                    comment.No    = (++CommentNum).ToString();
                    comment.Vpos  = chat.Attributes["vpos"].Value;
                    comment.Mail  = chat.Attributes["mail"] != null ? chat.Attributes["mail"].Value : "";
                    comment.Score = chat.Attributes["score"] != null?int.Parse(chat.Attributes["score"].Value) : 0;

                    comment.UserId  = chat.Attributes["user_id"].Value;
                    comment.Date    = NicoNicoUtil.GetTimeFromVpos(Status, comment.Vpos);
                    comment.Content = chat.InnerText;

                    Owner.CommentList.Add(comment);

                    //コマンドは弾く
                    if (chat.InnerText.StartsWith("/"))
                    {
                        return;
                    }
                    Handler.InvokeScript("AsInjectOneComment", comment.ToJson());
                }
            } catch (XmlException) {
                return;
            }
        }
Exemplo n.º 2
0
        private void StoreEntry(HtmlDocument doc, List <NicoNicoCommentEntry> list)
        {
            var nodes = doc.DocumentNode.SelectNodes("/packet/chat");

            if (nodes == null)
            {
                return;
            }

            foreach (var node in nodes)
            {
                var attr = node.Attributes;

                //削除されていたら登録しない もったいないしね
                if (attr.Contains("deleted"))
                {
                    continue;
                }

                var entry = new NicoNicoCommentEntry();

                entry.No         = attr["no"].Value;
                entry.Vpos       = attr["vpos"].Value;
                entry.RenderTime = NicoNicoUtil.GetTimeFromVpos(entry.Vpos);
                var unix = UnixTime.FromUnixTime(long.Parse(attr["date"].Value));

                entry.Date    = unix.ToLongDateString() + " " + unix.ToLongTimeString();
                entry.UserId  = attr.Contains("user_id") ? attr["user_id"].Value : "contributor";
                entry.Mail    = attr.Contains("mail") ? attr["mail"].Value : "";
                entry.Content = HttpUtility.HtmlDecode(node.InnerText);
                entry.Score   = attr.Contains("score") ? int.Parse(attr["score"].Value) : 0;

                if (!NicoNicoNGComment.Filter(entry))
                {
                    list.Add(entry);
                }
            }
        }