Pytube 不下载视频

发布于 2025-01-20 06:21:01 字数 385 浏览 2 评论 0原文

我安装了 pytube (pytube==12.0.0) 。当我运行代码时,它什么也不做,然后完成执行。它不会给出任何错误,但也不会下载视频。这可能与我的计算机上安装了一个过滤器有关,我之前在使用 heroku cli 时遇到过问题,因为它使用代理。但我还没有找到任何关于如何解决这个问题的信息。

我的代码是:

import pytube

url = 'https://www.youtube.com/watch?v=4SFhwxzfXNc'

youtube = pytube.YouTube(url)

video = youtube.streams.get_highest_resolution()

video.download('/Downloads')

I have pytube (pytube==12.0.0) installed. When I run my code it just does nothing, and then finishes executing. It doesn't give any errors, but it also doesn't download the video. This might have something to do with the fact that I have a filter installed on my computer, I've had issues with that before when using the heroku cli, because it was using a proxy. I haven't been able to find anything on how to fix that though.

My code is:

import pytube

url = 'https://www.youtube.com/watch?v=4SFhwxzfXNc'

youtube = pytube.YouTube(url)

video = youtube.streams.get_highest_resolution()

video.download('/Downloads')

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

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

发布评论

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

评论(2

独夜无伴 2025-01-27 06:21:01

愚蠢的错误 - video.download('/Downloads') 不是正确的文件路径。这是有效的代码:

import pytube

url = 'https://www.youtube.com/watch?v=4SFhwxzfXNc'

youtube = pytube.YouTube(url)

video = youtube.streams.get_highest_resolution()

video.download('C:/Users/user1/Downloads')

Stupid mistake - video.download('/Downloads') wasn't the right file path. This is the code that works:

import pytube

url = 'https://www.youtube.com/watch?v=4SFhwxzfXNc'

youtube = pytube.YouTube(url)

video = youtube.streams.get_highest_resolution()

video.download('C:/Users/user1/Downloads')
你的往事 2025-01-27 06:21:01

你尝试过吗?

from pytube import YouTube, helpers

proxy_handler = {
    "http": "127.0.0.1:20304",
    'https': '127.0.0.1:20304'
}
helpers.install_proxy(proxy_handler)

来源:https://github.com/pytube/pytube/issues/1128

端口应该取决于你的代理

Did you tried?

from pytube import YouTube, helpers

proxy_handler = {
    "http": "127.0.0.1:20304",
    'https': '127.0.0.1:20304'
}
helpers.install_proxy(proxy_handler)

Source: https://github.com/pytube/pytube/issues/1128

Port should depend on your proxy

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