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

FR: Output formatting to omit NA #13326

Open
Hubbitus opened this issue Jun 9, 2017 · 2 comments
Open

FR: Output formatting to omit NA #13326

Hubbitus opened this issue Jun 9, 2017 · 2 comments

Comments

@Hubbitus
Copy link

@Hubbitus Hubbitus commented Jun 9, 2017

Please follow the guide below

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

Description of your issue, suggested solution and other information

You allow formatting file name of output by templating.
And according to doc, quoting:

Each aforementioned sequence when referenced in an output template will be replaced by the actual value corresponding to the sequence name. Note that some of the sequences are not guaranteed to be present since they depend on the metadata obtained by a particular extractor. Such sequences will be replaced with NA.

If I use it like -o '%(playlist)s.%(playlist_index)s %(title)s.%(ext)s' in config and said download single video, not in playlist, I got file named similar to: NA.NA Viktor Gamov on In-Memory Data Grids.mkv
It is wired.

First simple workaround I found is configure also: --exec 'rename "NA.NA " "" NA.NA* || [ $? -eq 4 ] #{}' (and please note {} goes after comment mark because otherwise we got error on rename if we save multiple files for json and description).

It solve only partial of problem. Files named as expected, but when I start download multiple files - all will be re-downloaded from start, without continue!

My suggestion introduce option to embed python code as formatter something like:

-o '${arg['playlist'] + '.' + str(arg['playlist_index']) if arg['playlist'] != 'NA' else ''} %(title)s.%(ext)s'

It is desired and flexible solution, but will require invent wheel for parsing.

Otherwise possible solution just allow provide lambda function to fully create such string in python style of lambda. Idea borrowed from offlineimap configuration offered.

For example:

--output-lambda '(lambda arg: arg['playlist'] + '.' + str(arg['playlist_index']) + ' ' + arg['title'] + ' - ' + arg['title'] if arg['playlist'] != 'NA' else '') ${arg['playlist'] + '.' + str(arg['playlist_index']) if arg['playlist'] != 'NA' else arg['title'] + ' - ' + arg['title']}'

Obviously arg should be dict and contain keys as described in documentation.

@Hubbitus
Copy link
Author

@Hubbitus Hubbitus commented Aug 28, 2017

Are you interesting in that future? Have it worth to implement it and provide pull request?

@kristofferR
Copy link

@kristofferR kristofferR commented Feb 1, 2020

I'd love this feature implemented too.

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.