Exemple #1
0
            internal ContentType(XmlNode node)
            {
                foreach (var attrObj in node.Attributes)
                {
                    var attr = (XmlAttribute)attrObj;
                    var text = attr.Value;

                    switch (attr.Name)
                    {
                    case "id":
                        this.Id = attr.Value;
                        break;

                    case "disableVideo":
                        this.EnableVideo = !StrUtil.ToBool(text, true);
                        break;

                    case "disableAudio":
                        this.EnableAudio = !StrUtil.ToBool(text, true);
                        break;

                    case "start_time":
                        this.StartTime = StrUtil.ToDateTime(text);
                        break;

                    case "duration":
                        this.Duration = TimeSpan.FromSeconds(
                            StrUtil.ToInt(text, 0));
                        break;
                    }
                }

                this.Content = node.InnerText;
            }
        /// <summary>
        /// コンストラクタ
        /// </summary>
        protected LiveInfomationBase(XmlNode node, string rootName,
                                     string idString)
            : this()
        {
            var root = node.SelectSingleNode("/" + rootName);

            if (root == null)
            {
                throw new NicoLiveException(
                          NicoStatusCode.XmlParseError, idString);
            }

            // 放送情報が正しく取得できたか調べます。
            var status = root.Attributes["status"];

            if (status == null)
            {
                throw new NicoLiveException(
                          NicoStatusCode.XmlParseError, idString);
            }

            // 放送情報の取得に失敗した場合、その理由を返します。
            if (status.Value != "ok")
            {
                var code = root.SelectSingleNode("error/code");
                if (code != null)
                {
                    throw new NicoLiveException(
                              NicoStatusCodeUtil.GetCode(code.InnerText), idString);
                }
                else
                {
                    throw new NicoLiveException(
                              NicoStatusCode.UnknownError, idString);
                }
            }

            // 取得時刻です。
            var time = root.Attributes["time"];

            if (time != null)
            {
                this.Time = StrUtil.ToDateTime(time.Value);
            }

            this.RootNode = root;
            this.IdString = idString;
        }
Exemple #3
0
            internal StreamType(XmlNode node)
                : this()
            {
                foreach (var childObj in node.ChildNodes)
                {
                    var child = (XmlNode)childObj;
                    var text  = child.InnerText;

                    switch (child.Name)
                    {
                    case "id":
                        this.Id = int.Parse(text.Substring(2));
                        break;

                    case "title":
                        this.Title = text;
                        break;

                    case "description":
                        this.Description = text;
                        break;

                    case "comment_count":
                        this.CommentCount = StrUtil.ToInt(text, 0);
                        break;

                    case "watch_count":
                        this.WatchCount = StrUtil.ToInt(text, 0);
                        break;

                    case "danjo_comment_mode":
                        this.DanjoCommentMode = StrUtil.ToBool(text, false);
                        break;

                    case "nicoden":
                        this.IsNicoDen = StrUtil.ToBool(text, false);
                        break;

                    case "allow_netduetto":
                        this.AllowNetduetto = StrUtil.ToBool(text, false);
                        break;

                    case "relay_comment":
                        this.RelayComment = text;
                        break;

                    case "park":
                        this.IsPark = StrUtil.ToBool(text, false);
                        break;

                    case "nd_token":
                        this.NdToken = text;
                        break;

                    case "bourbon_url":
                        this.BourbonUrl = text;
                        break;

                    case "full_video":
                        this.FullVideo = text;
                        break;

                    case "after_video":
                        this.AfterVideo = text;
                        break;

                    case "before_video":
                        this.BeforeVideo = text;
                        break;

                    case "kickout_video":
                        this.KickoutVideo = text;
                        break;

                    case "header_comment":
                        this.HeaderComment = text;
                        break;

                    case "footer_comment":
                        this.FooterComment = text;
                        break;

                    case "plugin_delay":
                        this.PluginDelay = text;
                        break;

                    case "plugin_url":
                        this.PluginUrl = text;
                        break;

                    case "provider_type":
                        this.ProviderType = StrUtil.ToProvider(text);
                        break;

                    case "default_community":
                        this.DefaultCommunity = text;
                        break;

                    case "archive":
                        this.IsArchive = StrUtil.ToBool(text, false);
                        break;

                    case "is_dj_stream":
                        this.IsDjStream = StrUtil.ToBool(text, false);
                        break;

                    case "twitter_tag":
                        this.TwitterTag = text;
                        break;

                    case "is_owner":
                        this.IsOwner = StrUtil.ToBool(text, false);
                        break;

                    case "owner_id":
                        this.OwnerId = StrUtil.ToInt(text, -1);
                        break;

                    case "owner_name":
                        this.OwnerName = text;
                        break;

                    case "is_reserved":
                        this.IsReserved = StrUtil.ToBool(text, false);
                        break;

                    case "base_time":
                        this.BaseTime = StrUtil.ToDateTime(text);
                        break;

                    case "open_time":
                        this.OpenTime = StrUtil.ToDateTime(text);
                        break;

                    case "start_time":
                        this.StartTime = StrUtil.ToDateTime(text);
                        break;

                    case "end_time":
                        this.EndTime = StrUtil.ToDateTime(text);
                        break;

                    case "ichiba_notice_enable":
                        this.IsIchibaNoticeEnable = StrUtil.ToBool(text, false);
                        break;

                    case "comment_lock":
                        this.IsCommentLock = StrUtil.ToBool(text, false);
                        break;

                    case "background_comment":
                        this.IsBackgroundComment = StrUtil.ToBool(text, false);
                        break;

                    case "contents_list":
                        foreach (var childObj2 in child.ChildNodes)
                        {
                            var child2 = (XmlNode)childObj2;

                            if (child2.Name == "contents")
                            {
                                var content = new ContentType(child2);
                                this.ContentList.Add(content);
                            }
                        }
                        break;

                    case "press":
                        this.Press = new PressType(child);
                        break;
                    }
                }
            }
Exemple #4
0
            internal StreamType(XmlNode node)
                : this()
            {
                foreach (var childObj in node.ChildNodes)
                {
                    var child = (XmlNode)childObj;
                    var text  = child.InnerText;

                    switch (child.Name)
                    {
                    case "id":
                        this.Id = text;
                        break;

                    case "token":
                        this.Token = text;
                        break;

                    case "exclude":
                        this.Exclude = StrUtil.ToBool(text, false);
                        break;

                    case "provider_type":
                        this.ProviderType = StrUtil.ToProvider(text);
                        break;

                    case "base_time":
                        this.BaseTime = StrUtil.ToDateTime(text);
                        break;

                    case "open_time":
                        this.OpenTime = StrUtil.ToDateTime(text);
                        break;

                    case "start_time":
                        this.StartTime = StrUtil.ToDateTime(text);
                        break;

                    case "end_time":
                        this.EndTime = StrUtil.ToDateTime(text);
                        break;

                    case "allow_vote":
                        this.AllowVote = StrUtil.ToBool(text, false);
                        break;

                    case "disable_adaptive_bitrate":
                        this.IsAdaptiveBitrateEnabled = !StrUtil.ToBool(text, true);
                        break;

                    case "is_reserved":
                        this.IsReserved = StrUtil.ToBool(text, false);
                        break;

                    case "category":
                        this.Category = text;
                        break;

                    case "for_mobile":
                        this.ForMobile = StrUtil.ToBool(text, false);
                        break;
                    }
                }
            }