1
0
Fork 0
mirror of https://codeberg.org/Reuh/feather.git synced 2025-10-27 18:19:32 +00:00

fix: some API issues when connecting to FreshRSS

This commit is contained in:
Étienne Fildadut 2025-10-14 23:55:45 +02:00
parent 8521dce8f7
commit 70f679f959

View file

@ -40,6 +40,18 @@ class ClientSession(ABC):
pass 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/(.*)") label_name_re = re.compile("user/.*/label/(.*)")
@ -128,11 +140,18 @@ class GReaderArticle(Article):
self.content = item_content.content.content self.content = item_content.content.content
self.feed_title = item_content.origin.title self.feed_title = item_content.origin.title
self.feed_url = item_content.origin.html_url self.feed_url = item_content.origin.html_url
if len(item_content.canonical) > 0:
self.article_url = item_content.canonical[0].href 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() self._compute_json_path()
## Tiny Tiny RSS API ##
class TTRSession(ClientSession): class TTRSession(ClientSession):
"""Tiny Tiny RSS API client""" """Tiny Tiny RSS API client"""