From e9d4ed391196188f6980c498850e38177cda4cf1 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sat, 5 Sep 2020 00:50:04 +0200 Subject: [PATCH] Added more source fields to the RSS NewFeedEvent --- platypush/backend/http/request/rss/__init__.py | 13 ++++++++----- platypush/message/event/http/rss.py | 9 +++++---- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/platypush/backend/http/request/rss/__init__.py b/platypush/backend/http/request/rss/__init__.py index c42fbf7020..0f805b50b5 100644 --- a/platypush/backend/http/request/rss/__init__.py +++ b/platypush/backend/http/request/rss/__init__.py @@ -75,14 +75,15 @@ class RssUpdates(HttpRequest): self.logger.info('Extracting content from {}'.format(link)) parser = get_plugin('http.webpage') - response = parser.simplify(link).output - errors = parser.simplify(link).errors + response = parser.simplify(link) + output = response.output + errors = response.errors - if not response: + if not output: self.logger.warning('Mercury parser error: {}'.format(errors or '[unknown error]')) return - return response.get('content') + return output.get('content') def get_new_items(self, response): import feedparser @@ -212,7 +213,9 @@ class RssUpdates(HttpRequest): self.logger.info('Parsing RSS feed {}: completed'.format(self.title)) return NewFeedEvent(request=dict(self), response=entries, - source_id=source_record.id, title=self.title, + source_id=source_record.id, + source_title=source_record.title, + title=self.title, digest_format=self.digest_format, digest_filename=digest_filename) diff --git a/platypush/message/event/http/rss.py b/platypush/message/event/http/rss.py index aaf9fa52a0..cfc83ce0ae 100644 --- a/platypush/message/event/http/rss.py +++ b/platypush/message/event/http/rss.py @@ -6,19 +6,20 @@ class NewFeedEvent(HttpEvent): Event triggered when a monitored RSS feed has some new content """ - def __init__(self, request, response: list, source_id=None, title=None, + def __init__(self, request, response: list, source_id=None, source_title=None, source_url=None, title=None, digest_format=None, digest_filename=None, *args, **kwargs): """ :param request: Original request :param response: Received response :param source_id: ID of the source that generated the event + :param source_title: Name of the source, if available + :param source_url: URL of the source :param title: Title of the new element :param digest_format: Format of the digest - either 'html' or 'pdf', if set :param digest_filename: File name of the digest, if it was dumped to file """ - - super().__init__(request=request, response=response, source_id=source_id, - digest_format=digest_format, title=title, + super().__init__(request=request, response=response, source_id=source_id, source_title=source_title, + source_url=source_url, digest_format=digest_format, title=title, digest_filename=digest_filename, *args, **kwargs)