mirror of
https://codeberg.org/Reuh/feather.git
synced 2025-10-27 10:09:32 +00:00
fix: some API issues when connecting to FreshRSS
This commit is contained in:
parent
8521dce8f7
commit
70f679f959
1 changed files with 20 additions and 1 deletions
|
|
@ -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"""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue