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

Code before:
            'tags': list,
            'age_limit': 18,
            'display_id': 2569966,
            'upload_date': '20220131',
            'description': 'md5:b4fc879a58ae6c604f8f259155b7e3b9',
        }
    }, {
        # api/v6 v2
        'url': 'https://beeg.com/1941093077?t=911-1391',
        'only_matching': True,
    }, {
        # api/v6 v2 w/o t
        'url': 'https://beeg.com/1277207756',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)

        webpage = self._download_webpage(url, video_id)

        video = self._download_json(
            'https://store.externulls.com/facts/file/%s' % video_id,
            video_id, 'Downloading JSON for %s' % video_id)

        resources = video['file']['hls_resources'] if traverse_obj(video, ('file', 'hls_resources')) else video['fc_facts'][0]['hls_resources']

        formats = []
        for format_id, video_uri in resources.items():
            if not video_uri:
                continue
            height = self._search_regex(
                r'fl_cdn_(\d+)', format_id, 'height', default=None)
            if not height:
                continue
#                formats.extend(self._extract_m3u8_formats(
#                'https://video.beeg.com/' + video_uri, video_id, ext='m3u8', m3u8_id='hls'))
            formats.append({
                'url': 'https://video.beeg.com/' + video_uri,
                'format_id': 'hls',
                'height': int(height),
                'ext': 'mp4',
                'format': 'm3u8',
                'protocol': 'm3u8_native',
                'video_ext': 'mp4',
            })
        self._sort_formats(formats)

        title = traverse_obj(video, ('file', 'stuff', 'sf_name'))
        video_id = compat_str(video_id)
        display_id = traverse_obj(video, ('fc_facts', 0, 'id'))

Review comment (suggestion):
```suggestion
        resources = traverse_obj(video, ('file', 'hls_resources'), ('fc_facts', 0, 'hls_resources'))
```

Code after:
            'description': 'md5:b4fc879a58ae6c604f8f259155b7e3b9',
            'timestamp': 1643623200,
            'display_id': 2569965,
            'upload_date': '20220131',
        }
    }, {
        # api/v6 v2
        'url': 'https://beeg.com/1941093077?t=911-1391',
        'only_matching': True,
    }, {
        # api/v6 v2 w/o t
        'url': 'https://beeg.com/1277207756',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)

        webpage = self._download_webpage(url, video_id)

        video = self._download_json(
            'https://store.externulls.com/facts/file/%s' % video_id,
            video_id, 'Downloading JSON for %s' % video_id)

        fc_facts = video.get('fc_facts')
        first_fact = {}
        for fact in fc_facts:
            if not first_fact or try_get(fact, lambda x: x['id'] < first_fact['id']):
                first_fact = fact

        resources = traverse_obj(video, ('file', 'hls_resources')) or first_fact.get('hls_resources')

        formats = []
        for format_id, video_uri in resources.items():
            if not video_uri:
                continue
            height = int_or_none(self._search_regex(r'fl_cdn_(\d+)', format_id, 'height', default=None))
            current_formats = self._extract_m3u8_formats(f'https://video.beeg.com/{video_uri}', video_id, ext='mp4', m3u8_id=str(height))
            for f in current_formats:
                f['height'] = height
            formats.extend(current_formats)

        self._sort_formats(formats)

        return {
            'id': video_id,
            'display_id': first_fact.get('id'),
            'title': traverse_obj(video, ('file', 'stuff', 'sf_name')),
            'description': traverse_obj(video, ('file', 'stuff', 'sf_story')),
            'timestamp': unified_timestamp(first_fact.get('fc_created')),
            'duration': int_or_none(traverse_obj(video, ('file', 'fl_duration'))),