ydl_opts = { 'format': 'bestaudio', 'postprocessors': [{'key':'FFmpegExtractAudio'}], } with youtube_dl.YoutubeDL(ydl_opts) as ydl: info = ydl.extract_info(uri, download=True) filename = ydl.prepare_filename(info)