How to remove 'cipher' error from YouTube video downloader and download video in mp3 format?

前端 未结 1 1346
故里飘歌
故里飘歌 2020-12-22 09:08

I am trying to create a YouTube video downloader in python using pytube and tkinter. Most of the videos are getting downloaded fine but in some videos I am

相关标签:
1条回答
  • 2020-12-22 09:42

    The fix is pretty simple, it's there in the GitHub repo, but since this question came up here, this is how I fixed it. It's not due to the way your file works, it's a problem that happened because YouTube changed their search patterns or something from cipher to signatureCipher.

    • First, say pip install pytube3 in the terminal.

    • Second, go to the path - C:\Users\<user>\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\pytube. Keep in mind the path will vary so replace <user> with your Windows username and python37-32 with your Python version that you install pytube on.

    • Third, open extract.py from the above navigated directory and head onto line 301 or search for the line:

    cipher_url = [
        parse_qs(formats[i]["cipher"]) for i, data in enumerate(formats)
    ]
    
    • Now replace it with:
    cipher_url = [
         parse_qs(formats[i]["signatureCipher"]) for i, data in enumerate(formats)
    ]
    

    In case you damage this file while making changes to it, just say pip uninstall pytube3 and then install it again, and repeat. Keep in mind your imports will still be import pytube.

    0 讨论(0)
提交回复
热议问题