mirror of
https://git.nolog.cz/NoLog.cz/headline.git
synced 2025-01-31 20:03:34 +01:00
add dirty exceptions to skip broken RSS feeds
This commit is contained in:
parent
9800a0825d
commit
9918da68eb
1 changed files with 34 additions and 23 deletions
|
@ -112,6 +112,7 @@ def process_item(article, rc):
|
||||||
|
|
||||||
|
|
||||||
for feed in config['feeds']:
|
for feed in config['feeds']:
|
||||||
|
try:
|
||||||
rss_source = str(feed['rss_source'])
|
rss_source = str(feed['rss_source'])
|
||||||
unique_tag = str(feed['unique_tag'])
|
unique_tag = str(feed['unique_tag'])
|
||||||
name = str(feed['name'])
|
name = str(feed['name'])
|
||||||
|
@ -119,6 +120,7 @@ for feed in config['feeds']:
|
||||||
rss = feedparser.parse(rss_source)
|
rss = feedparser.parse(rss_source)
|
||||||
|
|
||||||
for item in rss['entries']:
|
for item in rss['entries']:
|
||||||
|
try:
|
||||||
rss_id = item[unique_tag]
|
rss_id = item[unique_tag]
|
||||||
title = item['title']
|
title = item['title']
|
||||||
#description = item['description'] ## Don't store description for now, as we don't need it and it's big.
|
#description = item['description'] ## Don't store description for now, as we don't need it and it's big.
|
||||||
|
@ -137,5 +139,14 @@ for feed in config['feeds']:
|
||||||
}
|
}
|
||||||
article_count += 1
|
article_count += 1
|
||||||
process_item(article, rc)
|
process_item(article, rc)
|
||||||
|
except Exception as e:
|
||||||
|
print("Parsing article failed")
|
||||||
|
print(e)
|
||||||
|
print(item)
|
||||||
|
except Exception as e:
|
||||||
|
print("Parsing feed failed.")
|
||||||
|
print(e)
|
||||||
|
print(feed)
|
||||||
|
pass
|
||||||
|
|
||||||
print("Processed articles: " + str(article_count))
|
print("Processed articles: " + str(article_count))
|
||||||
|
|
Loading…
Reference in a new issue