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't grab filename when using youtube-dl as python module #9550

Closed
kereilly opened this issue May 20, 2016 · 1 comment
Closed

Can't grab filename when using youtube-dl as python module #9550

kereilly opened this issue May 20, 2016 · 1 comment

Comments

@kereilly
Copy link

@kereilly kereilly commented May 20, 2016

Please follow the guide below

  • You will be asked some questions and requested to provide some information, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your issue (like that [x])
  • Use Preview tab to see how your issue will actually look like

Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2016.05.16. If it's not read this FAQ entry and update. Issues with outdated version will be rejected.

  • [x ] I've verified and I assure that I'm running youtube-dl 2016.05.16

Before submitting an issue make sure you have:

  • [ x] At least skimmed through README and most notably FAQ and BUGS sections
  • [ x] Searched the bugtracker for similar issues including closed ones

What is the purpose of your issue?

  • Bug report (encountered problems with youtube-dl)
  • Site support request (request for adding support for a new site)
  • Feature request (request for a new functionality)
  • [ x] Question
  • Other

The following sections concretize particular purposed issues, you can erase any section (the contents between triple ---) not applicable to your issue


Description of your issue, suggested solution and other information

Explanation of your issue in arbitrary form goes here. Please make sure the description is worded well enough to be understood. Provide as much context and examples as possible.
If work on your issue required an account credentials please provide them or explain how one can obtain them.

I'm using youtube-dl as a python module in a script. i'm running youtube-dl 2016.05.16 and python 2.7.10 on mac os 10.11. The problem i'm having is getting youtube-dl to report the name of the file it downloads. i'm using the ydl.extract_info function but the file extension will be different from what is reported by youtube-dl and what is actually saved. here is the code

destination = archival_location + ".%(ext)s"
ydl_opts = {
    'logger' : MyLogger(),
    'progress_hooks': [my_hook],
    'outtmpl' : destination,
    'ignoreerrors' : True
}
try:
    with YoutubeDL(ydl_opts) as ydl:
        info = ydl.extract_info(url, download=False)
        download_target = ydl.prepare_filename(info)
        ydl.download([url])

so my download_target variable will have something like "downloaded_file.mp4" but the actually file is "downloaded_file.mkv". I'm guessing since it was a youtube download ffmpeg muxed the audio and video together making it an mkv file? But i need to preserve file extensions when i can so i know its type for further processing. thats why i'm using the ".%(ext)s" in the 'outtmpl' option. anything i'm doing wrong here or is this just what happens when ffmpeg gets used.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented May 20, 2016

Duplicate of #5710.

@dstftw dstftw closed this May 20, 2016
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.