【发布时间】:2020-11-22 01:44:34
【问题描述】:
从这个帖子获得帮助:download only audio from youtube video using youtube-dl in python script
import youtube_dl #installed youtube_dl file
options = {
'format':'bestaudio/best',
'extractaudio':True, #extracting audio
'audioformat':'mp3', #file options and format
'outtmpl':'%(id)s.%(ext)s', #name the file the ID of the video
'noplaylist':True,
'nocheckcertificate':True,
'postprocessors': [{
'key': 'FFmpegExtractAudio',# Used ffmpeg for converting the file to mp3
'preferredcodec': 'mp3',
'preferredquality': '192',
}]
}
with youtube_dl.YoutubeDL(options) as ydl:
ydl.download(['https://youtu.be/BZP1rYjoBgI']) #final downloading
【问题讨论】:
标签: python audio youtube youtube-dl