Pytube was working just fine earlier and then, while I was downloading a few videos, it crashed somewhere among the middle, and it hasn't functioned on a single video since, including videos I have successfully downloaded in the past. This applies both to python code, and the command line interface. It crashes on any "YouTube([link])".
The error is the following (always the same):
C:\Users\Robly\talos>pytube v=0XpgchQnaUY --list
Traceback (most recent call last):
File "c:\code\python3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\code\python3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Code\Python3\Scripts\pytube.exe\__main__.py", line 9, in <module>
File "c:\code\python3\lib\site-packages\pytube\cli.py", line 58, in main
display_streams(args.url)
File "c:\code\python3\lib\site-packages\pytube\cli.py", line 182, in display_streams
yt = YouTube(url)
File "c:\code\python3\lib\site-packages\pytube\__main__.py", line 81, in __init__
self.prefetch_init()
File "c:\code\python3\lib\site-packages\pytube\__main__.py", line 90, in prefetch_init
self.init()
File "c:\code\python3\lib\site-packages\pytube\__main__.py", line 117, in init
mixins.apply_descrambler(self.vid_info, fmt)
File "c:\code\python3\lib\site-packages\pytube\mixins.py", line 76, in apply_descrambler
for i in stream_data[key].split(',')
KeyError: 'url_encoded_fmt_stream_map'
Well, I should have tried harder. Upon reinstalling (and apparently my version of pytube was outdated, on version 7.0.18, not sure if that has anything to do with) it started working out of the blue again.
I'm not familliar with GitHub issue etiquette, and I don't know if this might be an actual bug that should be fixed rather than worked around, so I'll leave the post up.
I have the same problem with you.
My code worked on earlier version of pytube now (on both windows and linux) gives error
Traceback (most recent call last):
File "<ipython-input-2-af95eab380ae>", line 1, in <module>
runfile('/home/charalampos/Desktop/downloaderFINAL.py', wdir='/home/charalampos/Desktop')
File "/usr/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py", line 710, in runfile
execfile(filename, namespace)
File "/usr/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py", line 101, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "/home/charalampos/Desktop/downloaderFINAL.py", line 6, in <module>
song = YouTube(input("螘蟺喂魏慰位位萎蟽蟿蔚 蔚未蠋 蟿慰 link 蟿慰蠀 蟿蟻伪纬慰蠀未喂慰蠉: \n ---> "))
File "/usr/lib/python3.6/site-packages/pytube/__main__.py", line 81, in __init__
self.prefetch_init()
File "/usr/lib/python3.6/site-packages/pytube/__main__.py", line 90, in prefetch_init
self.init()
File "/usr/lib/python3.6/site-packages/pytube/__main__.py", line 117, in init
mixins.apply_descrambler(self.vid_info, fmt)
File "/usr/lib/python3.6/site-packages/pytube/mixins.py", line 76, in apply_descrambler
for i in stream_data[key].split(',')
KeyError: 'url_encoded_fmt_stream_map'
I will try reinstalling pytube...
Ok. So the problem is witth pytube 7.0.18. Installing the latest version 8.0.X solved the problem
Still receiving this in pytube 9.0.6
File "...", line 42, in get_audio
yt = YouTube(url)
File "/usr/local/lib/python3.6/dist-packages/pytube/__main__.py", line 83, in __init__
self.prefetch_init()
File "/usr/local/lib/python3.6/dist-packages/pytube/__main__.py", line 92, in prefetch_init
self.init()
File "/usr/local/lib/python3.6/dist-packages/pytube/__main__.py", line 124, in init
mixins.apply_descrambler(self.player_config_args, fmt)
File "/usr/local/lib/python3.6/dist-packages/pytube/mixins.py", line 76, in apply_descrambler
for i in stream_data[key].split(',')
KeyError: 'url_encoded_fmt_stream_map'
Still receiving this in pytube '9.1.0'
File "...", line 26, in download_local
yt = YouTube("https://www.youtube.com/watch?v=" + id )
File "/usr/local/lib/python3.6/site-packages/pytube/__main__.py", line 84, in __init__
self.prefetch_init()
File "/usr/local/lib/python3.6/site-packages/pytube/__main__.py", line 93, in prefetch_init
self.init()
File "/usr/local/lib/python3.6/site-packages/pytube/__main__.py", line 125, in init
mixins.apply_descrambler(self.player_config_args, fmt)
File "/usr/local/lib/python3.6/site-packages/pytube/mixins.py", line 81, in apply_descrambler
for i in stream_data[key].split(',')
KeyError: 'url_encoded_fmt_stream_map'
Still receiving this on pytube 9.5.3
File "/home/feelthebern/anaconda3/lib/python3.7/site-packages/pytube/mixins.py", line 96, in apply_descrambler
for i in stream_data[key].split(',')
KeyError: 'url_encoded_fmt_stream_map'
Most helpful comment
Ok. So the problem is witth pytube 7.0.18. Installing the latest version 8.0.X solved the problem