Open hadi-qalani opened 1 month ago
Thank you for contributing to PyTube. Please remember to reference Contributing.md
Yeah, this is a recent error in the library. Been facing this as well. The cipher.py file and js code isn't being pushed because of certain error in the stream and regex parameters. The maintainers need to fix this or I need to get better and reading documentation.
@GuptajiRocks I don't think anybody maintains this project anymore. The people had to figure this out already. The last commit is from May 20 2023.
For me, the recent breakage results in this:
File "/home/wojtek/music/download/./download.py", line 9, in <module>
yt.streams.get_audio_only('webm').download()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'download
@Blayung well your error can be fixed if get audio only, change it from webm to an audio file. Maybe that would fix.
For the other part, you're true, the maintainers have stopped looking at this a long time ago, but recent pending PRs have corrected the code. So I am trying to apply the changes, if It works, I'll let you know
@GuptajiRocks Idk, webm used to work before.
@GuptajiRocks Actually, it turns out that the particular video I was trying to download there exceptionally didn't have a webm version (I don't know why). I had to use mp4 in that case. It works without changing anything in the pytube code though, so I don't think I actually experience the issue.
Well nice
@GuptajiRocks I don't think anybody maintains this project anymore. The people had to figure this out already. The last commit is from May 20 2023.
I have found a repository called pytube2, it has 0 stars so no one knows about it https://github.com/Josh-XT/pytube2 It is also on pip library so I think it is legit https://pypi.org/project/pytube2/ I have rapidly checked the code and it looks legit, the author has a good background story so I think is pretty safe to use even if is not from one of the originals pytube's authors
Update: I have just downloaded and used it, this version doesn't work too, I think there as been some changes by YouTube in the background, let's hope in some update from this new version, it looks still in developing, the last update was in march 2024
How about this one? https://github.com/JuanBindez/pytubefix
Thank you for the link. But if you see recent PRs, you can see the regex and bad request errors have been fixed. Now it's working fine.
How about this one? https://github.com/JuanBindez/pytubefix
This version works for me, I also have tested its implementation in python and it works the same as normal pytube, so no compatibility issues for my script
Expected Behavior: The video streams should be downloaded successfully without any errors. Actual Behavior: The following error is encountered:
Traceback (most recent call last):
File "path/to/your/script.py", line X, in <module>
YouTube('https://youtu.be/2lAe1cqCOXo').streams.first().download()
File "path/to/pytube/__main__.py", line 296, in streams
return StreamQuery(self.fmt_streams)
File "path/to/pytube/__main__.py", line 176, in fmt_streams
stream_manifest = extract.apply_descrambler(self.streaming_data)
File "path/to/pytube/__main__.py", line 160, in streaming_data
self.bypass_age_gate()
File "path/to/pytube/__main__.py", line 257, in bypass_age_gate
innertube_response = innertube.player(self.video_id)
File "path/to/pytube/innertube.py", line 448, in player
return self._call_api(endpoint, query, self.base_data)
File "path/to/pytube/innertube.py", line 390, in _call_api
response = request._execute_request(
File "path/to/pytube/request.py", line 37, in _execute_request
return urlopen(request, timeout=timeout) # nosec
File "/usr/lib/python3.12/urllib/request.py", line 215, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.12/urllib/request.py", line 521, in open
response = meth(req, response)
File "/usr/lib/python3.12/urllib/request.py", line 630, in http_response
response = self.parent.error(
File "/usr/lib/python3.12/urllib/request.py", line 559, in error
return self._call_chain(*args)
File "/usr/lib/python3.12/urllib/request.py", line 492, in _call_chain
result = func(*args)
File "/usr/lib/python3.12/urllib/request.py", line 639, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
Works fine for me.
hi every one Im using pytube to download a video from youtube but I encounter this issue:
The code: from pytube import YouTube
urll= "https://youtu.be/MAlSjtxy5ak?si=3Q80s_MU22qYChn8" url2='https://www.youtube.com/watch?v=y46hvE9JAXo' yt = YouTube(urll) st= yt.streams.filter(only_audio=True).all()
Traceback (most recent call last): File "F:\tbot\dwn.py", line 6, in
st= yt.streams.filter(only_audio=True).all()
File "E:\py\py installed\lib\site-packages\pytube__main.py", line 296, in streams
return StreamQuery(self.fmt_streams)
File "E:\py\py installed\lib\site-packages\pytube__main.py", line 176, in fmt_streams
stream_manifest = extract.apply_descrambler(self.streaming_data)
File "E:\py\py installed\lib\site-packages\pytube\main__.py", line 160, in streaming_data
self.bypass_age_gate()
File "E:\py\py installed\lib\site-packages\pytube\main__.py", line 257, in bypass_age_gate
innertube_response = innertube.player(self.video_id)
File "E:\py\py installed\lib\site-packages\pytube\innertube.py", line 448, in player
return self._call_api(endpoint, query, self.base_data)
File "E:\py\py installed\lib\site-packages\pytube\innertube.py", line 390, in _call_api
response = request._execute_request(
File "E:\py\py installed\lib\site-packages\pytube\request.py", line 37, in _execute_request
return urlopen(request, timeout=timeout) # nosec
File "E:\py\py installed\lib\urllib\request.py", line 216, in urlopen
return opener.open(url, data, timeout)
File "E:\py\py installed\lib\urllib\request.py", line 525, in open
response = meth(req, response)
File "E:\py\py installed\lib\urllib\request.py", line 634, in http_response
response = self.parent.error(
File "E:\py\py installed\lib\urllib\request.py", line 563, in error
return self._call_chain(args)
File "E:\py\py installed\lib\urllib\request.py", line 496, in _call_chain
result = func(args)
File "E:\py\py installed\lib\urllib\request.py", line 643, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request