From 6d50386eba636b2b467179871c8db4875711c93c Mon Sep 17 00:00:00 2001 From: Chris Kaczor Date: Sat, 15 Nov 2025 20:06:01 -0500 Subject: [PATCH] Initial commit --- .gitignore | 484 +++++++++++++++++++++++++ LICENSE | 21 ++ Library/EnumExtensions.cs | 27 ++ Library/FeedEntryStatus.cs | 12 + Library/MinifluxClient.cs | 101 ++++++ Library/MinifluxClient.csproj | 34 ++ Library/MinifluxClient.sln.DotSettings | 3 + Library/Models/Category.cs | 20 + Library/Models/Enclosure.cs | 26 ++ Library/Models/EntriesResponse.cs | 14 + Library/Models/Entry.cs | 65 ++++ Library/Models/Feed.cs | 131 +++++++ Library/Models/Icon.cs | 17 + Library/QueryParameterNameAttribute.cs | 7 + Library/Requests/UpdateEntryRequest.cs | 13 + Library/SortDirection.cs | 21 ++ Library/SortField.cs | 30 ++ MinifluxClient.sln | 38 ++ MinifluxClient.sln.DotSettings | 3 + README.md | 17 + Test/MSTestSettings.cs | 1 + Test/Test.csproj | 22 ++ Test/Test1.cs | 22 ++ azure-pipelines.yml | 63 ++++ 24 files changed, 1192 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 Library/EnumExtensions.cs create mode 100644 Library/FeedEntryStatus.cs create mode 100644 Library/MinifluxClient.cs create mode 100644 Library/MinifluxClient.csproj create mode 100644 Library/MinifluxClient.sln.DotSettings create mode 100644 Library/Models/Category.cs create mode 100644 Library/Models/Enclosure.cs create mode 100644 Library/Models/EntriesResponse.cs create mode 100644 Library/Models/Entry.cs create mode 100644 Library/Models/Feed.cs create mode 100644 Library/Models/Icon.cs create mode 100644 Library/QueryParameterNameAttribute.cs create mode 100644 Library/Requests/UpdateEntryRequest.cs create mode 100644 Library/SortDirection.cs create mode 100644 Library/SortField.cs create mode 100644 MinifluxClient.sln create mode 100644 MinifluxClient.sln.DotSettings create mode 100644 README.md create mode 100644 Test/MSTestSettings.cs create mode 100644 Test/Test.csproj create mode 100644 Test/Test1.cs create mode 100644 azure-pipelines.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bc78471 --- /dev/null +++ b/.gitignore @@ -0,0 +1,484 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from `dotnet new gitignore` + +# dotenv files +.env + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET +project.lock.json +project.fragment.lock.json +artifacts/ + +# Tye +.tye/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml +.idea/ + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# Mac bundle stuff +*.dmg +*.app + +# content below from: https://github.com/github/gitignore/blob/main/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/main/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# Vim temporary swap files +*.swp diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c3e95b8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Chris Kaczor + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Library/EnumExtensions.cs b/Library/EnumExtensions.cs new file mode 100644 index 0000000..8edf08c --- /dev/null +++ b/Library/EnumExtensions.cs @@ -0,0 +1,27 @@ +using System.Reflection; + +namespace ChrisKaczor.MinifluxClient; + +internal static class EnumExtensions +{ + internal static TAttribute? GetAttribute(this Enum enumValue) where TAttribute : Attribute + { + var type = enumValue.GetType(); + + var name = Enum.GetName(type, enumValue); + + if (name == null) + return null; + + var field = type.GetField(name); + + var attribute = field?.GetCustomAttribute(); + + return attribute; + } + + extension(T value) where T : Enum + { + internal string QueryPropertyName => value.GetAttribute()?.Name ?? string.Empty; + } +} \ No newline at end of file diff --git a/Library/FeedEntryStatus.cs b/Library/FeedEntryStatus.cs new file mode 100644 index 0000000..26806e2 --- /dev/null +++ b/Library/FeedEntryStatus.cs @@ -0,0 +1,12 @@ +using System.Text.Json.Serialization; + +namespace ChrisKaczor.MinifluxClient; + +public enum FeedEntryStatus +{ + [JsonStringEnumMemberName("read")] + Read, + + [JsonStringEnumMemberName("unread")] + Unread +} \ No newline at end of file diff --git a/Library/MinifluxClient.cs b/Library/MinifluxClient.cs new file mode 100644 index 0000000..5bf57f3 --- /dev/null +++ b/Library/MinifluxClient.cs @@ -0,0 +1,101 @@ +using ChrisKaczor.MinifluxClient.Models; +using RestSharp; +using System.Text.Json; + +namespace ChrisKaczor.MinifluxClient; + +public class MinifluxClient +{ + private readonly JsonSerializerOptions _jsonSerializerOptions; + private readonly RestClient _restClient; + + public MinifluxClient(string url, string apiKey) + { + _jsonSerializerOptions = new JsonSerializerOptions(); + + _restClient = new RestClient(url); + _restClient.AddDefaultHeader("X-Auth-Token", apiKey); + } + + private async Task ExecuteRestRequest(string api, Method method, IEnumerable? parameters, object? body) + { + var request = new RestRequest($"/v1/{api}", method); + + if (parameters != null) + { + foreach (var parameter in parameters) + { + request.AddParameter(parameter); + } + } + + if (body != null) + { + var bodyJson = JsonSerializer.Serialize(body, _jsonSerializerOptions); + request.AddStringBody(bodyJson, DataFormat.Json); + } + + var response = await _restClient.ExecuteAsync(request); + + if (response == null) + throw new Exception("Failed to get response from API"); + + if (!response.IsSuccessStatusCode) + throw new Exception($"Error: {response.StatusCode} - {response.Content}"); + + if (response.Content == null) + throw new Exception("Response content is null"); + + if (string.IsNullOrWhiteSpace(response.Content)) + return default; + + try + { + var responseObject = JsonSerializer.Deserialize(response.Content, _jsonSerializerOptions); + + return responseObject ?? throw new Exception($"Failed to deserialize response content - {response.Content}"); + } + catch (Exception e) + { + throw new Exception($"Failed to deserialize response content - {response.Content}", e); + } + } + + public async Task> GetCategories() + { + var response = await ExecuteRestRequest>("categories", Method.Get, null, null); + + return response ?? []; + } + + public async Task> GetFeeds() + { + var response = await ExecuteRestRequest>("feeds", Method.Get, null, null); + + return response ?? []; + } + + public async Task> GetFeedEntries(long feedId, SortField sortField, SortDirection sortDirection) + { + var parameters = new List + { + new QueryParameter(SortField.QueryParameterName, sortField.QueryPropertyName), + new QueryParameter(SortDirection.QueryParameterName, sortDirection.QueryPropertyName) + }; + + var response = await ExecuteRestRequest($"feeds/{feedId}/entries", Method.Get, parameters, null); + + return response?.Entries ?? []; + } + + public async Task MarkFeedEntries(IEnumerable entryIds, FeedEntryStatus status) + { + var updateEntryRequest = new Requests.UpdateEntryRequest + { + EntryIds = entryIds, + Status = status + }; + + await ExecuteRestRequest("entries", Method.Put, null, updateEntryRequest); + } +} \ No newline at end of file diff --git a/Library/MinifluxClient.csproj b/Library/MinifluxClient.csproj new file mode 100644 index 0000000..0a65a83 --- /dev/null +++ b/Library/MinifluxClient.csproj @@ -0,0 +1,34 @@ + + + + net10.0 + enable + enable + ChrisKaczor.MinifluxClient + ChrisKaczor.MinifluxClient + Chris Kaczor + ChrisKaczor.MinifluxClient + https://github.com/ckaczor/ChrisKaczor.MinifluxClient + README.md + This library can be used to read RSS feeds via the Miniflux API. + ChrisKaczor.MinifluxClient + ChrisKaczor.MinifluxClient + + + + + + + + + + + + + + True + \ + + + + diff --git a/Library/MinifluxClient.sln.DotSettings b/Library/MinifluxClient.sln.DotSettings new file mode 100644 index 0000000..498ab5c --- /dev/null +++ b/Library/MinifluxClient.sln.DotSettings @@ -0,0 +1,3 @@ + + True + True \ No newline at end of file diff --git a/Library/Models/Category.cs b/Library/Models/Category.cs new file mode 100644 index 0000000..508d7ef --- /dev/null +++ b/Library/Models/Category.cs @@ -0,0 +1,20 @@ +using JetBrains.Annotations; +using System.Text.Json.Serialization; + +namespace ChrisKaczor.MinifluxClient.Models; + +[PublicAPI] +public class Category +{ + [JsonPropertyName("id")] + public required long Id { get; set; } + + [JsonPropertyName("title")] + public required string Title { get; set; } + + [JsonPropertyName("user_id")] + public required long UserId { get; set; } + + [JsonPropertyName("hide_globally")] + public required bool HideGlobally { get; set; } +} \ No newline at end of file diff --git a/Library/Models/Enclosure.cs b/Library/Models/Enclosure.cs new file mode 100644 index 0000000..4b81855 --- /dev/null +++ b/Library/Models/Enclosure.cs @@ -0,0 +1,26 @@ +using JetBrains.Annotations; +using System.Text.Json.Serialization; + +namespace ChrisKaczor.MinifluxClient.Models; + +[PublicAPI] +public class Enclosure +{ + [JsonPropertyName("id")] + public required long Id { get; set; } + + [JsonPropertyName("user_id")] + public required long UserId { get; set; } + + [JsonPropertyName("entry_id")] + public required long EntryId { get; set; } + + [JsonPropertyName("url")] + public required string Url { get; set; } + + [JsonPropertyName("mime_type")] + public required string MimeType { get; set; } + + [JsonPropertyName("size")] + public required long Size { get; set; } +} \ No newline at end of file diff --git a/Library/Models/EntriesResponse.cs b/Library/Models/EntriesResponse.cs new file mode 100644 index 0000000..9e5ef1f --- /dev/null +++ b/Library/Models/EntriesResponse.cs @@ -0,0 +1,14 @@ +using JetBrains.Annotations; +using System.Text.Json.Serialization; + +namespace ChrisKaczor.MinifluxClient.Models; + +[PublicAPI] +public class EntriesResponse +{ + [JsonPropertyName("total")] + public required int Total { get; set; } + + [JsonPropertyName("entries")] + public required List Entries { get; set; } +} \ No newline at end of file diff --git a/Library/Models/Entry.cs b/Library/Models/Entry.cs new file mode 100644 index 0000000..c2fbe32 --- /dev/null +++ b/Library/Models/Entry.cs @@ -0,0 +1,65 @@ +using JetBrains.Annotations; +using System.Text.Json.Serialization; + +namespace ChrisKaczor.MinifluxClient.Models; + +[PublicAPI] +public class Entry +{ + [JsonPropertyName("id")] + public required long Id { get; set; } + + [JsonPropertyName("user_id")] + public required long UserId { get; set; } + + [JsonPropertyName("feed_id")] + public required long FeedId { get; set; } + + [JsonPropertyName("status")] + public required string Status { get; set; } + + [JsonPropertyName("hash")] + public required string Hash { get; set; } + + [JsonPropertyName("title")] + public required string Title { get; set; } + + [JsonPropertyName("url")] + public required string Url { get; set; } + + [JsonPropertyName("comments_url")] + public required string CommentsUrl { get; set; } + + [JsonPropertyName("published_at")] + public required DateTimeOffset PublishedAt { get; set; } + + [JsonPropertyName("created_at")] + public required DateTimeOffset CreatedAt { get; set; } + + [JsonPropertyName("changed_at")] + public required DateTimeOffset ChangedAt { get; set; } + + [JsonPropertyName("content")] + public required string Content { get; set; } + + [JsonPropertyName("author")] + public required string Author { get; set; } + + [JsonPropertyName("share_code")] + public required string ShareCode { get; set; } + + [JsonPropertyName("starred")] + public required bool Starred { get; set; } + + [JsonPropertyName("reading_time")] + public required int ReadingTime { get; set; } + + [JsonPropertyName("enclosures")] + public required List Enclosures { get; set; } + + [JsonPropertyName("feed")] + public required Feed Feed { get; set; } + + [JsonPropertyName("tags")] + public required List Tags { get; set; } +} \ No newline at end of file diff --git a/Library/Models/Feed.cs b/Library/Models/Feed.cs new file mode 100644 index 0000000..5697749 --- /dev/null +++ b/Library/Models/Feed.cs @@ -0,0 +1,131 @@ +using JetBrains.Annotations; +using System.Text.Json.Serialization; + +namespace ChrisKaczor.MinifluxClient.Models; + +[PublicAPI] +public class Feed +{ + [JsonPropertyName("id")] + public required long Id { get; set; } + + [JsonPropertyName("user_id")] + public required long UserId { get; set; } + + [JsonPropertyName("feed_url")] + public required string FeedUrl { get; set; } + + [JsonPropertyName("site_url")] + public required string SiteUrl { get; set; } + + [JsonPropertyName("title")] + public required string Title { get; set; } + + [JsonPropertyName("description")] + public required string Description { get; set; } + + [JsonPropertyName("checked_at")] + public required DateTimeOffset CheckedAt { get; set; } + + [JsonPropertyName("next_check_at")] + public required DateTimeOffset NextCheckAt { get; set; } + + [JsonPropertyName("etag_header")] + public required string EtagHeader { get; set; } + + [JsonPropertyName("last_modified_header")] + public required string LastModifiedHeader { get; set; } + + [JsonPropertyName("parsing_error_message")] + public required string ParsingErrorMessage { get; set; } + + [JsonPropertyName("parsing_error_count")] + public required int ParsingErrorCount { get; set; } + + [JsonPropertyName("scraper_rules")] + public required string ScraperRules { get; set; } + + [JsonPropertyName("rewrite_rules")] + public required string RewriteRules { get; set; } + + [JsonPropertyName("blocklist_rules")] + public required string BlocklistRules { get; set; } + + [JsonPropertyName("keeplist_rules")] + public required string KeeplistRules { get; set; } + + [JsonPropertyName("block_filter_entry_rules")] + public required string BlockFilterEntryRules { get; set; } + + [JsonPropertyName("keep_filter_entry_rules")] + public required string KeepFilterEntryRules { get; set; } + + [JsonPropertyName("urlrewrite_rules")] + public required string UrlrewriteRules { get; set; } + + [JsonPropertyName("user_agent")] + public required string UserAgent { get; set; } + + [JsonPropertyName("cookie")] + public required string Cookie { get; set; } + + [JsonPropertyName("username")] + public required string Username { get; set; } + + [JsonPropertyName("password")] + public required string Password { get; set; } + + [JsonPropertyName("disabled")] + public required bool Disabled { get; set; } + + [JsonPropertyName("no_media_player")] + public required bool NoMediaPlayer { get; set; } + + [JsonPropertyName("ignore_http_cache")] + public required bool IgnoreHttpCache { get; set; } + + [JsonPropertyName("allow_self_signed_certificates")] + public required bool AllowSelfSignedCertificates { get; set; } + + [JsonPropertyName("fetch_via_proxy")] + public required bool FetchViaProxy { get; set; } + + [JsonPropertyName("hide_globally")] + public required bool HideGlobally { get; set; } + + [JsonPropertyName("disable_http2")] + public required bool DisableHttp2 { get; set; } + + [JsonPropertyName("pushover_enabled")] + public required bool PushoverEnabled { get; set; } + + [JsonPropertyName("ntfy_enabled")] + public required bool NtfyEnabled { get; set; } + + [JsonPropertyName("crawler")] + public required bool Crawler { get; set; } + + [JsonPropertyName("apprise_service_urls")] + public required string AppriseServiceUrls { get; set; } + + [JsonPropertyName("webhook_url")] + public required string WebhookUrl { get; set; } + + [JsonPropertyName("ntfy_priority")] + public required int NtfyPriority { get; set; } + + [JsonPropertyName("ntfy_topic")] + public required string NtfyTopic { get; set; } + + [JsonPropertyName("pushover_priority")] + public required int PushoverPriority { get; set; } + + [JsonPropertyName("proxy_url")] + public required string ProxyUrl { get; set; } + + [JsonPropertyName("category")] + public required Category Category { get; set; } + + [JsonPropertyName("icon")] + public required Icon Icon { get; set; } +} \ No newline at end of file diff --git a/Library/Models/Icon.cs b/Library/Models/Icon.cs new file mode 100644 index 0000000..3c81d2c --- /dev/null +++ b/Library/Models/Icon.cs @@ -0,0 +1,17 @@ +using JetBrains.Annotations; +using System.Text.Json.Serialization; + +namespace ChrisKaczor.MinifluxClient.Models; + +[PublicAPI] +public class Icon +{ + [JsonPropertyName("feed_id")] + public required long FeedId { get; set; } + + [JsonPropertyName("icon_id")] + public required long IconId { get; set; } + + [JsonPropertyName("external_icon_id")] + public required string ExternalIconId { get; set; } +} \ No newline at end of file diff --git a/Library/QueryParameterNameAttribute.cs b/Library/QueryParameterNameAttribute.cs new file mode 100644 index 0000000..4201ba9 --- /dev/null +++ b/Library/QueryParameterNameAttribute.cs @@ -0,0 +1,7 @@ +namespace ChrisKaczor.MinifluxClient; + +[AttributeUsage(AttributeTargets.Enum | AttributeTargets.Field)] +internal class QueryParameterNameAttribute(string name) : Attribute +{ + public string Name { get; } = name; +} \ No newline at end of file diff --git a/Library/Requests/UpdateEntryRequest.cs b/Library/Requests/UpdateEntryRequest.cs new file mode 100644 index 0000000..eb20052 --- /dev/null +++ b/Library/Requests/UpdateEntryRequest.cs @@ -0,0 +1,13 @@ +using System.Text.Json.Serialization; + +namespace ChrisKaczor.MinifluxClient.Requests; + +public class UpdateEntryRequest +{ + [JsonPropertyName("entry_ids")] + public required IEnumerable EntryIds { get; set; } + + [JsonPropertyName("status")] + [JsonConverter(typeof(JsonStringEnumConverter))] + public required FeedEntryStatus Status { get; set; } +} \ No newline at end of file diff --git a/Library/SortDirection.cs b/Library/SortDirection.cs new file mode 100644 index 0000000..bd0ea32 --- /dev/null +++ b/Library/SortDirection.cs @@ -0,0 +1,21 @@ +using System.Reflection; + +namespace ChrisKaczor.MinifluxClient; + +[QueryParameterName("direction")] +public enum SortDirection +{ + [QueryParameterName("asc")] + Ascending, + + [QueryParameterName("desc")] + Descending +} + +internal static class SortDirectionExtensions +{ + extension(SortDirection) + { + internal static string QueryParameterName => typeof(SortDirection).GetCustomAttribute()?.Name ?? throw new InvalidOperationException(); + } +} \ No newline at end of file diff --git a/Library/SortField.cs b/Library/SortField.cs new file mode 100644 index 0000000..e82f0b7 --- /dev/null +++ b/Library/SortField.cs @@ -0,0 +1,30 @@ +using System.Reflection; + +namespace ChrisKaczor.MinifluxClient; + +[QueryParameterName("order")] +public enum SortField +{ + [QueryParameterName("id")] + Id, + + [QueryParameterName("status")] + Status, + + [QueryParameterName("published_at")] + PublishedAt, + + [QueryParameterName("category_title")] + CategoryTitle, + + [QueryParameterName("category_id")] + CategoryId +} + +internal static class SortFieldExtensions +{ + extension(SortField) + { + internal static string QueryParameterName => typeof(SortField).GetCustomAttribute()?.Name ?? throw new InvalidOperationException(); + } +} \ No newline at end of file diff --git a/MinifluxClient.sln b/MinifluxClient.sln new file mode 100644 index 0000000..3901569 --- /dev/null +++ b/MinifluxClient.sln @@ -0,0 +1,38 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 18 +VisualStudioVersion = 18.0.11018.127 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinifluxClient", "Library\MinifluxClient.csproj", "{85FE0D62-97D7-43DD-AC1B-F596762D0E33}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{206AEC91-0AFD-4E4B-AB88-853599C08D86}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{19E773CA-D190-46D9-8B87-05DB359562FC}" + ProjectSection(SolutionItems) = preProject + azure-pipelines.yml = azure-pipelines.yml + LICENSE = LICENSE + README.md = README.md + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {85FE0D62-97D7-43DD-AC1B-F596762D0E33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {85FE0D62-97D7-43DD-AC1B-F596762D0E33}.Debug|Any CPU.Build.0 = Debug|Any CPU + {85FE0D62-97D7-43DD-AC1B-F596762D0E33}.Release|Any CPU.ActiveCfg = Release|Any CPU + {85FE0D62-97D7-43DD-AC1B-F596762D0E33}.Release|Any CPU.Build.0 = Release|Any CPU + {206AEC91-0AFD-4E4B-AB88-853599C08D86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {206AEC91-0AFD-4E4B-AB88-853599C08D86}.Debug|Any CPU.Build.0 = Debug|Any CPU + {206AEC91-0AFD-4E4B-AB88-853599C08D86}.Release|Any CPU.ActiveCfg = Release|Any CPU + {206AEC91-0AFD-4E4B-AB88-853599C08D86}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F01F2A17-ECF5-4F99-A61E-633332945FB2} + EndGlobalSection +EndGlobal diff --git a/MinifluxClient.sln.DotSettings b/MinifluxClient.sln.DotSettings new file mode 100644 index 0000000..498ab5c --- /dev/null +++ b/MinifluxClient.sln.DotSettings @@ -0,0 +1,3 @@ + + True + True \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..157226e --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# ChrisKaczor.MinifluxClient + +This library can be used to read RSS feeds via the Miniflux API in [Miniflux](https://miniflux.app/index.html) or other similar feed readers/servers. + +Not fully implemented (at least so far) and only tested with [Miniflux](https://miniflux.app/index.html) but works for my needs in [Feed Center](http://github.com/ckaczor/FeedCenter). + +## Authors + +* **Chris Kaczor** - *Initial work* - https://github.com/ckaczor - https://chriskaczor.com + +## License + +This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details. + +## Disclaimer + +This code is used by my various personal projects and may not be useful or work in all use cases. \ No newline at end of file diff --git a/Test/MSTestSettings.cs b/Test/MSTestSettings.cs new file mode 100644 index 0000000..aaf278c --- /dev/null +++ b/Test/MSTestSettings.cs @@ -0,0 +1 @@ +[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)] diff --git a/Test/Test.csproj b/Test/Test.csproj new file mode 100644 index 0000000..d26d87f --- /dev/null +++ b/Test/Test.csproj @@ -0,0 +1,22 @@ + + + + net10.0 + latest + enable + enable + + + + + + + + + + + + + + + diff --git a/Test/Test1.cs b/Test/Test1.cs new file mode 100644 index 0000000..9dcad43 --- /dev/null +++ b/Test/Test1.cs @@ -0,0 +1,22 @@ +using ChrisKaczor.MinifluxClient; + +namespace Test; + +[TestClass] +public sealed class Test +{ + [TestMethod] + public async Task TestMethod1() + { + var client = new MinifluxClient("", ""); + + var categories = await client.GetCategories(); + + var feeds = await client.GetFeeds(); + + foreach (var feed in feeds) + { + var feedEntries = await client.GetFeedEntries(feed.Id, SortField.PublishedAt, SortDirection.Descending); + } + } +} \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 0000000..0cba7e9 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,63 @@ +name: 1.0.$(Rev:r) + +pr: none + +trigger: + batch: 'true' + branches: + include: + - main + +pool: + vmImage: 'windows-latest' + +variables: + buildConfiguration: 'Release' + +steps: +- task: GetRevision@1 + displayName: 'Get Revision' + inputs: + VariableName: Revision + +- task: Assembly-Info-NetCore@3 + displayName: 'Set Assembly Info' + inputs: + Path: '$(Build.SourcesDirectory)' + FileNames: 'Library\*.csproj' + InsertAttributes: true + FileEncoding: 'utf-8' + WriteBOM: true + FailOnWarning: true + Authors: 'Chris Kaczor' + Copyright: 'Copyright $(date:YYYY) Chris Kaczor' + FileVersion: '1.0.$(Revision)' + PackageVersion: '1.0.$(Revision)' + +- task: DotNetCoreCLI@2 + displayName: 'dotnet build' + inputs: + command: 'build' + arguments: '--configuration $(buildConfiguration)' + projects: 'Library\MinifluxClient.csproj' + +- task: DotNetCoreCLI@2 + displayName: "dotnet pack" + inputs: + command: 'pack' + arguments: '--configuration $(buildConfiguration)' + packagesToPack: 'Library\MinifluxClient.csproj' + nobuild: true + versioningScheme: 'byBuildNumber' + +- task: NuGetCommand@2 + displayName: 'nuget push' + inputs: + command: 'push' + feedsToUse: 'select' + packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg' + nuGetFeedType: external + publishFeedCredentials: 'NuGet' + publishVstsFeed: 'Packages' + versioningScheme: 'byBuildNumber' + allowPackageConflicts: true \ No newline at end of file