commit beb2121c782375074a8bd5063775eef188a7fade
parent 05425f189f79deaa2184ccd6f93664a16ce8993a
Author: Oscar Benedito <oscar@oscarbenedito.com>
Date:   Thu,  3 Sep 2020 22:14:24 +0200

Change blogroll script for OMPL 2.0

I now use Miniflux. This change fixes the parsing of Miniflux's .ompl.

Diffstat:
Mcreate-blogroll.py | 22++++++++++++----------
Mdata/blogroll.json | 2+-
2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/create-blogroll.py b/create-blogroll.py @@ -18,19 +18,21 @@ # along with this program. If not, see <https://www.gnu.org/licenses/>. import sys -import re import json +import xml.etree.ElementTree as ET -entries = re.compile(r'.*<outline text=\"Blogroll\">(.*?)</outline>.*', re.DOTALL) -entry = re.compile(r'<outline type=\"rss\" text=\"(.*)\" xmlUrl=\"(.*)\" htmlUrl=\"(.*)\"/>') - -with open(sys.argv[1], 'r') as f: - inp = f.read() - -lines = re.match(entries, inp).group(1) +tree = ET.parse(sys.argv[1]) +root = tree.getroot() out = [] -for (name, feed, html) in re.findall(entry, lines): - out.append({ "name": name, "url": html, "feed": feed }) +for category in root[0]: + if category.attrib['text'] == "Blogroll": + for entry in category: + out.append({ + "name": entry.attrib['text'], + "url": entry.attrib['htmlUrl'], + "feed": entry.attrib['xmlUrl'] + }) + break print(json.dumps(out, indent=2, sort_keys=True, ensure_ascii=False)) diff --git a/data/blogroll.json b/data/blogroll.json @@ -40,7 +40,7 @@ "url": "https://jlelse.blog" }, { - "feed": "https://kevq.uk/feed", + "feed": "https://kevq.uk/feed/", "name": "Kev Quirk", "url": "https://kevq.uk" },