pip install pytube # python2
pip3 install pytube # python3
pip install pytube3 # if not work with pytube.
-
Clone the repository:
git clone https://github.com/ForestCrazy/Python-Download-Youtube-Video.git
-
cd into directory into your command prompt:
cd Python-Download-Youtube-Video
-
Run the download_video.py file:
python download_video.py --url "url_youtube_video"
-
If you want to download the playlist then run the download_playlist.py:
python download_playlist.py --url "url_youtube_playlist"
Traceback (most recent call last):
File "C:\Python36-64\lib\site-packages\pytube\extract.py", line 297, in apply_descrambler
for format_item in formats
File "C:\Python36-64\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 "download_video.py", line 10, in <module>
youtube = YouTube(args.url)
File "C:\Python36-64\lib\site-packages\pytube\__main__.py", line 92, in __init__
self.descramble()
File "C:\Python36-64\lib\site-packages\pytube\__main__.py", line 132, in descramble
apply_descrambler(self.player_config_args, fmt)
File "C:\Python36-64\lib\site-packages\pytube\extract.py", line 301, in apply_descrambler
parse_qs(formats[i]["cipher"]) for i, data in enumerate(formats)
File "C:\Python36-64\lib\site-packages\pytube\extract.py", line 301, in <listcomp>
parse_qs(formats[i]["cipher"]) for i, data in enumerate(formats)
KeyError: 'cipher'
-
Go to the location where the package was installed. If you don't know where, run the command
pip show pytube3
And it'll give you something like this:
We can seeLocation: c:\python36-64\lib\site-packages
-
Go to that location, open the folder pytube and the file extract.py
-
In the file, line no. 306 or 301, you will find
parse_qs(formats[i]["cipher"])
. If yes, then change"cipher"
to"signatureCipher"
So, you'll initially have
cipher_url = [
parse_qs(formats[i]["cipher"]) for i, data in enumerate(formats)
]
but it should be
cipher_url = [
parse_qs(formats[i]["signatureCipher"]) for i, data in enumerate(formats)
]