Repository: yt-dlp/yt-dlp

Issue:
-f- + enter = autoselect format
### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

- [X] I understand that I will be **blocked** if I *intentionally* remove or skip any mandatory\* field

### Checklist

- [X] I'm requesting a feature unrelated to a specific site
- [X] I've looked through the [README](https://github.com/yt-dlp/yt-dlp#readme)
- [X] I've verified that I'm running yt-dlp version **2023.03.04** ([update instructions](https://github.com/yt-dlp/yt-dlp#update)) or later (specify commit)
- [X] I've searched [known issues](https://github.com/yt-dlp/yt-dlp/issues/3766) and the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues **including closed ones**. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)

### Provide a description that is worded well enough to be understood

Using -f- prompts `"Enter format selector:"`
When entering nothing (i.e. just pressing Enter) outputs `"ERROR: Requested format is not available"`

It would be more helpful in this case to autoselect the default format (i.e. the format which would have been selected by not using the -f switch at all) instead of _asking again_ (which doesn't make too much sense IMO).

### use cases
User wants to see the available formats, possibly select the format himself and then download - all in the same run. So `-f-` is used.
yt-dlp prints available formats and prompts for format selection.
At this point the user has no way (at least AFAIK) to say:

- _"Ok yt-dlp, thank you for showing me all available formats. I agree with the default selection. Please proceed."_
- _"Ok yt-dlp, thank you for showing me all available formats, but I am not really sure what is the best one, so please autoselect."_
- _"Ok yt-dlp, thank you for showing me all available formats, but I am too lazy to copy/paste the best format, which coincides with the default selection anyway, so please let me just press ENTER."_


### implementation
The user prompt would need to be changed so that this doesn't remain an undocumented feature:

`Enter format selector (or press ENTER for default selection or STRG+C to quit):`

### dependencies

* depends on #2493 (indicate default selection with red asterisk)

### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [ ] If using API, add `'verbose': True` to `YoutubeDL` params instead
- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

```shell
[debug] Command-line config: ['https://www.youtube.com/watch?v=BMX-qv7lkB4', '-f-']
[debug] Portable config "c:\hp\-\!portableapps\yt-dlp\yt-dlp.conf": ['--verbose', '--format-sort', 'hasvid,ie_pref,quality,res,hdr,codec,size,br,asr,ext,fps,hasaud,lang,source,proto,id', '-f', 'bestvideo*+bestaudio/best', '--paths', 'c:\\hp\\-\\#YT', '-o', '.\\%(playlist|)s\\%(playlist_index|)02d%(playlist_index& = |)s%(release_date>%Y-%m-%d,release_timestamp>%Y-%m-%d,upload_date>%Y-%m-%d,timestamp>%Y-%m-%d|#nodate#)s %(alt_title,title)s\\%(title)s [%(extractor)s.%(extractor_key)s.%(id)s] [%(format_id)s].%(ext)s', '-o', 'thumbnail:.\\%(playlist|)s\\%(playlist_index|)02d%(playlist_index& = |)s%(release_date>%Y-%m-%d,release_timestamp>%Y-%m-%d,upload_date>%Y-%m-%d,timestamp>%Y-%m-%d|#nodate#)s %(alt_title,title)s\\thumbs\\thumb.%(ext)s', '-o', 'subtitle:.\\%(playlist|)s\\%(playlist_index|)02d%(playlist_index& = |)s%(release_date>%Y-%m-%d,release_timestamp>%Y-%m-%d,upload_date>%Y-%m-%d,timestamp>%Y-%m-%d|#nodate#)s %(alt_title,title)s\\subs\\%(alt_title,title)s [%(extractor)s.%(extractor_key)s.%(id)s] [%(format_id)s].%(ext)s', '-o', 'infojson:.\\%(playlist|)s\\%(playlist_index|)02d%(playlist_index& = |)s%(release_date>%Y-%m-%d,release_timestamp>%Y-%m-%d,upload_date>%Y-%m-%d,timestamp>%Y-%m-%d|#nodate#)s %(alt_title,title)s\\!nfo\\%(alt_title,title)s [%(extractor)s.%(extractor_key)s.%(id)s] [%(format_id)s].%(ext)s', '-o', 'link:.\\%(playlist|)s\\%(playlist_index|)02d%(playlist_index& = |)s%(release_date>%Y-%m-%d,release_timestamp>%Y-%m-%d,upload_date>%Y-%m-%d,timestamp>%Y-%m-%d|#nodate#)s %(alt_title,title)s\\!nfo\\%(title)s [%(extractor)s.%(extractor_key)s.%(id)s] [%(format_id)s].%(ext)s', '-o', 'description:.\\%(playlist|)s\\%(playlist_index|)02d%(playlist_index& = |)s%(release_date>%Y-%m-%d,release_timestamp>%Y-%m-%d,upload_date>%Y-%m-%d,timestamp>%Y-%m-%d|#nodate#)s %(alt_title,title)s\\!nfo\\%(title)s [%(extractor)s.%(extractor_key)s.%(id)s] [%(format_id)s].%(ext)s', '-o', 'annotation:.\\%(playlist|)s\\%(playlist_index|)02d%(playlist_index& = |)s%(release_date>%Y-%m-%d,release_timestamp>%Y-%m-%d,upload_date>%Y-%m-%d,timestamp>%Y-%m-%d|#nodate#)s %(alt_title,title)s\\!nfo\\%(title)s [%(extractor)s.%(extractor_key)s.%(id)s] [%(format_id)s].%(ext)s', '-o', 'pl_infojson:.\\%(playlist|)s\\playlist.%(ext)s', '-o', 'pl_thumbnail:.\\%(playlist|)s\\folder.%(ext)s', '-o', 'pl_description:.\\%(playlist|)s\\playlist description.%(ext)s', '--output-na-placeholder', '~~~', '--write-info-json', '--write-description', '--write-annotations', '--no-overwrites', '--no-post-overwrites', '--merge-output-format', 'mkv', '--remux-video', 'mkv', '--write-subs', '--write-auto-subs', '--all-subs', '--sub-langs', 'all', '--sub-format', 'all/ttml/vtt/best', '--write-thumbnail', '--write-all-thumbnails', '--embed-metadata', '--embed-chapters', '--no-embed-info-json', '--write-link', '--write-url-link', '--write-desktop-link', '--no-check-certificate', '--retries', 'infinite', '--geo-bypass', '--geo-bypass-country', 'AT', '--no-clean-infojson', '--write-comments', '--audio-multistreams', '--no-playlist']
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2023.03.04 [392389b7d] (win_exe)
[debug] Python 3.8.10 (CPython AMD64 64bit) - Windows-10-10.0.19045-SP0 (OpenSSL 1.1.1k  25 Mar 2021)
[debug] exe versions: ffmpeg N-105208-gb24f0c82b3-20220108 (setts), ffprobe N-105208-gb24f0c82b3-20220108
[debug] Optional libraries: Cryptodome-3.17, brotli-1.0.9, certifi-2022.12.07, mutagen-1.46.0, sqlite3-2.6.0, websockets-10.4
[debug] Proxy map: {}
[debug] Loaded 1786 extractors
[debug] Using fake IP 77.118.217.106 (AT) as X-Forwarded-For
[youtube] Extracting URL: https://www.youtube.com/watch?v=BMX-qv7lkB4
[youtube] BMX-qv7lkB4: Downloading webpage
[youtube] BMX-qv7lkB4: Downloading android player API JSON
[debug] Sort order given by user: hasvid, ie_pref, quality, res, hdr, codec, size, br, asr, ext, fps, hasaud, lang, source, proto, id
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, vcodec:vp9.2, channels, acodec, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, quality, res, hdr, vcodec, acodec, filesize, fs_approx, tbr, vbr, abr, asr, vext, aext, fps, hasaud, lang, source, proto, id, channels
[youtube] Downloading comment section API JSON
[youtube] Downloading ~726 comments
[youtube] Sorting comments by newest first
[youtube] Downloading comment API JSON page 1 (0/726)
[youtube] Interrupted by user
[youtube] Extracted 0 comments
[info] Available formats for BMX-qv7lkB4:
ID  EXT   RESOLUTION FPS CH │   FILESIZE   TBR PROTO │ VCODEC          VBR ACODEC      ABR ASR MORE INFO
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────
sb1 mhtml 25x45        1    │                  mhtml │ images                                  storyboard
sb2 mhtml 48x27        2    │                  mhtml │ images                                  storyboard
sb0 mhtml 50x90        1    │                  mhtml │ images                                  storyboard
599 m4a   audio only      2 │  206.47KiB   31k dash  │ audio only          mp4a.40.5   31k 22k ultralow, m4a_dash
600 webm  audio only      2 │  211.02KiB   32k dash  │ audio only          opus        32k 48k ultralow, webm_dash
139 m4a   audio only      2 │  326.27KiB   49k dash  │ audio only          mp4a.40.5   49k 22k low, m4a_dash
249 webm  audio only      2 │  305.37KiB   46k dash  │ audio only          opus        46k 48k low, webm_dash
250 webm  audio only      2 │  372.20KiB   56k dash  │ audio only          opus        56k 48k low, webm_dash
140 m4a   audio only      2 │  863.48KiB  130k dash  │ audio only          mp4a.40.2  130k 44k medium, m4a_dash
251 webm  audio only      2 │  668.42KiB  100k dash  │ audio only          opus       100k 48k medium, webm_dash
17  3gp   176x144      8  1 │  514.64KiB   77k https │ mp4v.20.3       77k mp4a.40.2    0k 22k 144p
597 mp4   144x256     15    │  215.97KiB   32k dash  │ avc1.4d400b     32k video only          144p, mp4_dash
160 mp4   144x256     30    │  636.75KiB   96k dash  │ avc1.4d400c     96k video only          144p, mp4_dash
598 webm  144x256     15    │  189.40KiB   28k dash  │ vp9             28k video only          144p, webm_dash
278 webm  144x256     30    │  574.40KiB   86k dash  │ vp9             86k video only          144p, webm_dash
394 mp4   144x256     30    │  532.70KiB   80k dash  │ av01.0.00M.08   80k video only          144p, mp4_dash
133 mp4   240x426     30    │    1.02MiB  157k dash  │ avc1.4d4015    157k video only          240p, mp4_dash
242 webm  240x426     30    │    1.19MiB  183k dash  │ vp9            183k video only          240p, webm_dash
395 mp4   240x426     30    │  952.08KiB  143k dash  │ av01.0.00M.08  143k video only          240p, mp4_dash
134 mp4   360x640     30    │    1.80MiB  277k dash  │ avc1.4d401e    277k video only          360p, mp4_dash
18  mp4   360x640     30  2 │    3.89MiB  598k https │ avc1.42001E    598k mp4a.40.2    0k 48k 360p
243 webm  360x640     30    │    2.17MiB  334k dash  │ vp9            334k video only          360p, webm_dash
396 mp4   360x640     30    │    1.97MiB  303k dash  │ av01.0.01M.08  303k video only          360p, mp4_dash
135 mp4   480x854     30    │    2.70MiB  415k dash  │ avc1.4d401f    415k video only          480p, mp4_dash
244 webm  480x854     30    │    3.08MiB  474k dash  │ vp9            474k video only          480p, webm_dash
397 mp4   480x854     30    │    3.55MiB  546k dash  │ av01.0.04M.08  546k video only          480p, mp4_dash
136 mp4   720x1280    30    │    4.99MiB  768k dash  │ avc1.4d401f    768k video only          720p, mp4_dash
22  mp4   720x1280    30  2 │ ~  6.02MiB  897k https │ avc1.64001F    897k mp4a.40.2    0k 44k 720p
247 webm  720x1280    30    │    5.15MiB  792k dash  │ vp9            792k video only          720p, webm_dash
398 mp4   720x1280    30    │    6.54MiB 1006k dash  │ av01.0.05M.08 1006k video only          720p, mp4_dash
137 mp4   1080x1920   30    │   18.66MiB 2870k dash  │ avc1.640028   2870k video only          1080p, mp4_dash
248 webm  1080x1920   30    │   11.30MiB 1738k dash  │ vp9           1738k video only          1080p, webm_dash
399 mp4   1080x1920   30    │   11.37MiB 1749k dash  │ av01.0.08M.08 1749k video only          1080p, mp4_dash

Enter format selector:
ERROR: Requested format is not available

Enter format selector:
ERROR: Requested format is not available

Enter format selector:
```



Discussion:
If you type in only

`yt-dlp https://www.youtube.com/watch?v=BMX-qv7lkB4` OR 
`yt-dlp BMX-qv7lkB4`

It will default to the best quality it can. For youtube, usually 248 webm video + 251 webm audio. You don't have to include the "-f" flag.


> The default format selector is bv*+ba/b. This means that if a combined video + audio format that is better than the best video-only format is found, the former will be preferred. Use -f bv+ba/b or --compat-options format-spec to revert this
EDIT: Updated the OP for necessary clarification after unrelated comment above.
I do agree with your feature request, which is why https://github.com/yt-dlp/yt-dlp/labels/triage was removed. The additional clarification wasn't needed 😃. The implementation should be trivial too.

> `Enter format selector (or press ENTER for default selection or STRG+C to quit):`

That is more annoying that useful though imo. Leaving it undocumented should be fine.

> * depends on [highlight+print default format (autoselection) to console when using -F or -Fv or -f- #2493](https://github.com/yt-dlp/yt-dlp/issues/2493) (indicate default selection with red asterisk)

Your request makes sense even without it
> I do agree with your feature request

thank you, I am very happy to hear that 😃

> > `Enter format selector (or press ENTER for default selection or STRG+C to quit):`
> 
> That is more annoying that useful though imo. Leaving it undocumented should be fine.

Ok, I just wanted all users to be able to benefit, not just me and those in the know ...

> > * depends on [highlight+print default format (autoselection) to console when using -F or -Fv or -f- #2493](https://github.com/yt-dlp/yt-dlp/issues/2493) (indicate default selection with red asterisk)
> 
> Your request makes sense even without it

Sure, but right now the user is not told what format will be selected when pressing just ENTER.
But once #2493 is implemented, the user sees the autoselected format.

Resolving patch:
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
--- a/yt_dlp/YoutubeDL.py
+++ b/yt_dlp/YoutubeDL.py
@@ -2724,21 +2724,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),


Test patch: