#!/bin/bash
schemaVersion=7
dbPath=~/.var/app/org.gnome.FeedReader/data/feedreader/data/feedreader-${schemaVersion}.db
sqlite3 -csv ${dbPath} 'select name,url,xmlURL,categories.title as category from feeds LEFT JOIN categories ON feeds.category_id=categories.categorieID ORDER BY category' | perl <(cat <<'EOF'
use HTML::Entities;
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
print "<opml version=\"1.0\">\n";
print "<head>\n";
print " <title>FeedReader Exported RSS Feeds</title>\n";
print "</head>\n";
print "<body>\n";
$lastCategory = "";
$currentCategory = "";
while(<>) {
chomp;
my @line = split /,/;
$title = $line[0];
$title =~ tr/"//d; # strip qutoes
$title = encode_entities($title); # encode special characters
$currentCategory = $line[3];
$currentCategory =~ tr/"//d; # strip qutoes
$currentCategory = encode_entities($currentCategory); # encode special characters
print " </outline>\n" if ($lastCategory ne $currentCategory && $lastCategory ne "");
print " <outline title=\"$currentCategory\" text=\"$currentCategory\">\n" if ($lastCategory ne $currentCategory);
print " <outline title=\"$title\" text=\"$title\" type=\"rss\" htmlUrl=\"$line[1]\" xmlUrl=\"$line[2]\" />\n";
$lastCategory = $currentCategory;
}
print " </outline>\n" if ($currentCategory ne "");
print "</body>\n";
print "</opml>\n";
EOF
)
Comments