Skip to content

Commit

Permalink
[ie] Resolve language to ISO639-2 for ISM formats (yt-dlp#11359)
Browse files Browse the repository at this point in the history
Closes yt-dlp#11356
Authored by: bashonly
  • Loading branch information
bashonly authored Oct 26, 2024
1 parent 6abef74 commit 21cdcf0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion yt_dlp/extractor/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
FormatSorter,
GeoRestrictedError,
GeoUtils,
ISO639Utils,
LenientJSONDecoder,
Popen,
RegexNotFoundError,
Expand Down Expand Up @@ -3071,7 +3072,11 @@ def _parse_ism_formats_and_subtitles(self, ism_doc, ism_url, ism_id=None):
url_pattern = stream.attrib['Url']
stream_timescale = int_or_none(stream.get('TimeScale')) or timescale
stream_name = stream.get('Name')
stream_language = stream.get('Language', 'und')
# IsmFD expects ISO 639 Set 2 language codes (3-character length)
# See: https://github.com/yt-dlp/yt-dlp/issues/11356
stream_language = stream.get('Language') or 'und'
if len(stream_language) != 3:
stream_language = ISO639Utils.short2long(stream_language) or 'und'
for track in stream.findall('QualityLevel'):
KNOWN_TAGS = {'255': 'AACL', '65534': 'EC-3'}
fourcc = track.get('FourCC') or KNOWN_TAGS.get(track.get('AudioTag'))
Expand Down

0 comments on commit 21cdcf0

Please sign in to comment.