示例#1
0
        public static IReadOnlyList <SyndicationItem>?FetchNews(CultureInfo culture, string?topic = null)
        {
            if (string.IsNullOrWhiteSpace(topic))
            {
                topic = "world";
            }
            string lang = culture.TwoLetterISOLanguageName;
            string url  = $"{NewsUrl}{WebUtility.UrlEncode(topic).ToUpperInvariant()}?ned={lang}&hl={lang}";

            return(RssFeedsService.GetFeedResults(url));
        }
示例#2
0
        public static string?GetFeedURLForSubreddit(string sub, RedditCategory category, out string?rsub)
        {
            rsub = null;

            if (string.IsNullOrWhiteSpace(sub))
            {
                return(null);
            }

            if (_sanitizeRegex.IsMatch(sub))
            {
                return(null);
            }

            sub  = _subPrefixRegex.Replace(sub, string.Empty);
            rsub = "/r/" + sub.ToLowerInvariant();

            string url = $"https://www.reddit.com{rsub}/{category.Humanize(LetterCasing.LowerCase)}.rss";

            return(RssFeedsService.IsValidFeedURL(url) ? url : null);
        }