mirror of
https://github.com/hmaxnl/SharpRSS.git
synced 2025-01-18 21:04:21 +01:00
Moved to Argotic
This commit is contained in:
parent
323486f36d
commit
825af3a0b3
|
@ -155,12 +155,8 @@ namespace SharpRss
|
|||
new SqliteParameter("originalDoc", feedModel.OriginalDocument ?? string.Empty)
|
||||
}
|
||||
};
|
||||
/*await using SqliteDataReader reader = await cmd.ExecuteReaderAsync();*/
|
||||
await cmd.ExecuteNonQueryAsync();
|
||||
}
|
||||
|
||||
/*if (reader.Read())
|
||||
resultModel = await ReaderToFeedModel(reader);*/
|
||||
await transaction.CommitAsync();
|
||||
return resultModel;
|
||||
}
|
||||
|
@ -221,6 +217,7 @@ namespace SharpRss
|
|||
}
|
||||
return feedItems;
|
||||
}
|
||||
|
||||
public static async Task<int> SetFeedItemsAsync(HashSet<FeedItemModel> items)
|
||||
{
|
||||
int result = 0;
|
||||
|
|
|
@ -2,7 +2,8 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using CodeHollow.FeedReader;
|
||||
using Argotic.Common;
|
||||
using Argotic.Syndication;
|
||||
using Serilog;
|
||||
using SharpRss.Models;
|
||||
|
||||
|
@ -31,58 +32,15 @@ namespace SharpRss.Services
|
|||
//TODO: Need to rework this implementation!!!
|
||||
public async Task<bool> AddFeedsAsync(string[]? rssUrls, GroupModel? group = null)
|
||||
{
|
||||
bool result = false;
|
||||
if (rssUrls == null) return result;
|
||||
HashSet<Feed> fetchedFeeds = new HashSet<Feed>();
|
||||
foreach (var rssUrl in rssUrls)
|
||||
fetchedFeeds.Add(await FetchFeed(rssUrl));
|
||||
HashSet<FeedModel> feeds = new HashSet<FeedModel>();
|
||||
HashSet<FeedItemModel> itemModels = new HashSet<FeedItemModel>();
|
||||
|
||||
foreach (var feed in fetchedFeeds)
|
||||
{
|
||||
FeedModel feedModel = new FeedModel(feed.Link)
|
||||
{
|
||||
Title = feed.Title,
|
||||
GroupId = group?.Id ?? string.Empty,
|
||||
FeedType = feed.Type.ToString(),
|
||||
Description = feed.Description,
|
||||
Language = feed.Language,
|
||||
Copyright = feed.Copyright,
|
||||
DateAdded = DateTimeOffset.Now,
|
||||
LastUpdated = DateTimeOffset.Now,
|
||||
ImageUrl = feed.ImageUrl,
|
||||
OriginalDocument = feed.OriginalDocument
|
||||
};
|
||||
|
||||
feeds.Add(feedModel);
|
||||
return false;
|
||||
}
|
||||
/*Feed fetched = await FetchFeed(rssUrl);
|
||||
|
||||
if (fetched == null)
|
||||
return result;
|
||||
FeedModel feedModel = new FeedModel(rssUrl)
|
||||
public async Task UpdateFeeds()
|
||||
{
|
||||
Title = fetched.Title,
|
||||
GroupId = group?.Id ?? string.Empty,
|
||||
FeedType = fetched.Type.ToString(),
|
||||
Description = fetched.Description,
|
||||
Language = fetched.Language,
|
||||
Copyright = fetched.Copyright,
|
||||
DateAdded = DateTimeOffset.Now,
|
||||
LastUpdated = DateTimeOffset.Now,
|
||||
ImageUrl = fetched.ImageUrl,
|
||||
OriginalDocument = fetched.OriginalDocument
|
||||
};
|
||||
FeedModel? dbFeed = await _dbService.SetFeedAsync(feedModel);
|
||||
result = dbFeed != null;
|
||||
if (dbFeed == null)
|
||||
return result;*/
|
||||
//itemModels.Add(ConstructFeedItems());
|
||||
/*if (await AddFeedItems(fetched.Items, dbFeed) == 0)
|
||||
Log.Warning("No feed items added to feed: {FeedUrl}", dbFeed.Url);*/
|
||||
return result;
|
||||
Log.Verbose("Fetching feeds...");
|
||||
var feeds = await GetFeedsAsync();
|
||||
}
|
||||
|
||||
public async Task<HashSet<FeedModel>> GetFeedsAsync(string? groupId = null) => await DbAccess.GetFeedsAsync(groupId);
|
||||
public async Task<HashSet<FeedModel>> GetUngroupedFeedsAsync() => await DbAccess.GetFeedsAsync("");
|
||||
|
||||
|
@ -93,7 +51,7 @@ namespace SharpRss.Services
|
|||
return items;
|
||||
}
|
||||
|
||||
private async Task<int> AddFeedItems(IList<FeedItem> items, FeedModel feedModel)
|
||||
/*private async Task<int> AddFeedItems(IList<FeedItem> items, FeedModel feedModel)
|
||||
{
|
||||
int result = 0;
|
||||
if (!items.Any())
|
||||
|
@ -102,9 +60,9 @@ namespace SharpRss.Services
|
|||
// TODO: implement!!!
|
||||
result = await DbAccess.SetFeedItemsAsync(itemModels);
|
||||
return result;
|
||||
}
|
||||
}*/
|
||||
|
||||
private IList<FeedItemModel> ConstructFeedItems(IList<FeedItem> items, FeedModel feed)
|
||||
/*private IList<FeedItemModel> ConstructFeedItems(IList<FeedItem> items, FeedModel feed)
|
||||
{
|
||||
IList<FeedItemModel> itemModels = new List<FeedItemModel>();
|
||||
if (!items.Any())
|
||||
|
@ -126,16 +84,19 @@ namespace SharpRss.Services
|
|||
});
|
||||
}
|
||||
return itemModels;
|
||||
}
|
||||
}*/
|
||||
|
||||
private async Task<Feed> FetchFeed(string url)
|
||||
private GenericSyndicationFeed? CreateFeed(string url)
|
||||
{
|
||||
Log.Verbose("Fetching feed: {FeedUrl}", url);
|
||||
var urls = await FeedReader.ParseFeedUrlsAsStringAsync(url);
|
||||
string feedUrl = url;
|
||||
if (urls.Any())
|
||||
feedUrl = urls.First();
|
||||
return await FeedReader.ReadAsync(feedUrl);
|
||||
Uri feedUri = new Uri(url);
|
||||
Log.Verbose("Checking feed: {FeedUrl}", feedUri.ToString());
|
||||
if (!SyndicationDiscoveryUtility.UriExists(feedUri))
|
||||
{
|
||||
Log.Warning("Feed: {FeedUri} does not exists!", feedUri.ToString());
|
||||
return null;
|
||||
}
|
||||
Log.Verbose("Fetching feed: {FeedUrl}", feedUri.ToString());
|
||||
return GenericSyndicationFeed.Create(new Uri(url));
|
||||
}
|
||||
private async void SetupTestGroupsAndFeedsAsync()
|
||||
{
|
||||
|
@ -160,6 +121,15 @@ namespace SharpRss.Services
|
|||
Log.Error(e, "Error fetching feeds!");
|
||||
throw;
|
||||
}*/
|
||||
var groups = await GetGroupsAsync();
|
||||
GroupModel testGroup = groups.Single(x => x.Name == "News");
|
||||
await AddFeedsAsync(new[]
|
||||
{
|
||||
"https://www.nu.nl/rss/Algemeen",
|
||||
"https://www.nu.nl/rss/Economie",
|
||||
"https://www.nu.nl/rss/Sport",
|
||||
"http://news.google.com/?output=atom"
|
||||
}, testGroup);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CodeHollow.FeedReader" Version="1.2.6" />
|
||||
<PackageReference Include="Argotic.Common" Version="3000.0.5" />
|
||||
<PackageReference Include="Argotic.Core" Version="3000.0.5" />
|
||||
<PackageReference Include="Argotic.Web" Version="2008.0.2" />
|
||||
<PackageReference Include="Dapper" Version="2.0.123" />
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="7.0.5" />
|
||||
|
@ -20,4 +22,8 @@
|
|||
<ProjectReference Include="..\ToolQit\ToolQit\ToolQit.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Core" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
27
SharpRss/SyndicationManager.cs
Normal file
27
SharpRss/SyndicationManager.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using Argotic.Common;
|
||||
using Argotic.Syndication;
|
||||
|
||||
namespace SharpRss
|
||||
{
|
||||
public static class SyndicationManager
|
||||
{
|
||||
public static bool FeedExists(string feedUrl)
|
||||
{
|
||||
Uri feedUri = new Uri(feedUrl);
|
||||
return SyndicationDiscoveryUtility.UriExists(feedUri);
|
||||
}
|
||||
|
||||
public static bool TryGetFeed(string feedUrl, out GenericSyndicationFeed? feed)
|
||||
{
|
||||
feed = null;
|
||||
Uri feedUri = new Uri(feedUrl);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void Test()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
@using SharpRss.Models;
|
||||
@using MudBlazor.Utilities
|
||||
@using CodeHollow.FeedReader
|
||||
@using Serilog
|
||||
@using SharpRss.Services
|
||||
@using WebSharpRSS.Models;
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
<_ContentIncludedByDefault Remove="logs\log_20230525.json" />
|
||||
<_ContentIncludedByDefault Remove="logs\log_20230526.json" />
|
||||
<_ContentIncludedByDefault Remove="logs\log_20230527.json" />
|
||||
<_ContentIncludedByDefault Remove="logs\log_20230529.json" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
Loading…
Reference in New Issue
Block a user