forked from platypush/platypush
Added more source fields to the RSS NewFeedEvent
This commit is contained in:
parent
2ceb3511b3
commit
e9d4ed3911
2 changed files with 13 additions and 9 deletions
|
@ -75,14 +75,15 @@ class RssUpdates(HttpRequest):
|
||||||
self.logger.info('Extracting content from {}'.format(link))
|
self.logger.info('Extracting content from {}'.format(link))
|
||||||
|
|
||||||
parser = get_plugin('http.webpage')
|
parser = get_plugin('http.webpage')
|
||||||
response = parser.simplify(link).output
|
response = parser.simplify(link)
|
||||||
errors = parser.simplify(link).errors
|
output = response.output
|
||||||
|
errors = response.errors
|
||||||
|
|
||||||
if not response:
|
if not output:
|
||||||
self.logger.warning('Mercury parser error: {}'.format(errors or '[unknown error]'))
|
self.logger.warning('Mercury parser error: {}'.format(errors or '[unknown error]'))
|
||||||
return
|
return
|
||||||
|
|
||||||
return response.get('content')
|
return output.get('content')
|
||||||
|
|
||||||
def get_new_items(self, response):
|
def get_new_items(self, response):
|
||||||
import feedparser
|
import feedparser
|
||||||
|
@ -212,7 +213,9 @@ class RssUpdates(HttpRequest):
|
||||||
self.logger.info('Parsing RSS feed {}: completed'.format(self.title))
|
self.logger.info('Parsing RSS feed {}: completed'.format(self.title))
|
||||||
|
|
||||||
return NewFeedEvent(request=dict(self), response=entries,
|
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_format=self.digest_format,
|
||||||
digest_filename=digest_filename)
|
digest_filename=digest_filename)
|
||||||
|
|
||||||
|
|
|
@ -6,19 +6,20 @@ class NewFeedEvent(HttpEvent):
|
||||||
Event triggered when a monitored RSS feed has some new content
|
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):
|
digest_format=None, digest_filename=None, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
:param request: Original request
|
:param request: Original request
|
||||||
:param response: Received response
|
:param response: Received response
|
||||||
:param source_id: ID of the source that generated the event
|
: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 title: Title of the new element
|
||||||
:param digest_format: Format of the digest - either 'html' or 'pdf', if set
|
: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
|
:param digest_filename: File name of the digest, if it was dumped to file
|
||||||
"""
|
"""
|
||||||
|
super().__init__(request=request, response=response, source_id=source_id, source_title=source_title,
|
||||||
super().__init__(request=request, response=response, source_id=source_id,
|
source_url=source_url, digest_format=digest_format, title=title,
|
||||||
digest_format=digest_format, title=title,
|
|
||||||
digest_filename=digest_filename, *args, **kwargs)
|
digest_filename=digest_filename, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue