From ae8822ec0327c4d5674f1dc79de926b230f27f1f Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Wed, 16 Apr 2025 15:12:41 -0400 Subject: Highly wip waveform view Signed-off-by: Andrew Opalach --- src/portal/py/modules/pixiv_web.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/portal/py/modules') diff --git a/src/portal/py/modules/pixiv_web.py b/src/portal/py/modules/pixiv_web.py index c6a9c82..3c04202 100644 --- a/src/portal/py/modules/pixiv_web.py +++ b/src/portal/py/modules/pixiv_web.py @@ -97,16 +97,15 @@ class PixivWebBase(Search): if not ugoira: url = f'{BASE_URL}/illust/{illust_id}/ugoira_meta?lang={LANG}&version={VERSION}' ugoira = self.check_api_response(self.module.do_request(Method.GET, url)) - if not ugoira: - return None - kwargs['raw_responses']['ugoira'] = json.dumps(ugoira) - kwargs['media'] = { '0': self.parse_ugoira(ugoira, data['urls']['original']) } elif data['pageCount'] > 1: if not pages: url = f'{BASE_URL}/illust/{illust_id}/pages?lang={LANG}&version={VERSION}' pages = self.check_api_response(self.module.do_request(Method.GET, url)) - if not pages: - return None + # Retrieving ugoria or pages could return 404. + if ugoira: + kwargs['raw_responses']['ugoira'] = json.dumps(ugoira) + kwargs['media'] = { '0': self.parse_ugoira(ugoira, data['urls']['original']) } + elif pages: kwargs['raw_responses']['pages'] = json.dumps(pages) kwargs['media'] = self.parse_pages(pages) else: @@ -142,7 +141,7 @@ class PixivWebBase(Search): url = f'{BASE_URL}/illust/{illust_id}?lang={LANG}&version={VERSION}' obj = self.check_api_response(self.module.do_request(Method.GET, url)) if not obj: - return None + return self.create_tombstone({ 'id': illust_id }) return self.create_post(obj) def create_user(self, data: ParsedJson) -> User: @@ -249,6 +248,8 @@ class PixivWebBookmarks(PixivWebBase): self.pages[num] = [] for illust in obj['works']: if illust['userId'] == 0: + # Is it worth assuming this is a tombstone? Should run some tests + # to see if an illust object is ever returned anyway. post = self.create_tombstone(illust) else: post = self.request_illust(int(illust['id'])) -- cgit v1.2.3-101-g0448