Ejemplo n.º 1
0
        public static async Task <IEnumerable <NicoVideoModel> > GetMylistVideos(string mylistid, string orderby)
        {
            var MylistUrl = $"http://www.nicovideo.jp/mylist/{mylistid}?rss=2.0&numbers=1&sort={orderby}";
            var xml       = await WebUtil.GetXmlChannelAsync(MylistUrl);

            // Video更新
            return(xml.Descendants("item")
                   .Select(item => NicoUtil.CreateVideoFromXml(item,
                                                               "nico-numbers-view",
                                                               "nico-numbers-mylist",
                                                               "nico-numbers-res"
                                                               )));
        }
Ejemplo n.º 2
0
        public static NicoVideoModel CreateVideoFromXml(XElement item, string view, string mylist, string comment)
        {
            string tmp = string.Empty;

            try
            {
                // 明細部読み込み
                var descriptionString = item.Element("description").Value;
                descriptionString = descriptionString.Replace("&nbsp;", "&#x20;");
                //descriptionString = HttpUtility.HtmlDecode(descriptionString);
                descriptionString = descriptionString.Replace("&", "&amp;");
                descriptionString = descriptionString.Replace("'", "&apos;");
                tmp = descriptionString;
                var desc = WebUtil.ToXml($"<root>{descriptionString}</root>");

                var video = new NicoVideoModel()
                {
                    VideoId        = ToVideoId(item.Element("link").Value),
                    Title          = item.Element("title").Value,
                    ViewCounter    = ToCounter(desc, view),
                    MylistCounter  = ToCounter(desc, mylist),
                    CommentCounter = ToCounter(desc, comment),
                    StartTime      = ToRankingDatetime(desc, "nico-info-date"),
                    ThumbnailUrl   = (string)desc.Descendants("img").First().Attribute("src"),
                    LengthSeconds  = NicoUtil.ToLengthSeconds(desc),
                    Description    = (string)desc.Descendants("p").FirstOrDefault(x => (string)x.Attribute("class") == "nico-description")
                };

                /*
                 * <item>
                 * <title>第1位:【女子2人】初めてパンの気持ちを理解する実況【I am Bread】</title>
                 * <link>http://www.nicovideo.jp/watch/sm34525974</link>
                 * <guid isPermaLink="false">tag:nicovideo.jp,2019-01-25:/watch/sm34525974</guid>
                 * <pubDate>Thu, 31 Jan 2019 07:06:01 +0900</pubDate>
                 * <description><![CDATA[
                 *                    <p class="nico-thumbnail"><img alt="【女子2人】初めてパンの気持ちを理解する実況【I am Bread】" src="http://tn.smilevideo.jp/smile?i=34525974.59215" width="94" height="70" border="0"/></p>
                 *                              <p class="nico-description">全パンの想いを背負いし者----------------------関西弁女子実況グループ『サイコロジカルサーカス』が、第13回実況者杯に参加します!フリー部門実況動画の部、謎部門にエントリー!再生数・コメント・マイリス数で順位が決まります!!応援よろよろ!( ˘ω˘ )ニコニ広告が可能です!よければ広告で宣伝もよろしくお願いします(強欲の壺)テーマは【初】この動画はフリー部門実況動画の部の動画です。 今回は映画風の始まりにしてみました!楽しんで見てもらえるとうれしい!(*^^*)今回のプログラム⇒mylist/63232841大会詳細⇒sm33431601パンフレット⇒mylist/55555016舞台袖⇒co3253598プレイメンバー…ノイジーワールド(紫)・馬面なおと(桃) Twitter…https://twitter.com/rojikaru2525</p>
                 *                              <p class="nico-info"><small><strong class="nico-info-number">20,404</strong>pts.|<strong class="nico-info-length">20:04</strong>|<strong class="nico-info-date">2019年01月25日 18:11:01</strong> 投稿<br/><strong>合計</strong>  再生:<strong class="nico-info-total-view">729</strong>  コメント:<strong class="nico-info-total-res">59</strong>  マイリスト:<strong class="nico-info-total-mylist">9</strong><br/><strong>毎時</strong>  再生:<strong class="nico-info-hourly-view">4</strong>  コメント:<strong class="nico-info-hourly-res">0</strong>  マイリスト:<strong class="nico-info-hourly-mylist">0</strong><br/></small></p>
                 *                ]]></description>
                 * </item>
                 */
                return(video);
            }
            catch (Exception ex)
            {
                ServiceFactory.MessageService.Debug(tmp);
                ServiceFactory.MessageService.Exception(ex);
                throw;
            }
        }
Ejemplo n.º 3
0
        public static async Task <NicoVideoModel> GetVideo(string videoid)
        {
            var video = new NicoVideoModel();

            try
            {
                var txt = await WebUtil.GetStringAsync($"http://ext.nicovideo.jp/api/getthumbinfo/{videoid}", null, false);

                var xml = WebUtil.ToXml(txt);

                if (xml == null || (string)xml.Attribute("status") == "fail")
                {
                    video.VideoId = videoid;
                    video.Status  = VideoStatus.Delete;
                    return(video);
                }
                xml                  = xml.Descendants("thumb").First();
                video.VideoId        = ToVideoId((string)xml.Element("watch_url"));
                video.Title          = (string)xml.Element("title");
                video.Description    = (string)xml.Element("description");
                video.ThumbnailUrl   = (string)xml.Element("thumbnail_url");
                video.ViewCounter    = (long)xml.Element("view_counter");
                video.CommentCounter = (long)xml.Element("comment_num");
                video.MylistCounter  = (long)xml.Element("mylist_counter");
                video.StartTime      = DateTime.Parse((string)xml.Element("first_retrieve"));
                video.LengthSeconds  = NicoUtil.ToLengthSeconds((string)xml.Element("length"));
                video.Tags           = xml.Descendants("tags").First().Descendants("tag").Select(tag => (string)tag).GetString(" ");
                video.Username       = (string)xml.Element("user_nickname");
            }
            catch
            {
                video.VideoId = videoid;
                video.Status  = VideoStatus.Delete;
            }

            return(video);
        }