【问题标题】:how to use progress bar in pytube3如何在pytube3中使用进度条
【发布时间】:2020-09-07 14:21:07
【问题描述】:

我知道这个问题被问了很多,但我尝试了所有答案,但都没有奏效。

所以我写了这段代码来从 youtube 下载视频

try:
  from pytube import YouTube
  from pytube import Playlist
except Exception as e:
    print("som module are missing{}".format(e))

link = "a random youtube link"
yt = YouTube(link).streams.get_highest_resolution() 
# I couldn't get the link from user via input since I couldn't
# paste link in pycharm output section)

print(yt.title, " is downloading...")
ytd = yt.download("C:/Users/pedram/OneDrive/Desktop/test")
print("Download Completed!")

此代码运行良好,可从 youtube 下载视频。 但我也想添加一个下载栏,这样我就可以看到下载视频的进度 由于 pytube 不起作用,我下载了 pytube3,我认为这就是为什么那里的大多数答案对我不起作用的原因。 如果有人知道我应该怎么做,我会很感激他们的帮助。

【问题讨论】:

    标签: python python-3.x pytube


    【解决方案1】:

    我认为使用 tqdm 库可以解决问题。 例如。

    import tqdm
    for i in tqdm(some iterator..):
      ...
    

    【讨论】:

    • 我明白了...但是我的代码中没有迭代器,所以我确定它在这里是否有用
    • 试试while (tqdm(YouTube(link).streams.get_highest_resolution())) :
    猜你喜欢
    • 1970-01-01
    • 2019-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-29
    相关资源
    最近更新 更多