def downloadURL(url, preferredCodec=None, preferredQuality=None):
""" Downloads song using youtube_dl and the song's youtube
url.
"""
codec, quality = getCodecAndQuality()
ydl_opts = {
'format': 'bestaudio/best',
'quiet': True,
'no_warnings': True,
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': codec,
'preferredquality': quality,
},
{'key': 'FFmpegMetadata'},
],
}
try:
with YoutubeDL(ydl_opts) as ydl:
return ydl.extract_info(url, download=True)
except:
print("Problem downloading " + url)
return None
评论列表
文章目录