Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/news-updater.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Posselt <BernhardPosselt@users.noreply.github.com>2021-02-06 13:57:59 +0300
committerGitHub <noreply@github.com>2021-02-06 13:57:59 +0300
commit11680b519cf4eddac08848f3c65ac6a08bff969e (patch)
tree600e8abd1dce5ae3bd43f5bfcef8d72b5c006c31
parente060f009f8af52ce31194b196e29d72c570fe006 (diff)
parente7f51442581fb430cc52a3ccbfec920412ab5d65 (diff)
Merge pull request #32 from DriverXX/master
Add REST API support for News v15
-rw-r--r--nextcloud_news_updater/api/web.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/nextcloud_news_updater/api/web.py b/nextcloud_news_updater/api/web.py
index b7d5f53..132ea11 100644
--- a/nextcloud_news_updater/api/web.py
+++ b/nextcloud_news_updater/api/web.py
@@ -41,11 +41,32 @@ class WebApiV2(WebApi):
return [Feed(info['feedId'], info['userId']) for info in feeds]
+class WebApiV15(WebApi):
+ """REST API for Nextcloud News v15+"""
+
+ def __init__(self, config: Config) -> None:
+ super().__init__(config)
+ base_url = self._generify_base_url(config.url)
+ self.base_url = '%sindex.php/apps/news/api/v1-2' % base_url
+ self.before_cleanup_url = '%s/cleanup/before-update' % self.base_url
+ self.after_cleanup_url = '%s/cleanup/after-update' % self.base_url
+ self.all_feeds_url = '%s/feeds/all' % self.base_url
+ self.update_url = '%s/feeds/update' % self.base_url
+
+ def _parse_feeds_json(self, feeds_json: Any, userID: str) -> List[Feed]:
+ if not feeds_json:
+ return []
+ feeds_json = feeds_json['feeds']
+ return [Feed(info['id'], info['userId']) for info in feeds_json]
+
+
def create_web_api(config: Config) -> WebApi:
if config.apilevel == 'v1-2':
return WebApi(config)
if config.apilevel == 'v2':
return WebApiV2(config)
+ if config.apilevel == 'v15':
+ return WebApiV15(config)
class HttpClient: