Skip to content
This repository was archived by the owner on Nov 11, 2018. It is now read-only.
Open
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
12 changes: 12 additions & 0 deletions krill/krill.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,25 @@ def get_feed_items(self, xml, url):
feed_data = feedparser.parse(xml)
# Default to feed URL if no title element is present
feed_title = feed_data.feed.get("title", url)
# Store the feed's URL in case it needs appended to the entry links
feed_link = feed_data.feed.get("link")
if feed_link is None:
feed_link = ''
if feed_link.endswith("/"):
feed_link = feed_link[:-1]

for entry in feed_data.entries:
time = datetime.fromtimestamp(calendar.timegm(entry.published_parsed)) \
if "published_parsed" in entry else None
title = entry.get("title")
text = self._html_to_text(entry.description) if "description" in entry else None
link = entry.get("link")

# If the entry link does not have the full URL append the feed's link
if not re.match("^(http|https)://", link):
if not link.startswith("/"):
link = "/" + link
link = feed_link + link

# Some feeds put the text in the title element
if text is None and title is not None:
Expand Down