adding a fallback for when feed URLs do not work
This commit is contained in:
parent
af70f55774
commit
bfc4f02735
48
feedtools.py
48
feedtools.py
@ -15,30 +15,34 @@ def update():
|
|||||||
|
|
||||||
for x, feed in enumerate(feeds):
|
for x, feed in enumerate(feeds):
|
||||||
parsed = feedparser.parse(feed)
|
parsed = feedparser.parse(feed)
|
||||||
# print(parsed)
|
if parsed:
|
||||||
x = str(x)
|
# print(f'Adding: { parsed.feed.title } ({ parsed.feed.link })')
|
||||||
|
x = str(x)
|
||||||
|
|
||||||
tmp['feeds'][x] = {}
|
tmp['feeds'][x] = {}
|
||||||
tmp['feeds'][x]['title'] = parsed.feed.title
|
if parsed.feed.title:
|
||||||
tmp['feeds'][x]['link'] = parsed.feed.link
|
tmp['feeds'][x]['title'] = parsed.feed.title
|
||||||
tmp['feeds'][x]['rss'] = parsed.entries[0].title_detail.base
|
else:
|
||||||
tmp['feeds'][x]['description'] = parsed.feed.description
|
tmp['feeds'][x]['title'] = ""
|
||||||
|
tmp['feeds'][x]['link'] = parsed.feed.link
|
||||||
for post in parsed.entries:
|
tmp['feeds'][x]['rss'] = parsed.entries[0].title_detail.base
|
||||||
year = post['published_parsed'][0]
|
tmp['feeds'][x]['description'] = parsed.feed.description
|
||||||
month = post['published_parsed'][1]
|
|
||||||
day = post['published_parsed'][2]
|
for post in parsed.entries:
|
||||||
post_date = datetime(year, month, day, tzinfo=ZoneInfo("Europe/Amsterdam"))
|
year = post['published_parsed'][0]
|
||||||
|
month = post['published_parsed'][1]
|
||||||
|
day = post['published_parsed'][2]
|
||||||
|
post_date = datetime(year, month, day, tzinfo=ZoneInfo("Europe/Amsterdam"))
|
||||||
|
|
||||||
if not str(post_date) in tmp['all_posts_sorted']:
|
if not str(post_date) in tmp['all_posts_sorted']:
|
||||||
tmp['all_posts_sorted'][str(post_date)] = []
|
tmp['all_posts_sorted'][str(post_date)] = []
|
||||||
|
|
||||||
post['feed_details'] = {}
|
post['feed_details'] = {}
|
||||||
post['feed_details']['title'] = parsed.feed.title
|
post['feed_details']['title'] = parsed.feed.title
|
||||||
post['feed_details']['link'] = parsed.feed.link
|
post['feed_details']['link'] = parsed.feed.link
|
||||||
post['feed_details']['rss'] = parsed.entries[0].title_detail.base
|
post['feed_details']['rss'] = parsed.entries[0].title_detail.base
|
||||||
post['feed_details']['description'] = parsed.feed.description
|
post['feed_details']['description'] = parsed.feed.description
|
||||||
tmp['all_posts_sorted'][str(post_date)].append(post)
|
tmp['all_posts_sorted'][str(post_date)].append(post)
|
||||||
|
|
||||||
db.update(tmp)
|
db.update(tmp)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user