Pytube: KeyError: 'cipher'

Created on 29 May 2020  路  20Comments  路  Source: pytube/pytube

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')

Most helpful comment

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)
            ]

All 20 comments

Dupe of #641.

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)
            ]

Thank you vms123. This fix worked for me.

Thank you vrns123

Dear vrns123, thank you!

Thanks vrns123 for the fix / workaround

I m using colab
where i can find extract.py file in colab for change LOC for cipher

thanks bro

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!

Thanks for the fix!

Can anyone let me know what's the issue here. BTW, the fix worked for me..Thanks!

Thanks a lot for the fix.I love you!

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)
            ]

Yes it's Working

I m using colab
where i can find extract.py file in colab for change LOC for cipher

same pls help

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)
            ]

This worked for me Thank You馃

I m using colab
where i can find extract.py file in colab for change LOC for cipher

same pls help

You can use left sidebar of colab and from there goto /usr/local/lib/python3.6/dist-packages/pytube/extraxt.py

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)
            ]

Thank you dude.

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 a lot

It is throwing NameError : formats name 'formats' is not defined.. What to do now?

All,

Believe this is fixed in most recent version of Pytube
Let me know if this still doesnt work -- thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stdedos picture stdedos  路  24Comments

ajayrandhawa picture ajayrandhawa  路  20Comments

Winedays picture Winedays  路  31Comments

sk1122 picture sk1122  路  18Comments

JMIdeaMaker picture JMIdeaMaker  路  20Comments