show error message if no articles were returned from feedparser
This commit is contained in:
parent
d37148ea32
commit
7d4d1311bb
1 changed files with 5 additions and 1 deletions
|
|
@ -56,6 +56,7 @@ Utility functions
|
||||||
|
|
||||||
# Get articles of a feed
|
# Get articles of a feed
|
||||||
def get_articles(feed):
|
def get_articles(feed):
|
||||||
|
|
||||||
feed = feedparser.parse(feed['url'])
|
feed = feedparser.parse(feed['url'])
|
||||||
return feed.entries
|
return feed.entries
|
||||||
|
|
||||||
|
|
@ -217,6 +218,9 @@ def update_feed(feed):
|
||||||
articles = get_articles(feed)
|
articles = get_articles(feed)
|
||||||
threshold_date = datetime.now() - timedelta(days = max_age)
|
threshold_date = datetime.now() - timedelta(days = max_age)
|
||||||
|
|
||||||
|
if len(articles) == 0:
|
||||||
|
error('no articles received from feed "{}"'.format(feed['name']))
|
||||||
|
|
||||||
for a in articles:
|
for a in articles:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -302,7 +306,7 @@ def initialize():
|
||||||
os.makedirs(lovedpath)
|
os.makedirs(lovedpath)
|
||||||
|
|
||||||
|
|
||||||
# Update all feeds and delete old messages
|
# Update all feeds and remove old articles
|
||||||
def crawl():
|
def crawl():
|
||||||
|
|
||||||
log('crawling feeds', True)
|
log('crawling feeds', True)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue