youwee
youwee copied to clipboard
Add UA and refer to prevent 412 error
I download mp3 file from bilibili video, but there is a 412 error.
Then I test the raw yt-dlp download command.
Terminal:/mnt/e/tem/yt-dlp$ uv run yt-dlp -x --audio-format mp3 --audio-quality 0 -o "%(title)s.%(e
xt)s" https://www.bilibili.com/video/BV1Qo4y1s7XT
[BiliBili] Extracting URL: https://www.bilibili.com/video/BV1Qo4y1s7XT
[BiliBili] 1Qo4y1s7XT: Downloading webpage
ERROR: [BiliBili] 1Qo4y1s7XT: Unable to download webpage: HTTP Error 412: Precondition Failed (caused by <HTTPError 412: Precondition Failed>)
Terminal:/mnt/e/tem/yt-dlp$ uv run yt-dlp \
--user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" \
--referer "https://www.bilibili.com/" \
-x --audio-format mp3 --audio-quality 0 -o "%(title)s.%(ext)s" https://www.bilibili.com/video/BV1Qo4y1s7XT
[BiliBili] Extracting URL: https://www.bilibili.com/video/BV1Qo4y1s7XT
[BiliBili] 1Qo4y1s7XT: Downloading webpage
[BiliBili] BV1Qo4y1s7XT: Extracting videos in anthology
[BiliBili] BV1Qo4y1s7XT: Downloading wbi sign
[BiliBili] BV1Qo4y1s7XT: Downloading video formats for cid 1070698066
[BiliBili] Format(s) 1080P 高清, 720P 准高清 are missing; you have to become a premium member to download them. 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
[BiliBili] 396586742: Extracting chapters
[info] BV1Qo4y1s7XT: Downloading 1 format(s): 30280
[download] Destination: 许嵩-医生<纯音乐⧸伴奏⧸无和声>.m4a
[download] 100% of 4.81MiB in 00:00:01 at 3.85MiB/s
[ExtractAudio] Destination: 许嵩-医生<纯音乐⧸伴奏⧸无和声>.mp3
Deleting original file 许嵩-医生<纯音乐⧸伴奏⧸无和声>.m4a (pass -k to keep)
I will fix it and release in next version
I fixed and released in v0.17.0
Thanks a lot!