Nextcloud News Filter

If you use Nextcloud News for following online feeds (RSS and/or Atom) or maybe podcasts, this could be for you.

Some feeds are very interesting, but sometimes also contain advertisements or simply uninteresting articles? Of course you can ignore them, but with this small script you also can set up rules which mark these items as read so you don’t see them at all. This script was my answer to a lengthy discussion about adding a similar feature directly to Nextcloud News, which after 3 years still led to nothing…

It makes use of the Nextcloud News API which requires authentication, so you need to supply your Nextcloud username and password. And then the fun starts – you can define as many filters as you want, each with a descriptive title, and choose between the following criteria for matching feed items:

  • feedId: Apply the filter only on one specific feed. You can find out the number you should enter here by hovering your mouse over the feed name in the sidebar in Nextcloud News. The URL shown at the bottom of your browser ends in the right number, e.g. .../items/feeds/32/ – here, the feed ID is 32.
  • titleRegex: Check if some part of the item title matches this regular expression (case-insensitively).
  • bodyRegex: Check if some part of the item body matches this regular expression (case-insensitively).
  • hoursAge: Match items older than this (in the feed item, pubDate is checked, not updatedDate or lastModified).

Each criterion only can be used once per filter, so if you want to e.g. apply a titleRegex filter to 3 feeds, you have to create 3 separate filters with the same titleRegex and the respective different feedIds. For more details about the configuration, see the README file in the project’s repository. That’s also the place where you can get the script and an example config file. It’s possible to run everything either on bare metal (maybe using a venv) or inside a container. Cron is advised to execute the filters regularly, also have a look at the README for more on that.