예제 #1
0
        static async Task <RssVideoResponse> Internal_GetHotTopicRankingRssWithKeyAsync(string key, RankingTerm term)
        {
            if (!IsHotTopicAcceptTerm(term))
            {
                throw new ArgumentOutOfRangeException($"out of range {nameof(RankingTerm)}. accept with {string.Join(" or ", Constants.HotTopicAccepteRankingTerms)}.");
            }

            var dict = new Dictionary <string, string>()
            {
                { "rss", "2.0" },
                { "lang", "ja-jp" }
            };

            dict.Add(nameof(key), Uri.EscapeDataString(key));
            dict.Add(nameof(term), term.GetDescription());

            try
            {
                return(await VideoRssContentHelper.GetRssVideoResponseAsync(
                           $"{Constants.NiconicoRankingHotTopicDomain}?{HttpQueryExtention.DictionaryToQuery(dict)}"
                           ));
            }
            catch
            {
                return(new RssVideoResponse()
                {
                    IsOK = false, Items = new List <RssVideoData>()
                });
            }
        }
예제 #2
0
        static async Task <RssVideoResponse> Internal_GetRankingRssAsync(RankingGenre genre, RankingTerm term, int page)
        {
            if (page == 0 || page > Constants.MaxPage)
            {
                throw new ArgumentOutOfRangeException($"out of range {nameof(page)}. inside btw from 1 to {Constants.MaxPage} in with tag.");
            }

            var dict = new Dictionary <string, string>()
            {
                { "rss", "2.0" },
                { "lang", "ja-jp" }
            };

            dict.Add(nameof(term), term.GetDescription());
            if (page != 1)
            {
                dict.Add(nameof(page), page.ToString());
            }

            try
            {
                return(await VideoRssContentHelper.GetRssVideoResponseAsync(
                           $"{Constants.NiconicoRankingGenreDomain}{genre.GetDescription()}?{HttpQueryExtention.DictionaryToQuery(dict)}"
                           ));
            }
            catch
            {
                return(new RssVideoResponse()
                {
                    IsOK = false, Items = new List <RssVideoData>()
                });
            }
        }
예제 #3
0
        public static async Task <RssVideoResponse> GetCommunityVideosAsync(NiconicoContext context, string communityId, uint page)
        {
            var dict = new Dictionary <string, string>();

            dict.Add("rss", "2.0");
            dict.Add(nameof(page), page.ToString());

            return(await VideoRssContentHelper.GetRssVideoResponseAsync(
                       $"{NiconicoUrls.CommynityVideoPageUrl}/{communityId}?{HttpQueryExtention.DictionaryToQuery(dict)}"
                       ));
        }