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

Access to info_dict before/after download/post-processing when embedding #10987

Open
DavidVentura opened this issue Oct 21, 2016 · 1 comment
Open
Labels

Comments

@DavidVentura
Copy link

@DavidVentura DavidVentura commented Oct 21, 2016

  • I've verified and I assure that I'm running youtube-dl 2016.10.21.1

Before submitting an issue make sure you have:

  • At least skimmed through README and most notably FAQ and BUGS sections
  • 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)
  • Question
  • Other

I'm trying to get the exact filename that'll be written(merged) by youtube-dl. It's the same filename sent to debug when setting forcefilename to true on the options.

I want to access this:
https://github.com/rg3/youtube-dl/blob/master/youtube_dl/YoutubeDL.py#L1531

With youtube_dl.prepare_filename(result) I can get the merged filename without extension.. how do I get the extension?

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Mar 3, 2017

Sorry for the late response. In case you're still looking for a solution, here's a hacky version:

from __future__ import unicode_literals
import youtube_dl

filename = None


class Logger(object):
    def debug(self, message):
        global filename
        filename = message


ydl_opts = {
    'forcefilename': True,
    'simulate': True,
    'logger': Logger(),
}

with youtube_dl.YoutubeDL(ydl_opts) as ydl:
    ydl.extract_info('http://www.youtube.com/watch?v=BaW_jenozKc')

print(filename)

It would be great if embedders can access info_dict before/after downloading and post-processing...

@yan12125 yan12125 added the request label Mar 3, 2017
@yan12125 yan12125 changed the title How to get the final (merged) filename when embedding? Access to info_dict before/after download/post-processing when embedding Mar 3, 2017
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.