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

Code before:
                        'format_id': f'{format_id}-{quality}',
                        'url': format_url,
                        'ext': determine_ext(format_url, 'mp4'),
                        'height': get_height(quality),
                        'filesize': format_sizes.get(quality),
                        'http_headers': {
                            'Referer': urlh.url,
                        },
                    })
            xplayer_sources = try_get(
                initials, lambda x: x['xplayerSettings']['sources'], dict)
            if xplayer_sources:
                hls_sources = xplayer_sources.get('hls')
                if isinstance(hls_sources, dict):
                    if 'url' in hls_sources or 'fallback' in hls_sources:
                        for hls_format_key in ('url', 'fallback'):
                            hls_url = hls_sources.get(hls_format_key)
                            if not hls_url:
                                continue
                            hls_url = self._decipher_format_url(hls_url, f'hls-{hls_format_key}')
                            if not hls_url or hls_url in format_urls:
                                continue
                            format_urls.add(hls_url)
                            formats.extend(self._extract_m3u8_formats(
                                hls_url, video_id, 'mp4', entry_protocol='m3u8_native',
                                m3u8_id='hls', fatal=False))
                standard_sources = xplayer_sources.get('standard')
                if isinstance(standard_sources, dict):
                    for identifier, formats_list in standard_sources.items():
                        if not isinstance(formats_list, list):
                            continue
                        for standard_format in formats_list:
                            if not isinstance(standard_format, dict):
                                continue
                            for standard_format_key in ('url', 'fallback'):
                                standard_url = standard_format.get(standard_format_key)
                                if not standard_url:
                                    continue
                                quality = (str_or_none(standard_format.get('quality'))
                                           or str_or_none(standard_format.get('label'))
                                           or '')
                                format_id = join_nonempty(identifier, quality)
                                standard_url = self._decipher_format_url(standard_url, format_id)
                                if not standard_url or standard_url in format_urls:
                                    continue
                                format_urls.add(standard_url)
                                ext = determine_ext(standard_url, 'mp4')
                                if ext == 'm3u8':
                                    formats.extend(self._extract_m3u8_formats(
                                        standard_url, video_id, 'mp4', entry_protocol='m3u8_native',
                                        m3u8_id='hls', fatal=False))

Review comment (refactor):
Reindentation to match above:
```suggestion
       for 
           hls_url = self._decipher_format_url(hls_url, f'hls-{hls_format_key}')
           if not hls_url or hls_url in format_urls:
               continue
           format_urls.add(hls_url)
           formats.extend(self._extract_m3u8_formats(
               hls_url, video_id, 'mp4', entry_protocol='m3u8_native',
               m3u8_id='hls', fatal=False))
```
Then a minimal change below to match, and reindent the suite (-3 x 4-space):
```diff
-                standard_sources = xplayer_sources.get('standard')
-                if isinstance(standard_sources, dict):
-                    for identifier, formats_list in standard_sources.items():
+       for identifier, formats_list in traverse_obj(initials, (
+               'xplayerSettings', 'sources', 'standard', {dict.items},
+               lambda _, k_v: k_v[1].insert)):
-                        if not isinstance(formats_list, list):
-                            continue
```
But the `standard` sources also need to be unscrambled. You can make up a fancy traversal expression that handles both branches of the `xplayerSettings` and also the preload `playlist_url`, and even the `videoModel` sources that are probably no longer sent.

Code after:
                        hls_url = hls_sources.get(hls_format_key)
                        if not hls_url:
                            continue
                        hls_url = self._decipher_format_url(hls_url, f'hls-{hls_format_key}')
                        if not hls_url or hls_url in format_urls:
                            continue
                        format_urls.add(hls_url)
                        formats.extend(self._extract_m3u8_formats(
                            hls_url, video_id, 'mp4', entry_protocol='m3u8_native',
                            m3u8_id='hls', fatal=False))
                standard_sources = xplayer_sources.get('standard')
                if isinstance(standard_sources, dict):
                    for identifier, formats_list in standard_sources.items():
                        if not isinstance(formats_list, list):
                            continue
                        for standard_format in formats_list:
                            if not isinstance(standard_format, dict):
                                continue
                            for standard_format_key in ('url', 'fallback'):
                                standard_url = standard_format.get(standard_format_key)
                                if not standard_url:
                                    continue
                                quality = (str_or_none(standard_format.get('quality'))
                                           or str_or_none(standard_format.get('label'))
                                           or '')
                                format_id = join_nonempty(identifier, quality)
                                standard_url = self._decipher_format_url(standard_url, format_id)
                                if not standard_url or standard_url in format_urls:
                                    continue
                                format_urls.add(standard_url)
                                ext = determine_ext(standard_url, 'mp4')
                                if ext == 'm3u8':
                                    formats.extend(self._extract_m3u8_formats(
                                        standard_url, video_id, 'mp4', entry_protocol='m3u8_native',
                                        m3u8_id='hls', fatal=False))
                                    continue

                                formats.append({
                                    'format_id': format_id,
                                    'url': standard_url,
                                    'ext': ext,
                                    'height': get_height(quality),
                                    'filesize': format_sizes.get(quality),
                                    'http_headers': {
                                        'Referer': standard_url,
                                    },
                                })

            categories_list = video.get('categories')
            if isinstance(categories_list, list):
                categories = []