我现在有一个运行youtube-dl
来转换视频的功能。
def start_audio_extraction(url, audio_filename):
localfile = 'music/%s.mp3' % audio_filename
temp_filepath = os.environ.get(s3.Object(bucketname, localfile))
ydl_opts = {
'format': 'bestaudio/best', # choice of quality
'extractaudio' : True, # only keep the audio
'outtmpl': temp_filepath, # name the location
'noplaylist' : True, # only download single song, not playlist
'prefer-ffmpeg' : True,
# 'verbose': True,
'postprocessors': [{
'key': 'FFmpegMetadata'
},
{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
'logger': MyLogger(),
'progress_hooks': [my_hook],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
result = ydl.download([url])
return result
但问题是,当我运行此操作时,我最终收到此错误
File "/home/john/.virtualenvs/yout/local/lib/python2.7/site-packages/youtube_dl/YoutubeDL.py", line 578, in prepare_filename
tmpl = compat_expanduser(outtmpl)
File "/home/john/.virtualenvs/yout/local/lib/python2.7/site-packages/youtube_dl/compat.py", line 353, in compat_expanduser
if not path.startswith('~'):
AttributeError: 'NoneType' object has no attribute 'startswith'
我尝试在youtube-dl存储库中询问,并告诉outtmpl
必须是字符串。
因为我认为s3对象是lambda函数是我将托管移植到亚马逊的唯一解决方案吗?