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

Code before:
        if new_url == urllib.parse.urlparse(url)._replace(scheme='https').geturl():
            url = new_url
        elif url != new_url:
            self.report_following_redirect(new_url)
            if force_videoid:
                new_url = smuggle_url(new_url, {'force_videoid': force_videoid})
            return self.url_result(new_url)

        info_dict = {
            'id': video_id,
            'title': self._generic_title(url),
            'timestamp': unified_timestamp(full_response.headers.get('Last-Modified'))
        }

        # Check for direct link to a video
        content_type = full_response.headers.get('Content-Type', '').lower()
        m = re.match(r'^(?P<type>audio|video|application(?=/(?:ogg$|(?:vnd\.apple\.|x-)?mpegurl)))/(?P<format_id>[^;\s]+)', content_type)
        if m:
            self.report_detected('direct video link')
            headers = smuggled_data.get('http_headers', {})
            format_id = str(m.group('format_id'))
            subtitles = {}
            if format_id.endswith('mpegurl'):
                formats, subtitles = self._extract_m3u8_formats_and_subtitles(url, video_id, 'mp4', headers=headers)
                if self._hls_segment_query(url):
                    info_dict.update(self._hls_segment_query(url))
            elif format_id.endswith('mpd') or format_id.endswith('dash+xml'):
                formats, subtitles = self._extract_mpd_formats_and_subtitles(url, video_id, headers=headers)
            elif format_id == 'f4m':
                formats = self._extract_f4m_formats(url, video_id, headers=headers)
            else:
                formats = [{
                    'format_id': format_id,
                    'url': url,
                    'vcodec': 'none' if m.group('type') == 'audio' else None
                }]
                info_dict['direct'] = True
            info_dict.update({
                'formats': formats,
                'subtitles': subtitles,
                'http_headers': headers,
            })
            return info_dict

        if not self.get_param('test', False) and not is_intentional:
            force = self.get_param('force_generic_extractor', False)
            self.report_warning('%s generic information extractor' % ('Forcing' if force else 'Falling back on'))

        first_bytes = full_response.read(512)

        # Is it an M3U playlist?

Review comment (suggestion):
```suggestion
                info_dict.update(self._hls_segment_query(url))
```
same everywhere

Code after:
        elif url != new_url:
            self.report_following_redirect(new_url)
            if force_videoid:
                new_url = smuggle_url(new_url, {'force_videoid': force_videoid})
            return self.url_result(new_url)

        info_dict = {
            'id': video_id,
            'title': self._generic_title(url),
            'timestamp': unified_timestamp(full_response.headers.get('Last-Modified'))
        }

        # Check for direct link to a video
        content_type = full_response.headers.get('Content-Type', '').lower()
        m = re.match(r'^(?P<type>audio|video|application(?=/(?:ogg$|(?:vnd\.apple\.|x-)?mpegurl)))/(?P<format_id>[^;\s]+)', content_type)
        if m:
            self.report_detected('direct video link')
            headers = smuggled_data.get('http_headers', {})
            format_id = str(m.group('format_id'))
            subtitles = {}
            if format_id.endswith('mpegurl'):
                formats, subtitles = self._extract_m3u8_formats_and_subtitles(url, video_id, 'mp4', headers=headers)
                info_dict.update(self._fragment_query(url))
            elif format_id.endswith('mpd') or format_id.endswith('dash+xml'):
                formats, subtitles = self._extract_mpd_formats_and_subtitles(url, video_id, headers=headers)
                info_dict.update(self._fragment_query(url))
            elif format_id == 'f4m':
                formats = self._extract_f4m_formats(url, video_id, headers=headers)
            else:
                formats = [{
                    'format_id': format_id,
                    'url': url,
                    'vcodec': 'none' if m.group('type') == 'audio' else None
                }]
                info_dict['direct'] = True
            info_dict.update({
                'formats': formats,
                'subtitles': subtitles,
                'http_headers': headers,
            })
            return info_dict

        if not self.get_param('test', False) and not is_intentional:
            force = self.get_param('force_generic_extractor', False)
            self.report_warning('%s generic information extractor' % ('Forcing' if force else 'Falling back on'))

        first_bytes = full_response.read(512)

        # Is it an M3U playlist?
        if first_bytes.startswith(b'#EXTM3U'):
            self.report_detected('M3U playlist')