Beispiel #1
0
        public List <NicoNicoFavoriteCommunityContent> GetFavoriteCommunity()
        {
            //無駄にアクセスしないように
            if (IsEnd && Page != 1)
            {
                return(null);
            }

            var url = "http://www.nicovideo.jp/my/community?page=" + Page++;
            var a   = NicoNicoWrapperMain.Session.GetAsync(url).Result;

            var ret = new List <NicoNicoFavoriteCommunityContent>();

            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)
            {
                IsEnd = true;
                return(null);
            }


            foreach (var entry in outers)
            {
                var user = new NicoNicoFavoriteCommunityContent();

                var section = entry.SelectSingleNode("child::div[@class='section']");

                user.CommunityPage = section.SelectSingleNode("child::h5/a").Attributes["href"].Value;
                user.Name          = HttpUtility.HtmlDecode(section.SelectSingleNode("child::h5/a").InnerText.Trim());
                user.ThumbnailUrl  = entry.SelectSingleNode("child::div[@class='thumbContainer']/a/img").Attributes["src"].Value;


                var p = section.SelectSingleNode("child::p[1]");
                user.VideoAndMember = section.SelectSingleNode("child::ul/li[1]").InnerText.Trim() + " " + section.SelectSingleNode("child::ul/li[2   ]").InnerText.Trim();
                user.Description    = p == null ? "" : p.InnerText.Trim();

                //説明がなかったら
                if (user.Description == "ニコレポリストに追加/編集する")
                {
                    user.Description = "";
                }
                //改行を空白に置換
                user.Description = user.Description.Replace('\n', ' ').Replace('\r', ' ');

                user.Description = HttpUtility.HtmlDecode(user.Description);
                ret.Add(user);
            }
            return(ret);
        }
        public List<NicoNicoFavoriteCommunityContent> GetFavoriteCommunity()
        {
            //無駄にアクセスしないように
            if(IsEnd && Page != 1) {

                return null;
            }

            var url = "http://www.nicovideo.jp/my/community?page=" + Page++;
            var a = NicoNicoWrapperMain.Session.GetAsync(url).Result;

            var ret = new List<NicoNicoFavoriteCommunityContent>();

            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) {

                IsEnd = true;
                return null;
            }

            foreach(var entry in outers) {

                var user = new NicoNicoFavoriteCommunityContent();

                var section = entry.SelectSingleNode("child::div[@class='section']");

                user.CommunityPage =  section.SelectSingleNode("child::h5/a").Attributes["href"].Value;
                user.Name = HttpUtility.HtmlDecode(section.SelectSingleNode("child::h5/a").InnerText.Trim());
                user.ThumbnailUrl = entry.SelectSingleNode("child::div[@class='thumbContainer']/a/img").Attributes["src"].Value;

                var p = section.SelectSingleNode("child::p[1]");
                user.VideoAndMember = section.SelectSingleNode("child::ul/li[1]").InnerText.Trim() + " " + section.SelectSingleNode("child::ul/li[2   ]").InnerText.Trim();
                user.Description = p == null ? "" : p.InnerText.Trim();

                //説明がなかったら
                if(user.Description == "ニコレポリストに追加/編集する") {

                    user.Description = "";
                }
                //改行を空白に置換
                user.Description = user.Description.Replace('\n', ' ').Replace('\r', ' ');

                user.Description = HttpUtility.HtmlDecode(user.Description);
                ret.Add(user);
            }
            return ret;
        }
        //ユーザーページを開く
        public void Open()
        {
            if(SelectedCommunity != null) {

                NicoNicoOpener.Open(SelectedCommunity.CommunityPage);
            }
            SelectedCommunity = null;
        }