Repository: yt-dlp/yt-dlp
File: yt_dlp/YoutubeDL.py (Python)

Code before:
        if self.params.get('listsubtitles'):
            if 'automatic_captions' in info_dict:
                self.list_subtitles(
                    info_dict['id'], automatic_captions, 'automatic captions')
            self.list_subtitles(info_dict['id'], subtitles, 'subtitles')
        if self.params.get('listformats') or interactive_format_selection:
            self.list_formats(info_dict)
        if list_only:
            # Without this printing, -F --print-json will not work
            self.__forced_printings(info_dict)
            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 (press ENTER for default, or CTRL+C to quit): ', self.Styles.EMPHASIS))

                if req_format.strip() == '':
                    req_format = self._default_format_spec(info_dict, download=download)
                    self.write_debug('Nothing selected, using default format spec: %s' % req_format)
                try:
                    format_selector = self.build_format_selector(req_format)
                except SyntaxError as err:
                    self.report_error(err, tb=False, is_error=False)
                    continue

            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),
                'incomplete_formats': (
                    # All formats are video-only or
                    all(f.get('vcodec') != 'none' and f.get('acodec') == 'none' for f in formats)
                    # all formats are audio-only
                    or all(f.get('vcodec') == 'none' and f.get('acodec') != 'none' for f in formats)),
            }))
            if interactive_format_selection and not formats_to_download:
                self.report_error('Requested format is not available', tb=False, is_error=False)
                continue
            break

        if not formats_to_download:
            if not self.params.get('ignore_no_formats_error'):
                raise ExtractorError(
                    'Requested format is not available. Use --list-formats for a list of available formats',
                    expected=True, video_id=info_dict['id'], ie=info_dict['extractor'])

Review comment (bug):
We should always try and use a f-strings instead
```suggestion
                    self.write_debug(f'No format selected, using {req_format}')
```

Code after:
        if self.params.get('listsubtitles'):
            if 'automatic_captions' in info_dict:
                self.list_subtitles(
                    info_dict['id'], automatic_captions, 'automatic captions')
            self.list_subtitles(info_dict['id'], subtitles, 'subtitles')
        if self.params.get('listformats') or interactive_format_selection:
            self.list_formats(info_dict)
        if list_only:
            # Without this printing, -F --print-json will not work
            self.__forced_printings(info_dict)
            return info_dict

        format_selector = self.format_selector
        while True:
            if interactive_format_selection:
                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) 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),
                'incomplete_formats': (
                    # All formats are video-only or
                    all(f.get('vcodec') != 'none' and f.get('acodec') == 'none' for f in formats)
                    # all formats are audio-only
                    or all(f.get('vcodec') == 'none' and f.get('acodec') != 'none' for f in formats)),
            }))
            if interactive_format_selection and not formats_to_download:
                self.report_error('Requested format is not available', tb=False, is_error=False)
                continue
            break

        if not formats_to_download:
            if not self.params.get('ignore_no_formats_error'):
                raise ExtractorError(
                    'Requested format is not available. Use --list-formats for a list of available formats',
                    expected=True, video_id=info_dict['id'], ie=info_dict['extractor'])
            self.report_warning('Requested format is not available')
            # Process what we can, even without any available formats.
            formats_to_download = [{}]