Skip to content

Commit

Permalink
Auto-select default format in -f- (#7101)
Browse files Browse the repository at this point in the history
Authored by: ivanskodje, pukkandan
Closes #6720
  • Loading branch information
ivanskodje committed May 29, 2023
1 parent 4cbfa57 commit 372a0f3
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions yt_dlp/YoutubeDL.py
Original file line number Diff line number Diff line change
Expand Up @@ -2744,21 +2744,22 @@ def is_wellformed(f):
return info_dict

format_selector = self.format_selector
if format_selector is None:
req_format = self._default_format_spec(info_dict, download=download)
self.write_debug('Default format spec: %s' % req_format)
format_selector = self.build_format_selector(req_format)

while True:
if interactive_format_selection:
req_format = input(
self._format_screen('\nEnter format selector: ', self.Styles.EMPHASIS))
req_format = input(self._format_screen('\nEnter format selector ', self.Styles.EMPHASIS)
+ '(Press ENTER for default, or Ctrl+C to quit)'
+ self._format_screen(': ', self.Styles.EMPHASIS))
try:
format_selector = self.build_format_selector(req_format)
format_selector = self.build_format_selector(req_format) if req_format else None
except SyntaxError as err:
self.report_error(err, tb=False, is_error=False)
continue

if format_selector is None:
req_format = self._default_format_spec(info_dict, download=download)
self.write_debug(f'Default format spec: {req_format}')
format_selector = self.build_format_selector(req_format)

formats_to_download = list(format_selector({
'formats': formats,
'has_merged_format': any('none' not in (f.get('acodec'), f.get('vcodec')) for f in formats),
Expand Down

0 comments on commit 372a0f3

Please sign in to comment.