-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when downloading from servers that doesn't support Head requests #15
Comments
this is caused because the head request failed. pypdl first sends a head request to get metadata and to ensure the file exist or not apparently the link you provided doesn't implement the head request support or they don't allow it this cause the head request that pypdl send to fail giving you the error. its quite an easy fix we just need to add code to send a get request if head request fails this will fix the issue. thanks for reporting this was a bug that i didn't anticipate. Edit: with v1.3.2 this should be fixed. also the server you are trying to download from seems to have issue with multi segment download |
I can confirm that it's working smoothly now with v1.3.2. Thanks a lot! |
@mjishnu - this seems to have regressed with the move to AIOHttp. The first HEAD request raises an exception because the default |
@deepdelirious thanks for reporting it's kind of weird, the URL i was testing on return 302 instead of 404 or 405 so i was not getting this error, i am working on 1.6 so in that i will fix it. in the mean time just add a try except around the _get_header in your local machine async def _get_header(self, url):
try:
async with aiohttp.ClientSession() as session:
async with session.head(url, **self._kwargs) as response:
if response.status == 200:
self.logger.debug("Header acquired from head request")
return response.headers
except Exception:
pass
async with session.get(url, **self._kwargs) as response:
if response.status == 200:
self.logger.debug("Header acquired from get request")
return response.headers
raise Exception(
f"Failed to get header (Status: {response.status}, Reason: {response.reason})"
) this should fix it |
i have fixed this in the latest version you can check it out at https://test.pypi.org/project/pypdl/ |
I'm getting errors when trying to download some CSV files, even though there are no problems in the URL (tested via browser).
Is this something I'm doing wrong? Any tips on how to debug this?
Code:
Result:
ERROR:root:(ConnectionError) [Server Returned: Forbidden(403), Invalid URL]
The text was updated successfully, but these errors were encountered: