public async Task <NicoNicoRankingEntry> GetRankingAsync(string category, int page) { try { var ret = new NicoNicoRankingEntry(); ret.Period = Period; ret.Target = Target; var a = await App.ViewModelRoot.CurrentUser.Session.GetAsync(string.Format(ApiUrl, category, page)); var doc = new HtmlDocument(); doc.LoadHtml(a); ret.ItemList = new List <RankingItem>(); var nodes = doc.DocumentNode.SelectNodes("//div[@class='contentBody video videoList01']/ul/li"); if (nodes == null) { return(null); } //ランキングページから各種データをXPathで取得 foreach (var ranking in nodes) { var item = new RankingItem(); item.Rank = ranking.SelectSingleNode("div[@class='rankingNumWrap']/p[@class='rankingNum']").InnerText; item.RankingPoint = ranking.SelectSingleNode("div[@class='rankingNumWrap']/p[@class='rankingPt']").InnerText; var wrap = ranking.SelectSingleNode("div[@class='videoList01Wrap']"); item.PostAt = wrap.SelectSingleNode("p[contains(@class, 'itemTime')]").InnerText; item.Length = wrap.SelectSingleNode("div[@class='itemThumbBox']/span").InnerText; item.ThumbNail = wrap.SelectSingleNode("div[@class='itemThumbBox']/div/a/img[2]").Attributes["data-original"].Value; var content = ranking.SelectSingleNode("div[@class='itemContent']"); item.ContentUrl = "http://www.nicovideo.jp/" + content.SelectSingleNode("p/a").Attributes["href"].Value; item.Title = content.SelectSingleNode("p/a").InnerText; item.Description = content.SelectSingleNode("div[@class='wrap']/p[@class='itemDescription ranking']").InnerText; var itemdata = content.SelectSingleNode("div[@class='itemData']/ul"); item.ViewCount = itemdata.SelectSingleNode("li[@class='count view']/span").InnerText; item.CommentCount = itemdata.SelectSingleNode("li[@class='count comment']/span").InnerText; item.MylistCount = itemdata.SelectSingleNode("li[@class='count mylist']/span").InnerText; NicoNicoUtil.ApplyLocalHistory(item); ret.ItemList.Add(item); } return(ret); } catch (RequestFailed) { return(null); } }
public async Task<NicoNicoRankingEntry> GetRankingAsync(string category, int page) { try { var ret = new NicoNicoRankingEntry(); ret.Period = Period; ret.Target = Target; var a = await NicoNicoWrapperMain.Session.GetAsync(string.Format(ApiUrl, category, page)); var doc = new HtmlDocument(); doc.LoadHtml2(a); ret.ItemList = new List<RankingItem>(); var nodes = doc.DocumentNode.SelectNodes("//div[@class='contentBody video videoList01']/ul/li"); if(nodes == null) { return null; } foreach(var ranking in nodes) { var item = new RankingItem(); item.Rank = ranking.SelectSingleNode("div[@class='rankingNumWrap']/p[@class='rankingNum']").InnerText; item.RankingPoint = ranking.SelectSingleNode("div[@class='rankingNumWrap']/p[@class='rankingPt']").InnerText; var wrap = ranking.SelectSingleNode("div[@class='videoList01Wrap']"); item.PostAt = wrap.SelectSingleNode("p[contains(@class, 'itemTime')]").InnerText; item.Length = wrap.SelectSingleNode("div[@class='itemThumbBox']/span").InnerText; item.ThumbNail = wrap.SelectSingleNode("div[@class='itemThumbBox']/div/a/img[2]").Attributes["data-original"].Value; var content = ranking.SelectSingleNode("div[@class='itemContent']"); item.VideoUrl = "http://www.nicovideo.jp/" + content.SelectSingleNode("p/a").Attributes["href"].Value; item.Title = content.SelectSingleNode("p/a").InnerText; item.Description = content.SelectSingleNode("div[@class='wrap']/p[@class='itemDescription ranking']").InnerText; var itemdata = content.SelectSingleNode("div[@class='itemData']/ul"); item.ViewCount = itemdata.SelectSingleNode("li[@class='count view']/span").InnerText; item.CommentCount = itemdata.SelectSingleNode("li[@class='count comment']/span").InnerText; item.MylistCount = itemdata.SelectSingleNode("li[@class='count mylist']/span").InnerText; ret.ItemList.Add(item); } return ret; }catch(RequestTimeout) { return null; } }
public void Open(RankingItem item) { NicoNicoOpener.Open(item.VideoUrl); }