小编oma*_*ich的帖子

使用 pytube 从 YouTube 下载音频

我正在使用 pytube 和 Python 3.5 从 YouTube 下载视频,但我需要将视频转换为带有 .avi 扩展名的音频。

这是我目前正在使用的代码:

from pytube import YouTube

yt = YouTube(str(input("Enter the video link: ")))
videos = yt.get_videos()

s = 1
for v in videos:
    print(str(s)+". "+str(v))
    s += 1

n = int(input("Enter the number of the video: "))
vid = videos[n-1]

destination = str(input("Enter the destination: "))
vid.download(destination)

print(yt.filename+"\nHas been successfully downloaded")
Run Code Online (Sandbox Code Playgroud)

在上面的代码中,我可以下载视频。

我的问题是:如何直接下载 YouTube 上扩展名为 的视频的音频.avi

YouTube 数据 API 可以帮助我专门下载音频吗?

youtube youtube-data-api python-3.5 pytube

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

python-3.5 ×1

pytube ×1

youtube ×1

youtube-data-api ×1