pytube: KeyError: 'streamingData'
I was trying to download https://www.youtube.com/watch?v=NdA778dQrXE
And this always raises KeyError: ‘streamingData’ error.
>>> YouTube("https://www.youtube.com/watch?v=NdA778dQrXE")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pytube\__main__.py", line 92, in __init__
self.descramble()
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pytube\__main__.py", line 132, in descramble
apply_descrambler(self.player_config_args, fmt)
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pytube\extract.py", line 281, in apply_descrambler
formats = json.loads(stream_data["player_response"])["streamingData"]["formats"]
KeyError: 'streamingData'
List of some videos raises the same error.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 5
- Comments: 73
If you install both pytube3 and pytube with pip, certain files get overwritten in unintended ways. This is especially true because the pypi packages haven’t been updated in several months.
You should be able to fix this problem if you do the following:
pip uninstall pytube
pip uninstall pytube3
python -m pip install git+https://github.com/nficano/pytube
This should uninstall the conflicting versions of pytube, and install the most recent code from this repository.
First locate pytube library location
Click on “innertube.py” and edit the code on line 78 replacing client=‘ANDROID’ with client=‘WEB’
It worked pretty well for me but the problem is downloading video or audio is slow
Apparently the view I’m trying to download is age restricted
https://www.youtube.com/watch?v=v4HkASndEXo
The error is not intuitive.
Same issue here, error appears to occur with age restricted videos…
why is this closed? It is still not working
I finally got a solution for this KeyError: ‘Streaming Data’. This error arises if you are trying to download videos that require a sign in / login for example Age Restricted videos require sign in or login. I tried to keep an exception for Age Restricted from pytube.exceptions but the error still persists because the statement for exception didn’t actually run for some reason. Actually this is not even an error but a bug.
Solution I included several exception in below example i am trying to download the Youtube 8m dataset.
This made me download those videos without problem. Kindly try even if my solution looks silly.
Same issue here. There’s a way to make it work, but much slower: https://github.com/pytube/pytube/issues/743#issuecomment-1528453973 (I tried it and it’s working)
I solved the problem in linux as follows:
Wait…
Change the line:
for
line 78
Only change the client from Android to WEB, probably the problem only occurs for android due to an update.Hello,
Got it from https://github.com/pytube/pytube/commit/d6623d8ce39c777f22a5638307c9fceedc01b047 I am using a virtual env and a VM with Linux and it just worked for me 😃
Apparently, everyone started getting that error. Me as well, I just switched to yt-dlp (https://github.com/yt-dlp/yt-dlp) and it works perfectly now
The package was working fine, but suddenly stopped working.
My situation is using pytube 12.1.3, and downloading a public vedio got such error, the root cause is playability_status method return an array with 1 element in it: None, so we need to change the lib line 213, adding the condition of None:
Same issue here : windows 11 pytube 12.1.3 python 3.10
Thanks for this. This fixed the issue! by changing the innertube.py from ANDROID to WEB it seems to go much slower. Is their any fix for that?
Thanks a ton!
Shouldn’t close it that fast. March 2022, and the problem is still there. version 12