diff --git a/src/feather/client.py b/src/feather/client.py index 9a8b236..66c9bba 100644 --- a/src/feather/client.py +++ b/src/feather/client.py @@ -40,6 +40,18 @@ class ClientSession(ABC): pass +## Google Reader API ## + +# Monkey patch the item.enclosure class; FreshRSS returns the link in the href field but the library expects it in url +ContentItemEnclosure_old_init = google_reader.ContentItemEnclosure.__init__ + + +def ContentItemEnclosure_new_init(self, type: str, url: str = None, href: str = None): + ContentItemEnclosure_old_init(self, url=url or href, type=type) + + +google_reader.ContentItemEnclosure.__init__ = ContentItemEnclosure_new_init + label_name_re = re.compile("user/.*/label/(.*)") @@ -128,11 +140,18 @@ class GReaderArticle(Article): self.content = item_content.content.content self.feed_title = item_content.origin.title self.feed_url = item_content.origin.html_url - self.article_url = item_content.canonical[0].href + if len(item_content.canonical) > 0: + self.article_url = item_content.canonical[0].href + else: + # several API references I've seen didn't mention canonical, but alternate seems to also be the article link (?) and should be an ok fallback + self.article_url = item_content.alternate[0].href self._compute_json_path() +## Tiny Tiny RSS API ## + + class TTRSession(ClientSession): """Tiny Tiny RSS API client"""