mirror of
https://github.com/flibusta-apps/books_downloader.git
synced 2025-12-06 15:05:37 +01:00
Fix problems
This commit is contained in:
@@ -2,16 +2,16 @@ exclude: 'docs|node_modules|migrations|.git|.tox'
|
|||||||
|
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/ambv/black
|
- repo: https://github.com/ambv/black
|
||||||
rev: 22.3.0
|
rev: 22.10.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
language_version: python3.9
|
language_version: python3.11
|
||||||
- repo: https://github.com/pycqa/isort
|
- repo: https://github.com/pycqa/isort
|
||||||
rev: 5.10.1
|
rev: 5.10.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: isort
|
- id: isort
|
||||||
- repo: https://github.com/csachs/pyproject-flake8
|
- repo: https://github.com/csachs/pyproject-flake8
|
||||||
rev: v0.0.1a3
|
rev: v6.0.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyproject-flake8
|
- id: pyproject-flake8
|
||||||
additional_dependencies: [
|
additional_dependencies: [
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class FLDownloader(BaseDownloader):
|
|||||||
|
|
||||||
return await self.get_filename()
|
return await self.get_filename()
|
||||||
|
|
||||||
@async_retry(httpx.ReadTimeout, times=5, delay=10)
|
@async_retry(NotSuccess, times=5, delay=10)
|
||||||
async def _download_from_source(
|
async def _download_from_source(
|
||||||
self, source_config: SourceConfig, file_type: Optional[str] = None
|
self, source_config: SourceConfig, file_type: Optional[str] = None
|
||||||
) -> tuple[httpx.AsyncClient, httpx.Response, bool]:
|
) -> tuple[httpx.AsyncClient, httpx.Response, bool]:
|
||||||
@@ -104,10 +104,14 @@ class FLDownloader(BaseDownloader):
|
|||||||
raise ReceivedHTML()
|
raise ReceivedHTML()
|
||||||
|
|
||||||
return client, response, "application/zip" in content_type
|
return client, response, "application/zip" in content_type
|
||||||
except (asyncio.CancelledError, NotSuccess, ReceivedHTML):
|
except (asyncio.CancelledError, httpx.HTTPError, NotSuccess, ReceivedHTML) as e:
|
||||||
await response.aclose()
|
await response.aclose()
|
||||||
await client.aclose()
|
await client.aclose()
|
||||||
raise
|
|
||||||
|
if isinstance(e, httpx.HTTPError):
|
||||||
|
raise NotSuccess(str(e))
|
||||||
|
else:
|
||||||
|
raise e
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def _close_other_done(
|
async def _close_other_done(
|
||||||
@@ -154,13 +158,7 @@ class FLDownloader(BaseDownloader):
|
|||||||
)
|
)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
except (
|
except *:
|
||||||
NotSuccess,
|
|
||||||
ReceivedHTML,
|
|
||||||
ConvertationError,
|
|
||||||
FileNotFoundError,
|
|
||||||
ValueError,
|
|
||||||
):
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
tasks_ = pending
|
tasks_ = pending
|
||||||
|
|||||||
Reference in New Issue
Block a user