From e52dea51f4c952f3884bf21ba62eb3f422bdf827 Mon Sep 17 00:00:00 2001 From: dkoekden Date: Wed, 17 Jul 2024 11:58:46 +0200 Subject: [PATCH] implement changes for sinusbot --- test/test_InfoExtractor.py | 6 +++--- yt_dlp/extractor/common.py | 1 + yt_dlp/extractor/youtube.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/test/test_InfoExtractor.py b/test/test_InfoExtractor.py index 31e8f82448d4..d325f2e31866 100644 --- a/test/test_InfoExtractor.py +++ b/test/test_InfoExtractor.py @@ -899,7 +899,7 @@ def test_parse_m3u8_formats(self): 'acodec': 'mp4a.40.2', 'audio_ext': 'mp4', 'video_ext': 'none', - 'abr': 41.457, + 'abr': 41, }, { 'format_id': '263', 'format_index': None, @@ -1260,7 +1260,7 @@ def test_parse_mpd_formats(self): 'format_id': 'audio=128001', 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd', 'ext': 'm4a', - 'tbr': 128.001, + 'tbr': 128, 'asr': 48000, 'format_note': 'DASH audio', 'container': 'm4a_dash', @@ -1271,7 +1271,7 @@ def test_parse_mpd_formats(self): 'protocol': 'http_dash_segments', 'audio_ext': 'm4a', 'video_ext': 'none', - 'abr': 128.001, + 'abr': 128, }, { 'format_id': 'video=100000', 'manifest_url': 'https://sdn-global-streaming-cache-3qsdn.akamaized.net/stream/3144/files/17/07/672975/3144-kZT4LWMQw6Rh7Kpd.ism/manifest.mpd', diff --git a/yt_dlp/extractor/common.py b/yt_dlp/extractor/common.py index f63bd782586b..bb8bde426fac 100644 --- a/yt_dlp/extractor/common.py +++ b/yt_dlp/extractor/common.py @@ -2239,6 +2239,7 @@ def build_stream_name(): if mobj: abr, vbr = mobj.groups() abr, vbr = float_or_none(abr, 1000), float_or_none(vbr, 1000) + abr = int(abr) f.update({ 'vbr': vbr, 'abr': abr, diff --git a/yt_dlp/extractor/youtube.py b/yt_dlp/extractor/youtube.py index 53aca3816be8..5512c0b93a9c 100644 --- a/yt_dlp/extractor/youtube.py +++ b/yt_dlp/extractor/youtube.py @@ -3916,7 +3916,7 @@ def build_fragments(f): video_id=video_id, only_once=True) continue - tbr = float_or_none(fmt.get('averageBitrate') or fmt.get('bitrate'), 1000) + tbr = int_or_none(fmt.get('averageBitrate') or fmt.get('bitrate'), 1000) format_duration = traverse_obj(fmt, ('approxDurationMs', {lambda x: float_or_none(x, 1000)})) # Some formats may have much smaller duration than others (possibly damaged during encoding) # E.g. 2-nOtRESiUc Ref: https://github.com/yt-dlp/yt-dlp/issues/2823