]> jfr.im git - yt-dlp.git/commitdiff
[extractor/youtube] Extract more format info
authorpukkandan <redacted>
Sun, 7 Aug 2022 20:06:11 +0000 (01:36 +0530)
committerpukkandan <redacted>
Sun, 7 Aug 2022 20:17:07 +0000 (01:47 +0530)
yt_dlp/extractor/youtube.py

index 1b4e47b5f92735112a093e8742f6d5d4a5c54f92..325aa0a2303e04c0b38d7a10087f772928fe3e5e 100644 (file)
@@ -2254,6 +2254,10 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
                 'tags': [],
                 'uploader_url': 'http://www.youtube.com/user/nao20010128nao',
             }
+        }, {
+            'note': '6 channel audio',
+            'url': 'https://www.youtube.com/watch?v=zgdo7-RRjgo',
+            'only_matching': True,
         }
     ]
 
@@ -3253,10 +3257,13 @@ def _extract_formats_and_subtitles(self, streaming_data, video_id, player_url, i
                     '%s%s' % (audio_track.get('displayName') or '',
                               ' (default)' if language_preference > 0 else ''),
                     fmt.get('qualityLabel') or quality.replace('audio_quality_', ''),
+                    try_get(fmt, lambda x: x['projectionType'].replace('RECTANGULAR', '').lower()),
+                    try_get(fmt, lambda x: x['spatialAudioType'].replace('SPATIAL_AUDIO_TYPE_', '').lower()),
                     throttled and 'THROTTLED', is_damaged and 'DAMAGED', delim=', '),
                 # Format 22 is likely to be damaged. See https://github.com/yt-dlp/yt-dlp/issues/3372
                 'source_preference': -10 if throttled else -5 if itag == '22' else -1,
                 'fps': int_or_none(fmt.get('fps')) or None,
+                'audio_channels': fmt.get('audioChannels'),
                 'height': height,
                 'quality': q(quality),
                 'has_drm': bool(fmt.get('drmFamilies')),
@@ -3577,7 +3584,7 @@ def feed_entry(name):
         formats.extend(self._extract_storyboard(player_responses, duration))
 
         # source_preference is lower for throttled/potentially damaged formats
-        self._sort_formats(formats, ('quality', 'res', 'fps', 'hdr:12', 'source', 'codec:vp9.2', 'lang', 'proto'))
+        self._sort_formats(formats, ('quality', 'res', 'fps', 'hdr:12', 'channels', 'source', 'codec:vp9.2', 'lang', 'proto'))
 
         info = {
             'id': video_id,