UP | HOME

How to bulk import RSS feeds to gnus via gwene

gwene.org is a service which bridges RSS->NNTP. I have a big ole list of a couple hundred RSS feeds I read through gwene, using gnus. This is my hacky way of importing feeds into gwene, and subscribing to them in gnus.

Create/find the NNTP feeds on gwene

gwene.org supports bulk uploads with opml, but I could never make it work, it just fails silently, maybe there's something wrong with how I formatted my opml file. Luckily, the HTML page is simple and easily automated with perl.

#!/usr/bin/perl

my $gwene_url = "gwene.org";

while(<>) {
    chomp;
    $feed_url = $_;
    my $p1_content = `curl -d "url=$feed_url&confirm=Sign Up" $gwene_url 2>/dev/null`;
    $p1_content =~ /group value="([^"]+)"/;
    my $group = $1;
    my $p2_content = `curl -d "url=$feed_url&confirm=Sign Up&group=$group" $gwene_url 2>/dev/null`;
    if ($p2_content =~ /already subscribed as ([^ ]+)/) {
        print "$1\n";
    } else {
        print "$group\n";
    }
}

I run this against my list of feeds, and redirect the output to a new file which I'll use to subscribe to the feeds:

./upload_to_gwene.pl rss_feeds.txt > gwene_feeds.txt

Subscribe to your feeds in gnus

Here's a simple interactive elisp function you can use to import NNTP feeds from gwene_feeds.txt (or any plaintext list of NNTP feeds).

(defun slurp (file)
  "Read FILE into a string."
  (with-temp-buffer
    (insert-file-contents file)
    (buffer-substring-no-properties
     (point-min)
     (point-max))))

(defun gnus-import-feed-list (path)
  "Import list of NNTP feeds from file at PATH."
  (interactive "F")
  (let ((feeds (split-string (slurp path) "\n" t)))
    (cl-loop for feed in feeds
             do (gnus-subscribe-group feed))))

To add a feed, append it to rss_feeds.txt, and repeat this process.

This is pretty hacky but totally serviceable. Wrapping the bash/perl stuff in interactive elisp functions would be nice improvement.