From d2418a47c276ec2a5e18de96b16b62a9b0e36e8f Mon Sep 17 00:00:00 2001 From: pictuga Date: Tue, 11 Jun 2013 13:02:47 +0200 Subject: [PATCH] Add support for reddit.com feeds The content of the linked article is used for the content. The original content (with a link to comments) is still available in the "description" of the feed item. --- morss.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/morss.py b/morss.py index fb1f2f3..e6b5e0d 100644 --- a/morss.py +++ b/morss.py @@ -346,6 +346,13 @@ def Fill(rss, cache, feedurl="/", fast=False): item.link = "".join([(t[s[0]] if s[0] in t else "=") + s[1:] for s in url[1:]]) log(item.link) + # reddit + if urlparse.urlparse(item.link).netloc == 'www.reddit.com': + match = lxml.html.fromstring(item.desc).xpath('//a[text()="[link]"]/@href') + if len(match): + item.link = match[0] + log(item.link) + # check relative urls if urlparse.urlparse(item.link).netloc is '': item.link = urlparse.urljoin(feedurl, item.link)