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

Code before:
                formats.extend(fmts)
                self._merge_subtitles(subs, target=subtitles)
            else:
                formats.append({
                    'url': f"{video_format['url']}{video_response['fn']}?vkey={video_response['fvkey']}",
                    'width': video_response.get('vw'),
                    'height': video_response.get('vh'),
                    'ext': 'mp4',
                })

        return formats, subtitles

    def _extract_video_subtitles(self, api_response, subtitles_format):
        subtitles = {}
        for subtitle in api_response['sfl']['fi']:
            subtitles[subtitle['lang'].lower()] = [{
                'url': subtitle['url'],
                'ext': subtitles_format,
                'protocol': 'm3u8_native' if subtitles_format == 'vtt' else 'http'
            }]

        return subtitles

    def _real_extract(self, url):
        video_id = self._match_id(url)
        series_id = self._match_valid_url(url).group('series_id')
        webpage = self._download_webpage(url, video_id)

        formats, subtitles = [], {}
        for video_format, subtitle_format in (('mp4', 'srt'), ('hls', 'vtt')):
            api_response = self._get_video_api_response(url, video_id, series_id, subtitle_format, video_format)

            fmts, subs = self._extract_video_formats_and_subtitles(video_id, api_response)
            native_subtitles = self._extract_video_subtitles(api_response, subtitle_format)

            formats.extend(fmts)
            self._merge_subtitles(native_subtitles, target=subtitles)

        return {
            'id': video_id,
            'title': self._og_search_title(webpage),
            'description': self._og_search_description(webpage),
            'formats': formats,
            'subtitles': subtitles,
        }


class WeTvSeriesIE(WeTvBaseIE):
    _VALID_URL = WeTvBaseIE._VALID_URL_BASE + r'/(?P<series_id>\w+)(?:-[^?#]+)?'

    _TESTS = [{

Review comment (suggestion):
```suggestion
        video_id, series_id = self._match_valid_url(url).group('id', 'series_id')
```

Code after:

                formats.extend(fmts)
                self._merge_subtitles(subs, target=subtitles)
            else:
                formats.append({
                    'url': f'{video_format["url"]}{video_response["fn"]}?vkey={video_response["fvkey"]}',
                    'width': video_width,
                    'height': video_height,
                    'ext': 'mp4',
                })

        return formats, subtitles

    def _extract_video_subtitles(self, api_response, subtitles_format):
        subtitles = {}
        for subtitle in traverse_obj(api_response, ('sfl', 'fi')):
            subtitles.setdefault(subtitle['lang'].lower(), []).append({
                'url': subtitle['url'],
                'ext': subtitles_format,
                'protocol': 'm3u8_native' if determine_ext(subtitle['url']) == 'm3u8' else 'http',
            })

        return subtitles

    def _real_extract(self, url):
        video_id, series_id = self._match_valid_url(url).group('id', 'series_id')
        webpage = self._download_webpage(url, video_id)

        formats, subtitles = [], {}
        for video_format, subtitle_format, video_quality in (('mp4', 'srt', ''), ('hls', 'vtt', 'shd'), ('hls', 'vtt', 'fhd')):
            api_response = self._get_video_api_response(url, video_id, series_id, subtitle_format, video_format, video_quality)

            fmts, subs = self._extract_video_formats_and_subtitles(api_response, video_id, video_quality)
            native_subtitles = self._extract_video_subtitles(api_response, subtitle_format)

            formats.extend(fmts)
            self._merge_subtitles(subs, native_subtitles, target=subtitles)

        self._sort_formats(formats)
        webpage_metadata = self._get_webpage_metadata(webpage, video_id)

        return {
            'id': video_id,
            'title': (self._og_search_title(webpage)
                      or traverse_obj(webpage_metadata, ('coverInfo', 'description'))),
            'description': (self._og_search_description(webpage)
                            or traverse_obj(webpage_metadata, ('coverInfo', 'description'))),
            'formats': formats,
            'subtitles': subtitles,
            'thumbnail': self._og_search_thumbnail(webpage),
            'duration': int_or_none(traverse_obj(webpage_metadata, ('videoInfo', 'duration'))),