我在学习pytube
下载 Youtube 视频并尝试tqdm
在它的顶部显示进度条,但它显示各种错误,而且我无法理解当我下载视频时发生了什么pytube
并显示进度条,这就是我无法添加的原因tqdm
in it.
我写的代码pytube
运行良好,代码如下:
from pytube import YouTube
url = str(input("Enter the video link: "))
yt = YouTube(url)
videos = yt.streams.filter(file_extension='mp4').all()
filename = yt.title
s = 1
for v in videos:
print(str(s)+". "+str(v))
s += 1
n = int(input("Enter the number of the video: "))
vid = videos[n-1]
vid.download("C:/Users/user/Downloads/")
print(yt.title,"\nHas been successfully downloaded")
I need tqdm
添加到代码中以显示进度条。
我不知道tqdm
,但是有一个进度条功能 https://stackoverflow.com/questions/55882563/is-there-a-progress-bar-feature-for-pytube for pytube
.
我这样使用它:
from pytube.cli import on_progress
from pytube import YouTube as YT
...
yt = YT(video_url, on_progress_callback=on_progress)
yt.streams\
.filter(file_extension='mp4')\
.get_lowest_resolution()\
.download(video_path)
看起来像这样:
PSY - GANGNAM STYLE(강남스타일) MV.mp4
↳ |███████████████████████████████████████| 100.0%
希望能帮助到你!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)