让youtube-dl写给亚马逊s3

时间:2015-12-13 04:20:05

标签: amazon-web-services amazon-s3 youtube-dl

我现在有一个运行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函数是我将托管移植到亚马逊的唯一解决方案吗?

1 个答案:

答案 0 :(得分:0)

您可以使用goofys之类的内容将youtube-dl的输出重定向到S3。