pytube: KeyError: 'cipher'

When I try to download “https://www.youtube.com/watch?v=SiAuAJBZuGs” - successful But “https://www.youtube.com/watch?v=wmQx_K9Gwrc” - KeyError: ‘cipher’

Traceback (most recent call last):
  File "C:\Users\mark\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytube\extract.py", line 297, in apply_descrambler
    for format_item in formats
  File "C:\Users\mark\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytube\extract.py", line 297, in <listcomp>
    for format_item in formats
KeyError: 'url'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:/Users/mark/Desktop/MP3/test.py", line 6, in <module>
    yt = YouTube('https://www.youtube.com/watch?v=FIbNPViilOU')
  File "C:\Users\mark\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytube\__main__.py", line 92, in __init__
    self.descramble()
  File "C:\Users\mark\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytube\__main__.py", line 132, in descramble
    apply_descrambler(self.player_config_args, fmt)
  File "C:\Users\mark\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytube\extract.py", line 301, in apply_descrambler
    parse_qs(formats[i]["cipher"]) for i, data in enumerate(formats)
  File "C:\Users\mark\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pytube\extract.py", line 301, in <listcomp>
    parse_qs(formats[i]["cipher"]) for i, data in enumerate(formats)
KeyError: 'cipher'
from pytube import YouTube
yt = YouTube('https://www.youtube.com/watch?v=FIbNPViilOU')

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 20

Commits related to this issue

Most upvoted comments

I have fixed this issue by changing a few lines in extract.py

cipher_url = [
                parse_qs(formats[i]["cipher"]) for i, data in enumerate(formats)
            ]
cipher_url = [
                parse_qs(formats[i]["signatureCipher"]) for i, data in enumerate(formats)
            ]

I have fixed this issue by changing a few lines in extract.py

cipher_url = [
                parse_qs(formats[i]["cipher"]) for i, data in enumerate(formats)
            ]
cipher_url = [
                parse_qs(formats[i]["signatureCipher"]) for i, data in enumerate(formats)
            ]

Thanks dude!