From d52e6dc0b6aa7efca2fd599e503b60e418a98130 Mon Sep 17 00:00:00 2001 From: moyada Date: Tue, 19 Mar 2024 17:24:15 +0800 Subject: [PATCH] douyin error msg --- browser/douyin.py | 9 +++------ service/douyin.py | 8 ++++++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/browser/douyin.py b/browser/douyin.py index ad33115..33d89d9 100644 --- a/browser/douyin.py +++ b/browser/douyin.py @@ -20,22 +20,19 @@ def get_info(cls, url: str) -> any: p.page.goto(url, timeout=10000) p.page.wait_for_timeout(2000) except: - pass + raise Exception('网络异常,访问分享链接失败') for i in range(0, config.page_wait, 100): if cls.data is not None: break - try: - p.page.wait_for_timeout(100) - except: - break + p.page.wait_for_timeout(100) path = get_path(p.page.url) p.close() if path == "/": cls.data = None - return None + raise Exception('分享链接有误') # /note/7264601120775916855 diff --git a/service/douyin.py b/service/douyin.py index f7625d1..a0a846e 100644 --- a/service/douyin.py +++ b/service/douyin.py @@ -72,9 +72,13 @@ def get_info(cls, url: str) -> Result: return ErrorResult.URL_NOT_INCORRECT handler = DouyinHandler() - info = handler.get_info(share_url) + try: + info = handler.get_info(share_url) + except Exception as e: + return Result.error(str(e)) + if info is None or info['status_code'] != 0: - return ErrorResult.VIDEO_ADDRESS_NOT_FOUNT + return ErrorResult.VIDEO_INFO_NOT_FOUNT data = info['aweme_detail']