From 6fa81497d539a99fda2636126df3e485179a4edd Mon Sep 17 00:00:00 2001 From: MaxwellGoblin Date: Thu, 20 Jul 2017 17:14:05 +0800 Subject: [PATCH] [youtube]use mp4_audio track when no audio track for webm --- src/you_get/extractors/youtube.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/you_get/extractors/youtube.py b/src/you_get/extractors/youtube.py index 986906d6..3b412dc2 100644 --- a/src/you_get/extractors/youtube.py +++ b/src/you_get/extractors/youtube.py @@ -366,14 +366,22 @@ class YouTube(VideoExtractor): dash_url += '&signature={}'.format(sig) dash_size = stream['clen'] itag = stream['itag'] + audio_url = None + audio_size = None + try: + audio_url = dash_webm_a_url + audio_size = int(dash_webm_a_size) + except UnboundLocalError as e: + audio_url = dash_mp4_a_url + audio_size = int(dash_mp4_a_size) self.dash_streams[itag] = { 'quality': stream['size'], 'itag': itag, 'type': mimeType, 'mime': mimeType, 'container': 'webm', - 'src': [dash_url, dash_webm_a_url], - 'size': int(dash_size) + int(dash_webm_a_size) + 'src': [dash_url, audio_url], + 'size': int(dash_size) + int(audio_size) } def extract(self, **kwargs):