用于在 colab 中以最高分辨率 dl youtube 视频的 Python 库

原文标题Python library to dl youtube videos with highest resolution in colab

我想在 google colab 中快速下载 1080p/720p 等视频。所以我找到了pytube但显然它不支持 1080p 视频。

from pytube import YouTube
link = "    https://www.youtube.com/watch?v=Dv91YPlFmQA       ".replace(' ','')

yt = YouTube(link)  

print(yt.streams.get_highest_resolution())

这里的最高质量是 720p,但视频有 1080p,顺便说一句,下载速度非常快,可以在几秒钟内下载 2GB 的视频。

所以我尝试了

youtube_dl_options = {
    "format": "mp4[height=1080]", # This will select the specific resolution typed here
    "outtmpl":'/content/drive/MyDrive/' +"%(title)s-%(id)s.%(ext)s",
    "restrictfilenames": True,
    "nooverwrites": True,
    "writedescription": True,
    "writeinfojson": True,
    "writeannotations": True,
    "writethumbnail": True,
    "writesubtitles": True,
    "writeautomaticsub": True
}
from __future__ import unicode_literals
import youtube_dl
link = "     https://www.youtube.com/watch?v=Dv91YPlFmQA     ".replace(' ','')
downloadLinks = [link]

with youtube_dl.YoutubeDL(youtube_dl_options) as ydl:
    ydl.download(downloadLinks)

它有 1080p,但它的下载速度非常低,比如 70KB/s,所以有没有其他库可以以更快的速度下载 1080p 分辨率的 youtube vids。

因此,如果您知道我可以在 colab 中使用 pytube(ofc 和音频)进行 dl 1080p 的方式,或者无论如何使youtube-dl更快或任何其他可以提供此功能的方式,请告诉我。

原文链接:https://stackoverflow.com//questions/71555557/python-library-to-dl-youtube-videos-with-highest-resolution-in-colab

回复

我来回复
  • Subham的头像
    Subham 评论

    阅读此检查您可能会得到所需内容的链接。

    2年前 0条评论