当我运行它时:
ydl_opts = {
'outtmpl': files_path + '%(id)s.%(ext)s',
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([video_url])
Run Code Online (Sandbox Code Playgroud)
我在日志中得到它:
[ffmpeg] Merging formats into "/home/tmp/0uBOtQOO70Y.mkv"
[wsgi:error] Deleting original file /home/tmp/0uBOtQOO70Y.f137.mp4 (pass -k to keep)
[wsgi:error] Deleting original file /home/tmp/0uBOtQOO70Y.f251.webm (pass -k to keep)
Run Code Online (Sandbox Code Playgroud)
下载之前或之后如何获取/home/tmp/0uBOtQOO70Y.mkv ?
如果我做到了:
ydl_opts = {}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
info = ydl.extract_info(video_url, download=False)
Run Code Online (Sandbox Code Playgroud)
然后信息中是mp4扩展名