这是我每次尝试下载任何官方视频时都会遇到的错误,但使用某些在线下载应用程序时会下载相同的视频
KeyError Traceback (most recent call last)
~\anaconda3\lib\site-packages\pytube\extract.py in apply_descrambler(stream_data, key)
--> 297 for format_item in formats
~\anaconda3\lib\site-packages\pytube\extract.py in <listcomp>(.0)
296 }
--> 297 for format_item in formats
298 ]
KeyError: 'url'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
<ipython-input-1-796467b30bec> in <module>
7 import cv2
8
----> 9 video = YouTube('https://www.youtube.com/watch?v=tDq3fNew1rU')
~\anaconda3\lib\site-packages\pytube\__main__.py in __init__(self, url, defer_prefetch_init, on_progress_callback, on_complete_callback, proxies)
90 if not defer_prefetch_init:
91 self.prefetch()
---> 92 self.descramble()
94 def descramble(self) -> None:
~\anaconda3\lib\site-packages\pytube\__main__.py in descramble(self)
130 if not self.age_restricted and fmt in self.vid_info:
131 apply_descrambler(self.vid_info, fmt)
--> 132 apply_descrambler(self.player_config_args, fmt)
134 if not self.js:
~\anaconda3\lib\site-packages\pytube\extract.py in apply_descrambler(stream_data, key)
299 except KeyError:
300 cipher_url = [
--> 301 parse_qs(formats[i]["cipher"]) for i, data in enumerate(formats)
302 ]
303 stream_data[key] = [
~\anaconda3\lib\site-packages\pytube\extract.py in <listcomp>(.0)
299 except KeyError:
300 cipher_url = [
--> 301 parse_qs(formats[i]["cipher"]) for i, data in enumerate(formats)
302 ]
303 stream_data[key] = [
KeyError: 'cipher'
有人能帮我解决这个错误吗
这个文件是在一个问题中发布的(在PytubeGithub中),每次在主文件上导入它,然后
pytube.__main__.apply_descrambler = __pre__.apply_descrambler
在你的文件上使用那一行这会检测密码或密码签名,并进行一些必要的操作。。变化
我也有同样的问题。我通过以下方式解决了这个问题:
site-packages/pytub/extract.py
安装pytube
的地方李>parse_qs(formats[i]["cipher"]) for i, data in enumerate(formats)
["cipher"]
替换为["signatureCipher"]
资料来源here
相关问题 更多 >
编程相关推荐