Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you write the outtmp to memory? #7855

Closed
nadermx opened this issue Dec 13, 2015 · 1 comment
Closed

Can you write the outtmp to memory? #7855

nadermx opened this issue Dec 13, 2015 · 1 comment

Comments

@nadermx
Copy link

@nadermx nadermx commented Dec 13, 2015

I've been trying for some time now to have youtube-dl output the mp3 into a temporary file so I can migrate it or write straight to amazon s3.

Every iteration I have tried from BytesIO to Lambda returns AttributeError: xxxinstance has no attribute 'startswith'

I saw that there is the '-o -': True option which streams the data. What I'm wondering is if it would be possible to use that or how I would go about trying to get this to output to amazon S3

using the boto3 library you can do something along these lines

    # Upload the file to S3
    s3_client.upload_file(temp_filepath, bucketname, output_filepath)

    # Download the file from S3
    s3_client.download_file(bucketname, output_filepath, output_filepath)

Here is what I currently have which is still not working.

    output = output_filepath = open('music/%s.mp3' % audio_filename)

    ydl_opts = {
    'format': 'bestaudio/best', # choice of quality
    'extractaudio' : True,      # only keep the audio
    'outtmpl': output,  # name the location
    # '-o -': True,               #to stream content out
    '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])


@dstftw
Copy link
Collaborator

@dstftw dstftw commented Dec 13, 2015

You have been already clarified that outtmpl must be string. If you want to stream to stdout set outtmpl to -.

@dstftw dstftw closed this Dec 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.