python youtube_dl extract_info
def download_clip(url, name):
ydl_opts = {
'format': 'bestaudio/best',
'outtmpl': dir_utils.get_perm_med_dir() + f'/sound_board/{name}.wav',
'noplaylist': True,
'continue_dl': True,
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'wav',
'preferredquality': '192', }]
}
try:
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.cache.remove()
info_dict = ydl.extract_info(url, download=False)
ydl.prepare_filename(info_dict)
ydl.download([url])
return True
except Exception:
return False