RSS digests are now optional

This commit is contained in:
Fabio Manganiello 2018-05-07 19:44:34 +02:00
parent a3b83e8c57
commit bd761d420e

View file

@ -29,12 +29,12 @@ class RssUpdates(HttpRequest):
user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36' user_agent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36'
def __init__(self, url, title=None, headers=None, params=None, max_entries=None, def __init__(self, url, title=None, headers=None, params=None, max_entries=None,
mercury_api_key=None, digest_format='html', *args, **kwargs): mercury_api_key=None, digest_format=None, *args, **kwargs):
self.url = url self.url = url
self.title = title self.title = title
self.max_entries = max_entries self.max_entries = max_entries
self.mercury_api_key = mercury_api_key # Mercury Reader API used to parse the content of the link self.mercury_api_key = mercury_api_key # Mercury Reader API used to parse the content of the link
self.digest_format = digest_format.lower() if digest_format else 'html' self.digest_format = digest_format.lower() if digest_format else None # Supported formats: html, pdf
os.makedirs(os.path.expanduser(os.path.dirname(self.dbfile)), exist_ok=True) os.makedirs(os.path.expanduser(os.path.dirname(self.dbfile)), exist_ok=True)
@ -149,6 +149,7 @@ class RssUpdates(HttpRequest):
logging.info('Parsed {} new entries from the RSS feed {}'.format( logging.info('Parsed {} new entries from the RSS feed {}'.format(
len(entries), self.title)) len(entries), self.title))
if self.digest_format:
digest_filename = os.path.join(self.workdir, 'cache', '{}_{}.{}'.format( digest_filename = os.path.join(self.workdir, 'cache', '{}_{}.{}'.format(
datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%S'), datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%S'),
self.title, self.digest_format)) self.title, self.digest_format))