Skip to content

Commit

Permalink
Merge pull request #236 from HFrost0/fix_bilibili_api
Browse files Browse the repository at this point in the history
fix: bilibili api
  • Loading branch information
HFrost0 authored Sep 20, 2024
2 parents 41fa4b3 + 1ed9342 commit 23e43d9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bilix/sites/bilibili/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ class VideoInfo(BaseModel):


def _parse_bv_html(url, html: str) -> VideoInfo:
init_info = re.search(r'<script>window.__INITIAL_STATE__=({.*});\(', html).groups()[0] # this line may raise
init_info = re.search(r'<script>window.__INITIAL_STATE__=({.*?});\(', html).groups()[0] # this line may raise
init_info = json.loads(init_info)
if len(init_info.get('error', {})) > 0:
raise APIResourceError("视频已失效", url) # 啊叻?视频不见了?在分区下载的时候可能产生
Expand All @@ -369,7 +369,7 @@ def _parse_bv_html(url, html: str) -> VideoInfo:
pages.append(Page(p_name=p_name, p_url=p_url))
# extract dash and flv_url
dash, other = None, []
play_info = re.search('<script>window.__playinfo__=({.*})</script><script>', html).groups()[0]
play_info = re.search('<script>window.__playinfo__=({.*?})</script><script>', html).groups()[0]
play_info = json.loads(play_info)['data']
try:
dash = Dash.from_dict(play_info)
Expand Down

0 comments on commit 23e43d9

Please sign in to comment.