Fix filename generation

This commit is contained in:
2022-01-09 16:15:59 +03:00
parent 5136994dd3
commit feaa3d03cb
3 changed files with 4 additions and 4 deletions

View File

@@ -49,7 +49,7 @@ class BookLibraryClient:
@classmethod
async def _make_request(cls, url) -> dict:
async with httpx.AsyncClient() as client:
async with httpx.AsyncClient(timeout=60) as client:
response = await client.get(url, headers=cls.auth_headers)
return response.json()

View File

@@ -44,7 +44,7 @@ class FLDownloader(BaseDownloader):
if self.book is None:
raise ValueError("Book is None!")
return get_filename(self.book, self.file_type)
return get_filename(self.book_id, self.book, self.file_type)
async def get_final_filename(self) -> str:
if self.need_zip:

View File

@@ -54,7 +54,7 @@ def get_short_name(author: BookAuthor) -> str:
return " ".join(name_parts)
def get_filename(book: Book, file_type: str) -> str:
def get_filename(book_id: int, book: Book, file_type: str) -> str:
filename_parts = []
if book.authors:
@@ -86,6 +86,6 @@ def get_filename(book: Book, file_type: str) -> str:
):
filename = filename.replace(c, r)
right_part = f".{book.id}.{file_type}"
right_part = f".{book_id}.{file_type}"
return filename[: 64 - len(right_part)] + right_part