From 2ff422860e0ac5e0a071b19c98061f46bc2cb8c2 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Tue, 24 Dec 2024 18:15:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=97=E5=87=BA=E7=94=BB?= =?UTF-8?q?=E5=BB=8A=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=94=AF=E6=8C=81=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E5=92=8C=E8=BF=87=E6=BB=A4=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ehapi.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ehapi.py b/ehapi.py index f0b469a..ff9fd08 100644 --- a/ehapi.py +++ b/ehapi.py @@ -20,6 +20,26 @@ class EHC: def get_gallery(self, gid: int): return self.handle_api_result(self.get(f"/gallery/{gid}")) + def list_galleries(self, offset: int = 0, limit: int = 20, + all: bool = False, fields: str = '*', + sort_by_gid: bool = None, uploader: str = None, + category: str = None): + params = {} + if not all: + params['offset'] = offset + params['limit'] = limit + else: + params['all'] = '1' + if fields and fields != '*': + params['fields'] = fields + if sort_by_gid is not None: + params['sort_by_gid'] = '1' if sort_by_gid else '0' + if uploader: + params['uploader'] = uploader + if category: + params['category'] = category + return self.handle_api_result(self.get("/gallery/list", params=params)) + def handle_api_result(self, re: Response): re = re.json() if re['ok']: