A feature-rich command-line audio/video downloader
Infer `acodec` for single-codec containers
pukkandan86a972033e05
diff --git a/test/test_YoutubeDL.py b/test/test_YoutubeDL.pyindex 6be47af97f..5242cf88f9 100644--- a/test/test_YoutubeDL.py+++ b/test/test_YoutubeDL.py@@ -183,7 +183,7 @@ class TestFormatSelection(unittest.TestCase):]info_dict = _make_result(formats)- ydl = YDL({'format': 'best'})+ ydl = YDL({'format': 'best', 'format_sort': ['abr', 'ext']})ydl.sort_formats(info_dict)ydl.process_ie_result(copy.deepcopy(info_dict))downloaded = ydl.downloaded_info_dicts[0]@@ -195,7 +195,7 @@ class TestFormatSelection(unittest.TestCase):downloaded = ydl.downloaded_info_dicts[0]self.assertEqual(downloaded['format_id'], 'mp3-64')- ydl = YDL({'prefer_free_formats': True})+ ydl = YDL({'prefer_free_formats': True, 'format_sort': ['abr', 'ext']})ydl.sort_formats(info_dict)ydl.process_ie_result(copy.deepcopy(info_dict))downloaded = ydl.downloaded_info_dicts[0]diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.pyindex e3d1db3761..5636676001 100644--- a/yt_dlp/YoutubeDL.py+++ b/yt_dlp/YoutubeDL.py@@ -2813,6 +2813,9 @@ class YoutubeDL:format['url'] = sanitize_url(format['url'])if format.get('ext') is None:format['ext'] = determine_ext(format['url']).lower()+ if format['ext'] in ('aac', 'opus', 'mp3', 'flac', 'vorbis'):+ if format.get('acodec') is None:+ format['acodec'] = format['ext']if format.get('protocol') is None:format['protocol'] = determine_protocol(format)if format.get('resolution') is None: