From c81cfb58dbf9fc8c61be25e3fa1d07cf22914316 Mon Sep 17 00:00:00 2001 From: TOCK Chiu Date: Wed, 3 Jun 2020 00:26:18 +0800 Subject: [PATCH] [youtube] fix `KeyError: 'url'` on some videos --- src/you_get/extractors/youtube.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/you_get/extractors/youtube.py b/src/you_get/extractors/youtube.py index 38aa1a4e..f8630b8c 100644 --- a/src/you_get/extractors/youtube.py +++ b/src/you_get/extractors/youtube.py @@ -335,9 +335,9 @@ class YouTube(VideoExtractor): 'mime': stream['mimeType'].split(';')[0], 'container': mime_to_container(stream['mimeType'].split(';')[0]), } - if 'cipher' in stream: + if 'signatureCipher' in stream: self.streams[stream_itag].update(dict([(_.split('=')[0], parse.unquote(_.split('=')[1])) - for _ in stream['cipher'].split('&')])) + for _ in stream['signatureCipher'].split('&')])) # Prepare caption tracks try: @@ -481,10 +481,10 @@ class YouTube(VideoExtractor): del stream['contentLength'] del stream['initRange'] del stream['indexRange'] - if 'cipher' in stream: + if 'signatureCipher' in stream: stream.update(dict([(_.split('=')[0], parse.unquote(_.split('=')[1])) - for _ in stream['cipher'].split('&')])) - del stream['cipher'] + for _ in stream['signatureCipher'].split('&')])) + del stream['signatureCipher'] for stream in streams: # get over speed limiting stream['url'] += '&ratebypass=yes'