Pytube 响应时间太长

问题描述 投票:0回答:1

我正在尝试使用 pytube 制作 YouTube 下载器。首先,我测试了通过用户输入仅从视频中获取标题

from pytube import YouTube

link = input("type a youtube url: ")
#path = input("where you want to download")

yt = YouTube(link)

print(yt.title)

它可以工作,但是仅仅获得标题就需要大约 2 分钟,做其他任何事情都需要很长时间。问题是什么?有办法让它更快吗?

python pytube
1个回答
0
投票

打开 pytube/_ main _.py
转到 def fmt_streams(self) 行,然后注释或删除此代码:

# If the cached js doesn't work, try fetching a new js file
# https://github.com/pytube/pytube/issues/1054
    try:
        extract.apply_signature(stream_manifest, self.vid_info, self.js)
    except exceptions.ExtractError:
        # To force an update to the js file, we clear the cache and retry
        self._js = None
        self._js_url = None
        pytube.__js__ = None
        pytube.__js_url__ = None
        extract.apply_signature(stream_manifest, self.vid_info, self.js)

[https://github.com/pytube/pytube/issues/1453#issuecomment-1382458877]

© www.soinside.com 2019 - 2024. All rights reserved.