Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions lib/urlwatch/reporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
from .util import TrackSubClasses, chunkstring
from .xmpp import XMPP

from feedgen.feed import FeedGenerator
import hashlib

try:
import chump
except ImportError:
Expand Down Expand Up @@ -383,6 +386,37 @@ def submit(self):
print(line)


class RssReporter(TextReporter):
"""Print summary on stdout (the console) as RSS"""

__kind__ = 'rss'

def submit(self):

body = '\n'.join(super().submit())
if not body:
return

# Text output within preformatted tag.
body = '<pre>' + body + '</pre>'

# Create feed.
fg = FeedGenerator()
fg.title(self.config['feed']['title'])
fg.link( href=self.config['feed']['url'], rel='alternate' )
fg.subtitle(self.config['feed']['subtitle'])

# Create feed item
fe = fg.add_entry()
fe.title('New changes')
fe.content(body, type='CDATA')
id = hashlib.sha1(body.encode('utf-8')).hexdigest()
fe.id(id)

# Output feed to STDOUT.
rss = fg.rss_str(pretty=True).decode("utf-8")
print(rss)

class EMailReporter(TextReporter):
"""Send summary via e-mail / SMTP"""

Expand Down
9 changes: 9 additions & 0 deletions lib/urlwatch/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@
'color': True,
},

'rss': {
'enabled': False,
'feed': {
'title': 'urlwatch',
'subtitle': 'Changes in my monitored URLs.',
'url': 'http://example.com',
},
},

'email': {
'enabled': False,

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ keyring
appdirs
lxml
cssselect
feedgen