SharpRSS/SharpRss/RssService.cs

53 lines
1.3 KiB
C#
Raw Normal View History

2023-05-07 02:42:37 +02:00
using System.Collections.Generic;
2023-04-27 17:23:01 +02:00
using System.Linq;
2023-05-07 02:42:37 +02:00
using System.Threading.Tasks;
2023-04-27 17:23:01 +02:00
using CodeHollow.FeedReader;
2023-05-07 02:42:37 +02:00
using SharpRss.Models;
2023-04-27 17:23:01 +02:00
namespace SharpRss
{
2023-05-12 15:48:14 +02:00
/// <summary>
/// Managing RSS feeds and categories.
/// </summary>
2023-04-27 17:23:01 +02:00
public class RssService
{
2023-04-28 21:58:36 +02:00
public RssService()
{
2023-05-12 15:48:14 +02:00
/// Storage options:
/// - Database
/// - File
/// - Memory
2023-04-28 21:58:36 +02:00
}
2023-05-07 02:42:37 +02:00
2023-05-12 15:48:14 +02:00
public async Task<HashSet<CategoryModel>> GetCategories()
2023-05-07 02:42:37 +02:00
{
2023-05-12 15:48:14 +02:00
return new HashSet<CategoryModel>();
2023-05-07 02:42:37 +02:00
}
2023-05-12 15:48:14 +02:00
public async Task<HashSet<FeedModel>> GetAllFeeds()
2023-04-27 17:23:01 +02:00
{
2023-05-12 15:48:14 +02:00
return new HashSet<FeedModel>();
}
/// Old
2023-04-27 17:23:01 +02:00
2023-05-12 15:48:14 +02:00
public async Task<Feed> GetFeed(string feedUrl)
{
var urls = await FeedReader.GetFeedUrlsFromUrlAsync(feedUrl);
2023-04-27 17:23:01 +02:00
string url;
if (urls.Count() < 1)
url = _feeds[0];
else
url = urls.First().Url;
2023-05-12 15:48:14 +02:00
return await FeedReader.ReadAsync(url);
2023-04-27 17:23:01 +02:00
}
2023-05-12 15:48:14 +02:00
public async Task<HashSet<Feed>> GetFeedsFromCatAsync(CategoryModel category)
2023-04-28 21:58:36 +02:00
{
2023-05-12 15:48:14 +02:00
return new HashSet<Feed>();
2023-04-28 21:58:36 +02:00
}
2023-05-12 15:48:14 +02:00
private readonly string[] _feeds = { "https://www.reddit.com/r/freshrss/.rss", "http://fedoramagazine.org/" };
2023-04-27 17:23:01 +02:00
}
}