Python中you-get命令不能下载B站视频了吗?

you-get https://www.bilibili.com/video/av17732514/ ~
you-get: [error] oops, something went wrong.
you-get: don’t panic, c’est la vie. please try the following steps:
you-get: (1) Rule out any network problem.
you-get: (2) Make sure you-get is up-to-date.
you-get: (3) Check if the issue is already known, on
you-get: https://github.com/soimort/you-get/wiki/Known-Bugs
you-get: https://github.com/soimort/you-get/issues
you-get: (4) Run the command with ‘–debug’ option,
you-get: and report this issue with the full output.
这是什么情况
Python中you-get命令不能下载B站视频了吗?


18 回复

Run the command with ‘–debug’ option 贴下 debug 信息吧
话说为什么不试试 bilibili 助手的 chrome 扩展呢


我最近也遇到了这个问题。you-get确实不能直接下载B站视频了,因为B站更新了反爬机制。不过有个简单的解决方案:用--cookies参数。

首先从浏览器导出B站cookies(用EditThisCookie之类的插件),保存为cookies.txt。然后这样用:

import subprocess
import os

# 假设cookies.txt在当前目录
cookies_path = os.path.join(os.getcwd(), 'cookies.txt')
url = "https://www.bilibili.com/video/BV1xx411c7mD"

cmd = f'you-get --cookies {cookies_path} {url}'
subprocess.run(cmd, shell=True)

如果不想用命令行,也可以用you-get的Python API:

import you_get

def download_video(url, cookies_path='cookies.txt'):
    sys.argv = ['you-get', '--cookies', cookies_path, url]
    you_get.main()

download_video('https://www.bilibili.com/video/BV1xx411c7mD')

这样就能绕过B站的登录验证了。记得定期更新cookies文件,因为cookies会过期。

总结:加个cookies参数就能继续用。

我之前也是过一段时间不能,后来我用火狐登录了一次 B 站就可以了, 但是具体原因是不是这个 我也说不清

直接在链接后面加 jj 就可以下载

我不懂原理是什么,但总觉得没有 youtube-dl 好用。。。很多 porn 的电影 you-get 都下载不了

#3 惊了,实测可以,这个参数是怎么得来的?

给个例子吧,我直接加 jj 好像不行哎。

原始地址是:you-get 'https://www.bilibili.com/video/av17961420

you-get 'https://www.bilibili.com/video/av17961420/jj

应该是什么呢?

#6

<br>$ you-get.exe "<a target="_blank" href="https://www.bilibili.com/bangumi/play/ep115237" rel="nofollow noopener">https://www.bilibili.com/bangumi/play/ep115237</a>" jj<br><br><br>$ you-get.exe --version<br>you-get: version 0.4.1011, a tiny downloader that scrapes the web.<br>

#6

试了一下,ep 可以,av 还是不行,GG


you-get “https://www.bilibili.com/bangumi/play/ep115237” jj

you-get: [error] oops, something went wrong.
you-get: don’t panic, c’est la vie. please try the following steps:
you-get: (1) Rule out any network problem.
you-get: (2) Make sure you-get is up-to-date.
you-get: (3) Check if the issue is already known, on
you-get: https://github.com/soimort/you-get/wiki/Known-Bugs
you-get: https://github.com/soimort/you-get/issues
you-get: (4) Run the command with ‘–debug’ option,
you-get: and report this issue with the full output.
------------------------------------------------------------


好奇怪 ,我用自己的 mac, 阿里的服务器,google 的服务器都不行。 就你刚 发的那个地址,只出现了一个信息,然后就断开了。

知道问题了,多谢,看过段时间可以不。

我现在也下载不了 av 的 b 站视频了,有人知道怎么回事吗?可以修复吗?为什么 you-get 把 issue 功能关闭了,都没有渠道反馈问题了。

非常感谢,现在都要手动打补丁了,哈哈哈

对呀,我们又不能总等着人家更新。

只要能用就好,也不是很麻烦

请问这个要怎么使用?

其实就是在 bilibili.py 这个文件中的 70 行,get_content(api_url) 改成 get_content(api_url, headers={‘referer’: self.url, ‘User-Agent’: ‘Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36’})

回到顶部