Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ie/bilibili] Fix subtitles and chapters extraction #11708

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

xiaomac
Copy link
Contributor

@xiaomac xiaomac commented Dec 2, 2024

Update bilibili url of info api with wbi

IMPORTANT: PRs without the template will be CLOSED

Description of your pull request and other information

seems bilibili update they subtitle api url:
old: https://api.bilibili.com/x/player/v2?aid=113470703931990&cid=26731938624
new: https://api.bilibili.com/x/player/wbi/v2?aid=113470703931990&cid=26731938624

subtitles info is different (empty some time, or random text other) everytimes the old url is requested:

#1:
"subtitle": { "allow_submit": false, "lan": "", "lan_doc": "", "subtitles": [ { "id": 1610305384030071000, "lan": "ai-zh", "lan_doc": "中文(自动生成)", "is_lock": false, "subtitle_url": "//aisubtitle.hdslb.com/bfs/ai_subtitle/prod/113384720701738265043985411da261a20ff661ad1742661f045442eb?auth_key=1733141553-2cb7a684118a43b0805fb8218fa0d3d5-0-3a8c2b0ae88228cf5e2abd7305e0a3dd", "type": 1, "id_str": "1610305384030071040", "ai_type": 0, "ai_status": 2 } ] },

#2

"subtitle": { "allow_submit": false, "lan": "", "lan_doc": "", "subtitles": [ { "id": 1621313484639830800, "lan": "ai-zh", "lan_doc": "中文(自动生成)", "is_lock": false, "subtitle_url": "", "type": 1, "id_str": "1621313484639830784", "ai_type": 0, "ai_status": 2 } ] },

#3

"subtitle": { "allow_submit": false, "lan": "", "lan_doc": "", "subtitles": [ { "id": 1594993089838253000, "lan": "ai-zh", "lan_doc": "中文(自动生成)", "is_lock": false, "subtitle_url": "//aisubtitle.hdslb.com/bfs/ai_subtitle/prod/11326509914660626182422278427ae3a2c0f57329b82aca9855da788e?auth_key=1733141745-2f81559110754683993d8cc30656ac70-0-bbda9c01620eb4d99f818375a3b3df96", "type": 1, "id_str": "1594993089838253056", "ai_type": 0, "ai_status": 2 } ] }

check out the subtitle_url in #1 and #3, are total none sense content.

Fixes #

use new url: https://api.bilibili.com/x/player/**wbi**/v2

"subtitle": { "allow_submit": false, "lan": "", "lan_doc": "", "subtitles": [ { "id": 1621313484639830800, "lan": "ai-zh", "lan_doc": "中文(自动生成)", "is_lock": false, "subtitle_url": "//aisubtitle.hdslb.com/bfs/ai_subtitle/prod/11347070393199026731938624d2e6f10bd77a075e49b793b12ab8bf73?auth_key=1733141975-be61791b7526450db96b8141994e9300-0-17391f3ea1538b8e3a721d3e9b297c8a", "subtitle_url_v2": "//subtitle.bilibili.com/S%13%1BP.%1D%28%29X%2CR%5Ej%1F%25w%0E%02H%5EHO4%14%7B4%08K@%3C%7B%00M%0B%0A%1AM%08%056N6$%0C0&%02%1E%01%09%0E%1A2V~%15F%5C%11C%5E%5BCQ%0C%7F%17P%5Ct%19WQXUZZ_%5E%5DYq%23N%3Fc%5E%19JNK%14fNzAAQDDPX%12Y%0D%2FLQ%0E%20%18S?auth_key=1733141975-be61791b7526450db96b8141994e9300-0-17391f3ea1538b8e3a721d3e9b297c8a", "type": 1, "id_str": "1621313484639830784", "ai_type": 0, "ai_status": 2 } ] },

bug fixed.

Template

Before submitting a pull request make sure you have:

In order to be accepted and merged into yt-dlp each piece of code must be in public domain or released under Unlicense. Check all of the following options that apply:

  • I am the original author of this code and I am willing to release it under Unlicense
  • I am not the original author of this code but it is in public domain or released under Unlicense (provide reliable evidence)

What is the purpose of your pull request?

Update bilibili url of info api with wbi
@bashonly bashonly added the site-bug Issue with a specific website label Dec 2, 2024
@bashonly
Copy link
Member

bashonly commented Dec 2, 2024

If we are using wbi endpoints for these now, do we need to sign the URL (_sign_wbi) like we do when making requests to the other wbi endpoints?

@xiaomac
Copy link
Contributor Author

xiaomac commented Dec 2, 2024

If we are using wbi endpoints for these now, do we need to sign the URL (_sign_wbi) like we do when making requests to the other wbi endpoints?

i think so, but looks like the code already done that part i presume.

when i use --list-subs without logined_cookie, it shows warning:

WARNING: [BiliBili] Subtitles are only available when logged in. Use --cookies-from-browser or --cookies for the authentication. See https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp for how to manually pass cookies

and after i add --cookies, the requests with '/wbi/' works well.

@grqx
Copy link

grqx commented Dec 2, 2024

i think so, but looks like the code already done that part i presume.

if you want to sign the params, pass query=_sign_wbi(params, video_id). But as documented in https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/video/player.md, they aren't required for this API

@bashonly
Copy link
Member

bashonly commented Dec 2, 2024

they aren't required for this API

Nevermind my question then, I was just curious

@bashonly bashonly changed the title Update bilibili.py when extracting subtitle info [ie/bilibili] Fix subtitles and chapter extraction Dec 3, 2024
@bashonly bashonly changed the title [ie/bilibili] Fix subtitles and chapter extraction [ie/bilibili] Fix subtitles and chapters extraction Dec 3, 2024
@bashonly bashonly merged commit a13a336 into yt-dlp:master Dec 3, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
site-bug Issue with a specific website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants