From cd8512a96fd1d4aef0e3c98011eb799ae386b474 Mon Sep 17 00:00:00 2001 From: mirusu400 Date: Sun, 16 Jan 2022 15:35:42 +0900 Subject: [PATCH 1/2] Fix some login exceptions --- twspace_dl/login.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/twspace_dl/login.py b/twspace_dl/login.py index bdd0500..2ecc516 100644 --- a/twspace_dl/login.py +++ b/twspace_dl/login.py @@ -68,9 +68,11 @@ def login(self) -> str: try: self.flow_token = request_flow.json()["flow_token"] except KeyError as err: - raise RuntimeError( - "Error while checking account duplication:", request_flow.json() - ) from err + pass + # Sometimes it doesn't check account duplication + # raise RuntimeError( + # "Error while checking account duplication:", request_flow.json() + # ) from err # enter password request_flow = self.session.post( From 8e7d1437667d4ba80725254b17ce7e51e40d44c1 Mon Sep 17 00:00:00 2001 From: Ryu1845 Date: Sun, 16 Jan 2022 13:24:35 +0100 Subject: [PATCH 2/2] change try except pass to if statement --- twspace_dl/login.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/twspace_dl/login.py b/twspace_dl/login.py index 2ecc516..f1751a5 100644 --- a/twspace_dl/login.py +++ b/twspace_dl/login.py @@ -64,11 +64,9 @@ def login(self) -> str: # account duplication check request_flow = self.session.post( self.task_url, headers=self._headers, json=self._account_dup_check_data - ) - try: - self.flow_token = request_flow.json()["flow_token"] - except KeyError as err: - pass + ).json() + if "flow_token" in request_flow.keys(): + self.flow_token = request_flow["flow_token"] # Sometimes it doesn't check account duplication # raise RuntimeError( # "Error while checking account duplication:", request_flow.json()