Kurobeats

feed-to-opml.sh

Oct 21st, 2018
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.40 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. schemaVersion=7
  4. dbPath=~/.var/app/org.gnome.FeedReader/data/feedreader/data/feedreader-${schemaVersion}.db
  5.  
  6. 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'
  7. use HTML::Entities;
  8. print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
  9. print "<opml version=\"1.0\">\n";
  10. print "<head>\n";
  11. print "    <title>FeedReader Exported RSS Feeds</title>\n";
  12. print "</head>\n";
  13. print "<body>\n";
  14. $lastCategory = "";
  15. $currentCategory = "";
  16. while(<>) {
  17.     chomp;
  18.     my @line = split /,/;
  19.     $title = $line[0];
  20.     $title =~ tr/"//d; # strip qutoes
  21.     $title =  encode_entities($title); # encode special characters
  22.     $currentCategory = $line[3];
  23.     $currentCategory =~ tr/"//d; # strip qutoes
  24.     $currentCategory =  encode_entities($currentCategory); # encode special characters
  25.     print "    </outline>\n" if ($lastCategory ne $currentCategory && $lastCategory ne "");
  26.     print "    <outline title=\"$currentCategory\" text=\"$currentCategory\">\n" if ($lastCategory ne $currentCategory);
  27.     print "        <outline title=\"$title\" text=\"$title\" type=\"rss\" htmlUrl=\"$line[1]\" xmlUrl=\"$line[2]\" />\n";
  28.  
  29.     $lastCategory = $currentCategory;
  30. }
  31. print "    </outline>\n" if ($currentCategory ne "");
  32. print "</body>\n";
  33. print "</opml>\n";
  34. EOF
  35. )
Advertisement
Add Comment
Please, Sign In to add comment