1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-08-21 10:51:27 +00:00

[ie/svt] Extract forced subs under separate lang code (#14062)

Closes #14020
Authored by: PierreMesure
This commit is contained in:
Pierre 2025-08-19 23:57:46 +01:00 committed by GitHub
parent 7540aa1da1
commit 82a1390204
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -88,7 +88,7 @@ class SVTBaseIE(InfoExtractor):
'id': video_id,
'title': title,
'formats': formats,
'subtitles': subtitles,
'subtitles': self._fixup_subtitles(subtitles),
'duration': duration,
'timestamp': timestamp,
'age_limit': age_limit,
@ -99,6 +99,16 @@ class SVTBaseIE(InfoExtractor):
'is_live': is_live,
}
@staticmethod
def _fixup_subtitles(subtitles):
# See: https://github.com/yt-dlp/yt-dlp/issues/14020
fixed_subtitles = {}
for lang, subs in subtitles.items():
for sub in subs:
fixed_lang = f'{lang}-forced' if 'text-open' in sub['url'] else lang
fixed_subtitles.setdefault(fixed_lang, []).append(sub)
return fixed_subtitles
class SVTPlayIE(SVTBaseIE):
IE_NAME = 'svt:play'
@ -115,6 +125,26 @@ class SVTPlayIE(SVTBaseIE):
)
'''
_TESTS = [{
'url': 'https://www.svtplay.se/video/eXYgwZb/sverige-och-kriget/1-utbrottet',
'md5': '2382036fd6f8c994856c323fe51c426e',
'info_dict': {
'id': 'ePBvGRq',
'ext': 'mp4',
'title': '1. Utbrottet',
'description': 'md5:02291cc3159dbc9aa95d564e77a8a92b',
'series': 'Sverige och kriget',
'episode': '1. Utbrottet',
'timestamp': 1746921600,
'upload_date': '20250511',
'duration': 3585,
'thumbnail': r're:^https?://(?:.*[\.-]jpg|www.svtstatic.se/image/.*)$',
'age_limit': 0,
'subtitles': {'sv': 'count:3', 'sv-forced': 'count:3'},
},
'params': {
'skip_download': 'm3u8',
},
}, {
'url': 'https://www.svtplay.se/video/30479064',
'md5': '2382036fd6f8c994856c323fe51c426e',
'info_dict': {