Skip to content

Commit

Permalink
douyin error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
moyada committed Mar 19, 2024
1 parent 3b5c009 commit d52e6dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 3 additions & 6 deletions browser/douyin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions service/douyin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down

0 comments on commit d52e6dc

Please sign in to comment.