コード例 #1
0
 public async Task <NiconicoVideoRss> GetCategoryRanking(RankingCategory category, RankingTarget target, RankingTimeSpan timeSpan)
 {
     return(await ContextActionAsync(async context =>
     {
         return await NiconicoRanking.GetRankingData(target, timeSpan, category);
     }));
 }
コード例 #2
0
 public async Task <NiconicoVideoRss> GetCategoryRanking(RankingCategory category, RankingTarget target, RankingTimeSpan timeSpan)
 {
     return(await ConnectionRetryUtil.TaskWithRetry(async() =>
     {
         return await NiconicoRanking.GetRankingData(target, timeSpan, category);
     }));
 }
コード例 #3
0
        public async Task RankingHotTopicGettingTestAsync(RankingTerm term, int page)
        {
            var data = await NiconicoRanking.GetRankingRssAsync(RankingGenre.HotTopic, term : term, page : page);

            Assert.IsTrue(data.IsOK);

            Assert.IsTrue(data.Items.Any());
            var sampleItems = data.Items.Take(1).ToArray();

            foreach (var sampleItem in sampleItems)
            {
                var videoid = sampleItem.GetVideoId();
                Assert.IsTrue(videoid.StartsWith("sm") || videoid.StartsWith("so") || videoid.StartsWith("nm"));
                System.Diagnostics.Debug.WriteLine(videoid);
                var title = sampleItem.GetRankTrimmingTitle();
                System.Diagnostics.Debug.WriteLine(title);

                var moreData = sampleItem.GetMoreData();

                Assert.IsNotNull(moreData.Title);
                Assert.IsTrue(moreData.Length > TimeSpan.Zero);
                Assert.IsTrue(moreData.WatchCount >= 0);
                Assert.IsTrue(moreData.CommentCount >= 0);
                Assert.IsTrue(moreData.MylistCount >= 0);
            }
        }
コード例 #4
0
ファイル: RankingProvider.cs プロジェクト: willvin313/Hohoema
        public async Task <List <Database.Local.RankingGenreTag> > GetRankingGenreTagsAsync(RankingGenre genre, bool isForceUpdate = false)
        {
            if (isForceUpdate)
            {
                Database.Local.RankingGenreTagsDb.Delete(genre);
            }
            else
            {
                var cachedTags = Database.Local.RankingGenreTagsDb.Get(genre);
                if (cachedTags != null && (DateTime.Now - cachedTags.UpdateAt) < TimeSpan.FromHours(6))
                {
                    return(cachedTags.Tags);
                }
            }

            var tagsRaw = await NiconicoRanking.GetGenrePickedTagAsync(genre);

            var tags = tagsRaw.Select(x => new Database.Local.RankingGenreTag()
            {
                DisplayName = x.DisplayName, Tag = x.Tag
            }).ToList();

            Database.Local.RankingGenreTagsDb.Upsert(genre, tags);
            return(tags);
        }
コード例 #5
0
        public async Task RankingHotTopicTagsGettingsAsync()
        {
            var tags = await NiconicoRanking.GetGenrePickedTagAsync(RankingGenre.HotTopic);

            foreach (var tag in tags)
            {
                Assert.IsNotNull(tag);

                if (tag.IsDefaultTag)
                {
                    System.Diagnostics.Debug.WriteLine("Default tag: " + tag.DisplayName);
                    Assert.IsNotNull(tag.DisplayName);
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine($"{tag.DisplayName}");
                    System.Diagnostics.Debug.WriteLine($"{tag.Tag}");
                    Assert.IsNotNull(tag.DisplayName);
                    Assert.IsNotNull(tag.Tag);
                }
            }
        }
コード例 #6
0
        protected override async Task <int> HohoemaPreloadingResetSourceImpl()
        {
            RankingRss = await NiconicoRanking.GetRankingData(_Target, _TimeSpan, _Category);

            return(RankingRss.Channel.Items.Count);
        }
コード例 #7
0
 public async Task RankingHotTopicFailTestAsync(RankingTerm term, int page)
 {
     await Assert.ThrowsExceptionAsync <ArgumentOutOfRangeException>(async() =>
                                                                     await NiconicoRanking.GetRankingRssAsync(RankingGenre.HotTopic, term: term, page: page)
                                                                     );
 }
コード例 #8
0
        protected override async Task <int> ResetSourceImpl()
        {
            RankingRss = await NiconicoRanking.GetRankingData(Target, TimeSpan, Category);

            return(RankingRss.Channel.Items.Count);
        }
コード例 #9
0
ファイル: RankingProvider.cs プロジェクト: willvin313/Hohoema
 public async Task <Mntone.Nico2.RssVideoResponse> GetRankingGenreWithTagAsync(RankingGenre genre, string tag, RankingTerm term, int page = 1)
 {
     return(await NiconicoRanking.GetRankingRssAsync(genre, tag, term, page));
 }