Example #1
0
        public List <NicoNicoUserMylistEntry> GetUserMylist()
        {
            var url = UserPage + "/mylist";

            Owner.Status = "ユーザーマイリスト取得中";

            List <NicoNicoUserMylistEntry> ret = new List <NicoNicoUserMylistEntry>();

            try {
                var a   = NicoNicoWrapperMain.Session.GetAsync(url).Result;
                var doc = new HtmlDocument();
                doc.LoadHtml2(a);

                var content = doc.DocumentNode.SelectSingleNode("//div[@class='content']");

                var outers = content.SelectNodes("child::div[@class='articleBody']/div[@class='outer']");

                //終了
                if (outers == null)
                {
                    Owner.Status = "";
                    return(null);
                }
                //ニコレポタイムライン走査
                foreach (var node in outers)
                {
                    NicoNicoUserMylistEntry entry = new NicoNicoUserMylistEntry();

                    //h4タグ
                    var h4 = node.SelectSingleNode("child::div/h4");

                    entry.Url = "http://www.nicovideo.jp/" + h4.SelectSingleNode("child::a").Attributes["href"].Value;

                    //名前取得
                    entry.Name = h4.SelectSingleNode("child::a").InnerText.Trim();

                    //説明文取得
                    var desc = node.SelectSingleNode("child::div/p[@data-nico-mylist-desc-full='true']");
                    entry.Description = desc == null ? "" : desc.InnerText.Trim();

                    entry.Description = HyperLinkParser.Parse(entry.Description);

                    //サムネイル取得
                    var thumb1 = node.SelectSingleNode("child::div/ul/li[1]/img");
                    var thumb2 = node.SelectSingleNode("child::div/ul/li[2]/img");
                    var thumb3 = node.SelectSingleNode("child::div/ul/li[3]/img");

                    if (thumb1 != null)
                    {
                        entry.ThumbNail1Available = true;
                        entry.ThumbNail1Url       = thumb1.Attributes["src"].Value;
                        entry.ThumbNail1ToolTip   = HttpUtility.HtmlDecode(thumb1.Attributes["alt"].Value);
                    }
                    else
                    {
                        goto next;
                    }

                    if (thumb2 != null)
                    {
                        entry.ThumbNail2Available = true;
                        entry.ThumbNail2Url       = thumb2.Attributes["src"].Value;
                        entry.ThumbNail2ToolTip   = HttpUtility.HtmlDecode(thumb2.Attributes["alt"].Value);
                    }
                    else
                    {
                        goto next;
                    }

                    if (thumb3 != null)
                    {
                        entry.ThumbNail3Available = true;
                        entry.ThumbNail3Url       = thumb3.Attributes["src"].Value;
                        entry.ThumbNail3ToolTip   = HttpUtility.HtmlDecode(thumb3.Attributes["alt"].Value);
                    }

next:
                    ret.Add(entry);
                }

                Owner.Status = "";
                return(ret);
            } catch (RequestTimeout) {
                Owner.Status = "ユーザーマイリストの取得に失敗しました";
                return(null);
            }
        }
Example #2
0
        public List<NicoNicoUserMylistEntry> GetUserMylist()
        {
            var url = UserPage + "/mylist";
            Owner.Status = "ユーザーマイリスト取得中";

            List<NicoNicoUserMylistEntry> ret = new List<NicoNicoUserMylistEntry>();
            try {

                var a = NicoNicoWrapperMain.Session.GetAsync(url).Result;
                var doc = new HtmlDocument();
                doc.LoadHtml2(a);

                var content = doc.DocumentNode.SelectSingleNode("//div[@class='content']");

                var outers = content.SelectNodes("child::div[@class='articleBody']/div[@class='outer']");

                //終了
                if(outers == null) {

                    Owner.Status = "";
                    return null;
                }
                //ニコレポタイムライン走査
                foreach(var node in outers) {

                    NicoNicoUserMylistEntry entry = new NicoNicoUserMylistEntry();

                    //h4タグ
                    var h4 = node.SelectSingleNode("child::div/h4");

                    entry.Url = "http://www.nicovideo.jp/" + h4.SelectSingleNode("child::a").Attributes["href"].Value;

                    //名前取得
                    entry.Name = h4.SelectSingleNode("child::a").InnerText.Trim();

                    //説明文取得
                    var desc = node.SelectSingleNode("child::div/p[@data-nico-mylist-desc-full='true']");
                    entry.Description = desc == null ? "" : desc.InnerText.Trim();

                    entry.Description = HyperLinkParser.Parse(entry.Description);

                    //サムネイル取得
                    var thumb1 = node.SelectSingleNode("child::div/ul/li[1]/img");
                    var thumb2 = node.SelectSingleNode("child::div/ul/li[2]/img");
                    var thumb3 = node.SelectSingleNode("child::div/ul/li[3]/img");

                    if(thumb1 != null) {

                        entry.ThumbNail1Available = true;
                        entry.ThumbNail1Url = thumb1.Attributes["src"].Value;
                        entry.ThumbNail1ToolTip = HttpUtility.HtmlDecode(thumb1.Attributes["alt"].Value);
                    } else {
                        goto next;
                    }

                    if(thumb2 != null) {

                        entry.ThumbNail2Available = true;
                        entry.ThumbNail2Url = thumb2.Attributes["src"].Value;
                        entry.ThumbNail2ToolTip = HttpUtility.HtmlDecode(thumb2.Attributes["alt"].Value);
                    } else {
                        goto next;
                    }

                    if(thumb3 != null) {

                        entry.ThumbNail3Available = true;
                        entry.ThumbNail3Url = thumb3.Attributes["src"].Value;
                        entry.ThumbNail3ToolTip = HttpUtility.HtmlDecode(thumb3.Attributes["alt"].Value);
                    }

                    next:
                    ret.Add(entry);
                }

                Owner.Status = "";
                return ret;
            } catch(RequestTimeout) {

                Owner.Status = "ユーザーマイリストの取得に失敗しました";
                return null;
            }
        }