我一直在尝试使用python而不是控制台来使用youtubedl。我正在尝试获取视频的一些信息,如可用的视频格式、标题、视频的持续时间等。除了listformats
,其他选项都不起作用。所以我尝试了文档中描述的选项的不同组合。不幸的是什么都没用。我只看到listformats
中的视频格式列表。另外,输出仅显示在控制台中,但我需要在变量中显示输出信息,例如video_details
。在
from __future__ import unicode_literals
import youtube_dl
ydl_opts = {
'-v': True,
'format': '-f',
'print_json': True,
'listformats': '--list-formats',
'getfilename': '--get-filename',
'--get-filename': True,
'-e': True,
}
ydl = youtube_dl.YoutubeDL(ydl_opts)
video_details = ydl.download(['https://www.youtube.com/watch?v=BaW_jenozKc'])
你想提取信息。 使用
extract_info
-方法而不是download
,它会工作的!在相关问题 更多 >
编程相关推荐