diff --git a/krill/krill.py b/krill/krill.py index fed59c2..1dfff6a 100755 --- a/krill/krill.py +++ b/krill/krill.py @@ -66,6 +66,12 @@ 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)) \ @@ -73,6 +79,12 @@ def get_feed_items(self, xml, url): 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: