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

Code before:
    def _real_extract(self, url):
        display_id = self._match_id(url)

        # the website is oddly giving all request as 404 at first and then loaded with js
        webpage, _ = self._download_webpage_handle(url, display_id, expected_status=404)

        api_data = self._download_json(
            f'https://api.godresource.com/api/Streams/{display_id}', display_id)

        video_url = api_data['streamUrl']

        # TODO: better name?
        extraction_result = {}
        if determine_ext(video_url) == 'm3u8':
            formats, subtitles = self._extract_m3u8_formats_and_subtitles(
                api_data['streamUrl'], display_id)

            extraction_result = {
                'formats': formats,
                'subtitles': subtitles
            }
        elif determine_ext(video_url) == 'mp4':
            extraction_result = {
                'url': video_url,
                'ext': 'mp4'
            }

        return {
            'id': display_id,
            **extraction_result,
            **merge_dicts(traverse_obj(api_data, {
                'title': ('title', {str}),  # can be None in API
                'thumbnail': ('thumbnail', {url_or_none}),
                'view_count': ('views', {int}),
                'channel': ('channelName', {str}),
                'channel_id': 'channelId',
                'timestamp': ('streamDateCreated', {unified_timestamp}),
                'modified_timestamp': ('streamDataModified', {unified_timestamp})
            }), {
                # This title is not reliable (only give the site name)
                'title': self._html_extract_title(webpage),
            }),
        }


Review comment (refactor):
```suggestion
            extraction_result = {'formats': [{
                'url': video_url,
                'ext': 'mp4'
            }]}
```
is prefered

Code after:
    }]

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

        api_data = self._download_json(
            f'https://api.godresource.com/api/Streams/{display_id}', display_id)

        video_url = api_data['streamUrl']
        is_live = api_data.get('isLive') or False
        if (ext := determine_ext(video_url)) == 'm3u8':
            formats, subtitles = self._extract_m3u8_formats_and_subtitles(
                video_url, display_id, live=is_live)
        elif ext == 'mp4':
            formats, subtitles = [{
                'url': video_url,
                'ext': ext
            }], {}
        else:
            raise ExtractorError(f'Unexpected video format {ext}')

        return {
            'id': display_id,
            'formats': formats,
            'subtitles': subtitles,
            'title': '',
            'is_live': is_live,
            **traverse_obj(api_data, {
                'title': ('title', {str}),
                'thumbnail': ('thumbnail', {url_or_none}),
                'view_count': ('views', {int}),
                'channel': ('channelName', {str}),
                'channel_id': ('channelId', {str_or_none}),
                'timestamp': ('streamDateCreated', {unified_timestamp}),
                'modified_timestamp': ('streamDataModified', {unified_timestamp})
            })
        }