From 8ae878587b2bac9701fb3e529049e0ff416f4e5c Mon Sep 17 00:00:00 2001 From: yezian Date: Tue, 13 Aug 2024 13:19:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=87=8D=E8=AF=95=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qushuiyin.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/qushuiyin.py b/qushuiyin.py index d4bcecb..e27a905 100644 --- a/qushuiyin.py +++ b/qushuiyin.py @@ -16,10 +16,19 @@ def endecode_and_proxy_url(original_url): class Video: def douyin(self, url): # Extract ID from URL - id_match = self.extract_id(url) - if not id_match: + for attempt_1 in range(10): + id_match = self.extract_id(url) + if id_match: + break + else: + time.sleep(0.5) + else: return {"code": 400, "msg": "Unable to parse video ID"} + # id_match = self.extract_id(url) + # if not id_match: + # return {"code": 400, "msg": "Unable to parse video ID"} + video_id = id_match # Construct request headers @@ -46,7 +55,6 @@ class Video: matches = re.search(pattern, response.text, re.DOTALL) if matches: - print(attempt) break else: time.sleep(0.5)