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

Code before:
        src_iframe = self._search_regex(r'\<iframe[^>]+src="([^"]+)"', webpage, 'src iframe')

        webpage_iframe = self._download_webpage(src_iframe.replace('player.php', 'config2.php'), video_id=video_id,
                                                headers={'Referer': src_iframe})

        sources = self._parse_json(self._search_regex(r'sources\:[^>](\[.*?\])', webpage_iframe, 'm3u8 source'),
                                   video_id=video_id, transform_source=js_to_json)

        formats = []

        for source in sources:
            file = source.get('file')
            if file and source.get('type') == 'm3u8':
                fmts, subs = self._extract_m3u8_formats_and_subtitles(urljoin('https://www.lightcast.com/embed/', file),
                                                                      video_id, 'mp4', fatal=False,
                                                                      headers={'Referer': src_iframe})
                formats.extend(fmts)
        self._sort_formats(formats)

        return {
            'id': video_id,
            'title': self._html_search_meta(['og:title', 'twitter:title'], webpage, fatal=True),
            'description': self._html_search_meta(['og:description', 'twitter:description'], webpage, fatal=True),
            'thumbnail': self._search_regex(r'image\:[^>]\"([^"]+)\"', webpage_iframe, 'thumbnail'),
            'formats': formats,
        }


Review comment (refactor):
```suggestion
        video_id = self._match_id(url)
        src_iframe = self._search_regex(
            r'\<iframe[^>]+src="([^"]+)"', self._download_webpage(url, video_id), 'src iframe')

        webpage_iframe = self._download_webpage(
            src_iframe.replace('player.php', 'config2.php'), video_id, headers={'Referer': src_iframe})

        sources = self._parse_json(self._search_regex(
            r'sources\:[^>](\[.*?\])', webpage_iframe, 'm3u8 source'), video_id, transform_source=js_to_json)

        formats, subtitles = [], {}
        for source in sources:
            file = source.get('file')
            if file and source.get('type') == 'm3u8':
                fmts, subs = self._extract_m3u8_formats_and_subtitles(
                    urljoin('https://www.lightcast.com/embed/', file),
                    video_id, 'mp4', fatal=False, headers={'Referer': src_iframe})
                formats.extend(fmts)
                subtitles = self._merge_subtitles(subtitles, subs)
        self._sort_formats(formats)
        
        return {
            'id': video_id,
            'title': self._html_search_meta(['og:title', 'twitter:title'], webpage),
            'description': self._html_search_meta(['og:description', 'twitter:description'], webpage),
            'thumbnail': self._search_regex(r'image\:[^>]\"([^"]+)\"', webpage_iframe, 'thumbnail'),
            'formats': formats,
            'subtitles': subtitles,
        }
```

Code after:
        webpage_iframe = self._download_webpage(
            src_iframe.replace('player.php', 'config2.php'), video_id, headers={'Referer': src_iframe})

        sources = self._parse_json(self._search_regex(
            r'sources\:\s*(\[.*?\])', webpage_iframe, 'm3u8 source'), video_id, transform_source=js_to_json)

        formats, subtitles = [], {}
        for source in sources:
            file = source.get('file')
            if file and source.get('type') == 'm3u8':
                fmts, subs = self._extract_m3u8_formats_and_subtitles(
                    urljoin('https://www.lightcast.com/embed/', file),
                    video_id, 'mp4', fatal=False, headers={'Referer': src_iframe})
                formats.extend(fmts)
                subtitles = self._merge_subtitles(subtitles, subs)
        self._sort_formats(formats)

        return {
            'id': video_id,
            'title': self._html_search_meta(['og:title', 'twitter:title'], webpage),
            'description': self._html_search_meta(['og:description', 'twitter:description'], webpage),
            'thumbnail': self._search_regex(r'image:\s*"([^"]+)', webpage_iframe, 'thumbnail'),
            'formats': formats,
            'subtitles': subtitles,
        }