[BUG] Video class doesn't work - 400 Bad Request
Closed this issue ยท 21 comments
If I try and use anything in from extras.py I just get this
File "D:\Program Files\Python39\lib\site-packages\youtubesearchpython\internal\extras.py", line 42, in __makeRequest
response = urlopen(request)
File "D:\Program Files\Python39\lib\urllib\request.py", line 214, in urlopen
return opener.open(url, data, timeout)
File "D:\Program Files\Python39\lib\urllib\request.py", line 523, in open
response = meth(req, response)
File "D:\Program Files\Python39\lib\urllib\request.py", line 632, in http_response
response = self.parent.error(
File "D:\Program Files\Python39\lib\urllib\request.py", line 561, in error
return self._call_chain(*args)
File "D:\Program Files\Python39\lib\urllib\request.py", line 494, in _call_chain
result = func(*args)
File "D:\Program Files\Python39\lib\urllib\request.py", line 641, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\Alucard\Desktop\ytalbumdl-source\test.py", line 4, in <module>
print(Video.getInfo('https://www.youtube.com/watch?v=SCHpzvmw_PU'))
File "D:\Program Files\Python39\lib\site-packages\youtubesearchpython\extras.py", line 337, in getInfo
return Video(videoLink, "getInfo", mode).result
File "D:\Program Files\Python39\lib\site-packages\youtubesearchpython\internal\extras.py", line 11, in __init__
statusCode = self.__makeRequest(self.__getVideoId(videoLink))
File "D:\Program Files\Python39\lib\site-packages\youtubesearchpython\internal\extras.py", line 46, in __makeRequest
raise Exception('ERROR: Could not make request.')
Exception: ERROR: Could not make request.```
I tried to use Video.getInfo for this example but the same happens with everything from extras
Started getting this today too, it seems if you attempt it multiple times it will sometimes work and sometimes not. My guess is youtube attempting to prevent downloading.
I'm guessing that too, since it does it with older versions as well
so basically youtube-search-python is broken until further notice?
so basically youtube-search-python is broken until further notice?
So far it only seems like this error happens when using Video.get() not VideoSearch() so that second one should work
is there any alternate way of getting a title from a url or the id?
Not that I've seen, my solution would be to just attempt the download over and over on error since it seems to work some of the time
not working for me I ran it over 500 times and none of them succeeded, so that sucks
If I try and use anything in from extras.py I just get this
File "D:\Program Files\Python39\lib\site-packages\youtubesearchpython\internal\extras.py", line 42, in __makeRequest response = urlopen(request) File "D:\Program Files\Python39\lib\urllib\request.py", line 214, in urlopen return opener.open(url, data, timeout) File "D:\Program Files\Python39\lib\urllib\request.py", line 523, in open response = meth(req, response) File "D:\Program Files\Python39\lib\urllib\request.py", line 632, in http_response response = self.parent.error( File "D:\Program Files\Python39\lib\urllib\request.py", line 561, in error return self._call_chain(*args) File "D:\Program Files\Python39\lib\urllib\request.py", line 494, in _call_chain result = func(*args) File "D:\Program Files\Python39\lib\urllib\request.py", line 641, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 400: Bad Request During handling of the above exception, another exception occurred: Traceback (most recent call last): File "c:\Users\Alucard\Desktop\ytalbumdl-source\test.py", line 4, in <module> print(Video.getInfo('https://www.youtube.com/watch?v=SCHpzvmw_PU')) File "D:\Program Files\Python39\lib\site-packages\youtubesearchpython\extras.py", line 337, in getInfo return Video(videoLink, "getInfo", mode).result File "D:\Program Files\Python39\lib\site-packages\youtubesearchpython\internal\extras.py", line 11, in __init__ statusCode = self.__makeRequest(self.__getVideoId(videoLink)) File "D:\Program Files\Python39\lib\site-packages\youtubesearchpython\internal\extras.py", line 46, in __makeRequest raise Exception('ERROR: Could not make request.') Exception: ERROR: Could not make request.```
Hello!
YouTube is currently changing a lot of things on its API. I have fixed StreamURLFetcher a while ago, and back then everything worked.
Let me have a look
After further investigation, I have found that only one class is reproducing this error, and that is Video class - others aren't. I will see what I can do
After further investigation, I have found that only one class is reproducing this error, and that is Video class - others aren't. I will see what I can do
I also had this exact same issue with the Playlist class
YouTube is messing around again.
Patch for Video class: #111
Now, I didn't notice any error in Playlist class. Just FYI, this class was recently patched, and fix hasn't landed to PyPI yet. This is why you are having this error. You can install latest version from here: pip install git+https://github.com/alexmercerind/youtube-search-python
Closing, since error doesn't occour anymore. If it does, then comment here.
I am having this same issue but with playlists
Traceback (most recent call last):
File "C:\Users\arcti\AppData\Local\Programs\Python\Python36\lib\site-packages\youtubesearchpython\internal\extras.py", line 162, in __makeRequest
response = urlopen(request, timeout=self.timeout)
File "C:\Users\arcti\AppData\Local\Programs\Python\Python36\lib\urllib\request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "C:\Users\arcti\AppData\Local\Programs\Python\Python36\lib\urllib\request.py", line 532, in open
response = meth(req, response)
File "C:\Users\arcti\AppData\Local\Programs\Python\Python36\lib\urllib\request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Users\arcti\AppData\Local\Programs\Python\Python36\lib\urllib\request.py", line 570, in error
return self._call_chain(*args)
File "C:\Users\arcti\AppData\Local\Programs\Python\Python36\lib\urllib\request.py", line 504, in _call_chain
result = func(*args)
File "C:\Users\arcti\AppData\Local\Programs\Python\Python36\lib\urllib\request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "video.pyw", line 62, in <module>
playlist = Playlist(link1)
File "C:\Users\arcti\AppData\Local\Programs\Python\Python36\lib\site-packages\youtubesearchpython\extras.py", line 548, in __init__
self.__playlist = PlaylistInternal(playlistLink, None, ResultMode.dict, self.timeout)
File "C:\Users\arcti\AppData\Local\Programs\Python\Python36\lib\site-packages\youtubesearchpython\internal\extras.py", line 136, in __init__
statusCode = self.__makeRequest(playlistLink)
File "C:\Users\arcti\AppData\Local\Programs\Python\Python36\lib\site-packages\youtubesearchpython\internal\extras.py", line 166, in __makeRequest
raise Exception('ERROR: Could not make request.')
Exception: ERROR: Could not make request.
As i said, fix hasnt landed to PyPI yet. You have to get latest version from git: pip install git+https://github.com/alexmercerind/youtube-search-python
I have tested everything in the morning, and it worked ok.
Please test latest release from git first.
Awesome, that worked! Very much appreciated
same fix is needed for the __future__
subpackage
same fix is needed for the
__future__
subpackage
One of next things from me is going to be a rewrite of synchronous and asynchronous packages (as part of #104), to extract core, so that everything should be easier to maintain. This is probably gonna happen next week. No breaking changes at the API, just easier maintaining. I will do it then, but if you want it ASAP you can always create a PR.
Thanks
same fix is needed for the
__future__
subpackageOne of next things from me is going to be a rewrite of synchronous and asynchronous packages (as part of #104), to extract core, so that everything should be easier to maintain. This is probably gonna happen next week. No breaking changes at the API, just easier maintaining. I will do it then, but if you want it ASAP you can always create a PR.
Thanks
Thanks a lot <3
I have started with rewrite, and have extracted the core of this package. Now, asynchronous & synchronous functions in extras.py share code between themselves. So, __future__
subpackage is now fully working. This fix hasn't yet landed on main repository, since I have to make some improvements, so for now you can install my fork: pip install git+https://github.com/mytja/youtube-search-python