pytube下载字节保持不准确/非常慢

发布于 2025-02-04 00:42:29 字数 595 浏览 3 评论 0原文

我目前正在为pytube和tkinter编程YouTube下载器。完成编程后的GUI后,我注意到下载过程中还来自进度功能的字节比实际下载本身更长(完成的文件已经存在,而进度栏仍然会以有时在一分钟内打印出进度)

这很奇怪的是,昨天它的工作正常。这就是为什么我尝试一个没有任何GUI的简单程序,但我仍然有同样的问题。

import pytube

def on_progress(stream, chunk, bytes_remaining):
    print(bytes_remaining)

def on_complete(stream, file_path):
    print("Finished")

video = pytube.YouTube("MyLink", on_progress_callback=on_progress, on_complete_callback=on_complete)
video.streams.get_highest_resolution().download(output_path="C:/My/Path")

在过去的几天里,我从事该计划的工作,并进行了许多测试尝试。可能是我尝试在很小一段时间内下载太多视频的原因,以便Pytube有点超载?

I'm currently programming a YouTube Downloader with Pytube and Tkinter. After I finished programming the GUI I noticed that the bytes remaining coming from the progress function during the Download need way longer than the actual download itself (the finished file is already there while the progress bar still prints out the progress for sometimes over a minute)

What's weird about this is that it worked perfectly fine yesterday. That's why I tried out a simple program without any GUI and i still have same problem.

import pytube

def on_progress(stream, chunk, bytes_remaining):
    print(bytes_remaining)

def on_complete(stream, file_path):
    print("Finished")

video = pytube.YouTube("MyLink", on_progress_callback=on_progress, on_complete_callback=on_complete)
video.streams.get_highest_resolution().download(output_path="C:/My/Path")

I worked on the program for the past few days and did many test tries. Could be the reason that I tried downloading too many videos over a small period of time so Pytube is kind of overloaded?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初心 2025-02-11 00:42:29

我看到您正在使用 pytube 库,该库使用 youtube-dl.exe ,现在可能已经过时了。

因此,您不应使用 pytube 库,而应使用
yt-dlp.exe 您可以下载在这里。

您可以阅读有关如何使用它的文档,如果您仍然面临问题,请随时提出。我对这些东西有很好的经验。

I see that you are using the PyTube library which uses youtube-dl.exe which is probably outdated now.

So instead of using the PyTube library, you should use
yt-dlp.exe which you can download here.

You can read through the documentation on how to use it and if you still face problems using it then feel free to ask. I have a good experience of this stuff.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文