Sagara.FeedReader 1.0.0-alpha5

This is a prerelease version of Sagara.FeedReader.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Sagara.FeedReader --version 1.0.0-alpha5                
NuGet\Install-Package Sagara.FeedReader -Version 1.0.0-alpha5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sagara.FeedReader" Version="1.0.0-alpha5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sagara.FeedReader --version 1.0.0-alpha5                
#r "nuget: Sagara.FeedReader, 1.0.0-alpha5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Sagara.FeedReader as a Cake Addin
#addin nuget:?package=Sagara.FeedReader&version=1.0.0-alpha5&prerelease

// Install Sagara.FeedReader as a Cake Tool
#tool nuget:?package=Sagara.FeedReader&version=1.0.0-alpha5&prerelease                

Sagara.FeedReader

publish

Sagara.FeedReader is a .NET library used for reading and parsing RSS and ATOM feeds. Supports RSS 0.91, 0.92, 1.0, 2.0 and ATOM.

Requirements

.NET 8

NuGet Package

NuGet

For Sagara.FeedReader API docs generated from XML comments, see the GitHub repo.

*** Forked from CodeHollow.FeedReader ***

This is a heavily-modified fork of CodeHollow.FeedReader. The biggest difference is that it uses .NET's dependency injection framework to manage HttpClient instead of storing it in a static variable. I also did a fair bit of refactoring and used more modern code constructs in some places.

This version only supports .NET 8 and higher. If you don't need .NET's DI capabilities, or you need support for earlier versions of .NET / .NET Framework, please use the original package:

https://github.com/arminreiter/FeedReader

Original readme follows.


FeedReader

FeedReader is a .net library used for reading and parsing RSS and ATOM feeds. Supports RSS 0.91, 0.92, 1.0, 2.0 and ATOM. Developed because tested existing libraries do not work with different languages, encodings or have other issues. Library tested with multiple languages, encodings and feeds.

FeedReader library is available as NuGet package: https://www.nuget.org/packages/CodeHollow.FeedReader/

Usage

The simplest way to read a feed and show the information is:

    var feed = await FeedReader.ReadAsync("https://arminreiter.com/feed");

    Console.WriteLine("Feed Title: " + feed.Title);
    Console.WriteLine("Feed Description: " + feed.Description);
    Console.WriteLine("Feed Image: " + feed.ImageUrl);
    // ...
    foreach(var item in feed.Items)
    {
        Console.WriteLine(item.Title + " - " + item.Link);
    }

There are some properties that are only available in e.g. RSS 2.0. If you want to get those properties, the property "SpecificFeed" is the right one:

    var feed = await FeedReader.ReadAsync("https://arminreiter.com/feed");

    Console.WriteLine("Feed Title: " + feed.Title);
            
    if(feed.Type == FeedType.Rss_2_0)
    {
        var rss20feed = (Feeds.Rss20Feed)feed.SpecificFeed;
        Console.WriteLine("Generator: " + rss20feed.Generator);
    }

If the url to the feed is not known, then you can use FeedReader.GetFeedUrlsFromUrl(url) to parse the url from the html webpage:

    string url = "arminreiter.com";
    var urls = FeedReader.GetFeedUrlsFromUrl(url);
            
    string feedUrl;
    if (urls.Count() < 1) // no url - probably the url is already the right feed url
        feedUrl = url;
    else if (urls.Count() == 1)
        feedUrl = urls.First().Url;
    else if (urls.Count() == 2) // if 2 urls, then its usually a feed and a comments feed, so take the first per default
        feedUrl = urls.First().Url;
    else
    {
        // show all urls and let the user select (or take the first or ...)
        // ...
    }

    var readerTask = FeedReader.ReadAsync(feedUrl);
    readerTask.ConfigureAwait(false);

    foreach (var item in readerTask.Result.Items)
    {
        Console.WriteLine(item.Title + " - " + item.Link);
        // ...
    }

The code contains a sample console application: https://github.com/codehollow/FeedReader/tree/master/FeedReader.StaticConsoleSample

Specifications

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.0 83 12/13/2024
2.1.0-alpha1 53 10/30/2024
2.0.0 107 10/15/2024
1.1.1 80 10/15/2024
1.1.0 91 10/14/2024
1.0.0 117 9/2/2024
1.0.0-alpha6 95 8/31/2024
1.0.0-alpha5 110 3/12/2024
1.0.0-alpha4 107 2/20/2024
1.0.0-alpha3 145 1/10/2024
1.0.0-alpha2 105 1/10/2024
1.0.0-alpha1 117 1/4/2024