Closed lean-aa closed 8 months ago
HTTP 412 is the status code for reaching API rate limit on bilibili, and all API requests from the same IP address will be restricted for a certain amount of time.
I try open this url in browser, It's can get right json.
Need view https://www.bilibili.com/ to get cookie first.
curl 'https://api.bilibili.com/x/web-interface/search/type?context=&page=1&order=pubdate&keyword=%E5%91%A8%E6%9D%B0%E4%BC%A6&duration=0&tids_2=&__refresh__=true&search_type=video&tids=0&highlight=1' \
-H $'cookie: buvid3=B316A51A-F640-D845-A87E-3AE6CCD098EE81984infoc; b_nut=1681592281; CURRENT_FNVAL=4048; _uuid=5C656C26-8135-BA96-9A9D-2B92810510DEB581243infoc; CURRENT_PID=35a6d580-dbd0-11ed-9490-9f9747584641; rpdid=|(um|Juulmk|0J\'uY)ulmkk)R; buvid4=7D238122-1DEE-A424-E4FD-01116A0EFB7F83076-023041604-Eg1Sg8zdHfupW32s9pBw%2Fw%3D%3D; fingerprint=34442aa86c5038f096a4281bb2c27db2; buvid_fp_plain=undefined; buvid_fp=4f6e181b5d54774c360e7cc8ece49e55; b_lsid=2DE29B4E_18D6502742B; bili_ticket=eyJhbGciOiJIUzI1NiIsImtpZCI6InMwMyIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MDcwNTU4ODAsImlhdCI6MTcwNjc5NjYyMCwicGx0IjotMX0.qgoRZHqpSsy0CVapMoANrc0Gt9Zop2ruJNcWgVTm0qU; bili_ticket_expires=1707055820; enable_web_push=DISABLE; header_theme_version=CLOSE; home_feed_column=5; browser_resolution=2560-918; bp_video_offset_2054571714=893171288527339541; sid=nvguvmnh'
I see. Adding a buvid3 cookie should fix this problem.
I solved this problem by using --cookies
parameter, according to this document https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp Get cookies.txt file.
yt-dlp "bilisearch:周杰伦" --cookies cookies.txt
cookies.txt file like this
# Netscape HTTP Cookie File
# This file is generated by yt-dlp. Do not edit.
.bilibili.com TRUE / FALSE 1738333501 _uuid 13416438-8579-9913-91AE-34EFA613959509732infoc
.bilibili.com TRUE / FALSE 0 b_lsid FD0CEF910_18D67227BCC
.bilibili.com TRUE / FALSE 1741357501 b_nut 1706797501
.bilibili.com TRUE / FALSE 1738368491 browser_resolution 1091-918
.bilibili.com TRUE / FALSE 1741357501 buvid3 101103CF-598D-69AD-C0A7-86ACD2E8BB5C08091infoc
.bilibili.com TRUE / FALSE 1741357501 buvid4 BBC106B7-ED7D-615F-442C-F048FDD096B908091-024020114-ANawzDfwerU2QorLcdfITg%3D%3D
.bilibili.com TRUE / FALSE 1741357511 buvid_fp dd139ca05df9d1b8cd13ef76011d9aa4
.bilibili.com TRUE / FALSE 1738368491 enable_web_push DISABLE
.bilibili.com TRUE / FALSE 1738368491 header_theme_version CLOSE
.bilibili.com TRUE / FALSE 1738368491 home_feed_column 4
.bilibili.com TRUE / FALSE 0 sid 1dh94bnf
www.bilibili.com FALSE / FALSE 0 bmg_af_switch 1
www.bilibili.com FALSE / FALSE 0 bmg_src_def_domain i1.hdslb.com
I see. Adding a buvid3 cookie should fix this problem.
You are right. Only need buvid3 cookie.
DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE
Checklist
Provide a description that is worded well enough to be understood
download from www.bilibili.com url is ok but download via bilisearch produce error
Provide verbose output that clearly demonstrates the problem
yt-dlp -vU <your command line>
)[debug] Command-line config
) and insert it belowComplete Verbose Output