Parse Medium RSS feeds
closes https://github.com/pirate/bookmark-archiver/issues/64
This commit is contained in:
parent
b5c6d34860
commit
f49f1b5aa0
1 changed files with 26 additions and 0 deletions
26
parse.py
26
parse.py
|
@ -38,6 +38,7 @@ def get_parsers(file):
|
||||||
'bookmarks': parse_bookmarks_export,
|
'bookmarks': parse_bookmarks_export,
|
||||||
'rss': parse_rss_export,
|
'rss': parse_rss_export,
|
||||||
'pinboard_rss': parse_pinboard_rss_feed,
|
'pinboard_rss': parse_pinboard_rss_feed,
|
||||||
|
'medium_rss': parse_medium_rss_feed,
|
||||||
}
|
}
|
||||||
|
|
||||||
def parse_links(path):
|
def parse_links(path):
|
||||||
|
@ -199,3 +200,28 @@ def parse_pinboard_rss_feed(rss_file):
|
||||||
}
|
}
|
||||||
info['type'] = get_link_type(info)
|
info['type'] = get_link_type(info)
|
||||||
yield info
|
yield info
|
||||||
|
|
||||||
|
def parse_medium_rss_feed(rss_file):
|
||||||
|
"""Parse Medium RSS feed files into links"""
|
||||||
|
|
||||||
|
rss_file.seek(0)
|
||||||
|
root = etree.parse(rss_file).getroot()
|
||||||
|
items = root.find("channel").findall("item")
|
||||||
|
for item in items:
|
||||||
|
for child in item:
|
||||||
|
print(child.tag, child.text)
|
||||||
|
url = item.find("link").text
|
||||||
|
title = item.find("title").text
|
||||||
|
ts_str = item.find("pubDate").text
|
||||||
|
time = datetime.strptime(ts_str, "%a, %d %b %Y %H:%M:%S %Z")
|
||||||
|
info = {
|
||||||
|
'url': url,
|
||||||
|
'domain': domain(url),
|
||||||
|
'base_url': base_url(url),
|
||||||
|
'timestamp': str(time.timestamp()),
|
||||||
|
'tags': "",
|
||||||
|
'title': title,
|
||||||
|
'sources': [rss_file.name],
|
||||||
|
}
|
||||||
|
info['type'] = get_link_type(info)
|
||||||
|
yield info
|
||||||
|
|
Loading…
Reference in a new issue