通过you-get下载视频,自动判断下载最优画质,jupyter notebook调试成功。python程序如下:
import requests
import you_get
import os
#fmt = "dash-hdflv2_4k"#"dash-flv720" #"dash-flv"#"dash-hdflv2"#
address = "BV1iY411h72p"
aaa = requests.get(f"https://www.bilibili.com/video/{address}").text
if "超清 4K" in aaa:
fmt = "dash-hdflv2_4k"
elif "高清 1080P+" in aaa:
fmt = "dash-hdflv2"
elif "高清 1080P" in aaa:
fmt = "dash-flv"
elif "高清 720P" in aaa:
fmt = "dash-flv720"
elif "清晰 480P" in aaa:
fmt = "dash-flv480"
elif "流畅 360P" in aaa:
fmt = "dash-flv360"
print(fmt)
c = f"you-get -c d://ipynb//cookies.sqlite -o f://视频 --format={fmt} https://www.bilibili.com/video/{address} --debug"
print(c)
!$c