From 9f24d437cb21d667d346d98a38dc8d5fe9cd0be9 Mon Sep 17 00:00:00 2001 From: TheOnlyWayUp Date: Sun, 30 Jun 2024 20:09:07 +0000 Subject: [PATCH] fix(frontend): Arabic language support --- src/api/src/create_book.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/src/create_book.py b/src/api/src/create_book.py index bc6c23c..468468e 100644 --- a/src/api/src/create_book.py +++ b/src/api/src/create_book.py @@ -174,7 +174,7 @@ async def add_chapters( ): chapters = [] - for part in data["parts"]: + for cidx, part in enumerate(data["parts"]): content = await fetch_part_content(part["id"], cookies=cookies) title = part["title"] clean_title = slugify(title) @@ -182,7 +182,7 @@ async def add_chapters( # Thanks https://eu17.proxysite.com/process.php?d=5VyWYcoQl%2BVF0BYOuOavtvjOloFUZz2BJ%2Fepiusk6Nz7PV%2B9i8rs7cFviGftrBNll%2B0a3qO7UiDkTt4qwCa0fDES&b=1 chapter = epub.EpubHtml( title=title, - file_name=f"{clean_title}.xhtml", + file_name=f"{cidx}.xhtml", # Used to be clean_title.xhtml, but that broke Arabic support as slugify turns arabic strings into '', leading to multiple files with the same name, breaking those chapters. lang=data["language"]["name"], ) @@ -200,11 +200,11 @@ async def add_chapters( img = epub.EpubImage( media_type="image/jpeg", content=await response.read(), - file_name=f"static/{clean_title}/{idx}.jpeg", + file_name=f"static/{cidx}/{idx}.jpeg", ) book.add_item(img) content = content.replace( - str(image), f'' + str(image), f'' ) chapter.set_content(f"

{title}

" + content)