you-get修复B站下载方法

之前一直在用you-get命令配合脚本下载B站的视频,最近发现命令失效了,一直报错,索性就有一段时间搁置下不用了,今天实在是手痒,就去网络上检索了一下这个问题,发现大家都或多或少都出现了这个情况。

# 报错信息
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. 

最后在you-getgithub上找到了答案,但是这次需要手动调整,无法通过brew upgrade you-get升级版本解决,下面我就把解决方案放上。
找到bilibili.py文件所在的位置,如果是brew安装的you-get的话,mac系统的位置应该是在/usr/local/Cellar/you-get/0.4.1011_1/libexec/lib/python3.6/site-packages/you_get/extractors
在该目录下找到bilibili.py,打开文件,在代码的70行进行修改。

# 使用第三行的代码替换第二行代码
xml_str = get_content(api_url)
xml_str = 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'})

再用--debug试一下。

you-get -i 视频地址 --debug

是不是发现B站的视频又可以下载了,小伙伴们又可以愉快玩耍了。

你可能感兴趣的:(you-get修复B站下载方法)