Skip to content

Commit

Permalink
Fix epub name special characters
Browse files Browse the repository at this point in the history
  • Loading branch information
quantrancse committed Aug 17, 2021
1 parent 9e02817 commit 1341163
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions hako2epub.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ class EpubEngine():
def __init__(self):
self.ln_info_json_file = 'ln_info.json'

def format_name(self, name):
return name.replace(' ', '-').replace('?', '').replace('!', '')

def make_cover_image(self):
try:
print('Making cover image...')
Expand Down Expand Up @@ -354,11 +357,11 @@ def bind_epub_book(self):
self.book.add_item(epub.EpubNcx())
self.book.add_item(epub.EpubNav())

epub_name = self.volume.name + '-' + self.ln.name + '.epub'
epub_name = epub_name.replace(' ', '-')
epub_name = self.format_name(
self.volume.name + '-' + self.ln.name + '.epub')
self.set_metadata(epub_name, self.ln.author)

epub_folder = self.ln.name.replace(' ', '-').replace('?', '').replace('!', '')
epub_folder = self.format_name(self.ln.name)
if not isdir(epub_folder):
mkdir(epub_folder)

Expand All @@ -379,9 +382,8 @@ def create_epub(self, ln):
self.save_json(ln)

def update_epub(self, ln, volume):
epub_name = volume.name + '-' + ln.name + '.epub'
epub_name = epub_name.replace(' ', '-')
epub_folder = ln.name.replace(' ', '-').replace('?', '').replace('!', '')
epub_name = self.format_name(volume.name + '-' + ln.name + '.epub')
epub_folder = self.format_name(ln.name)
epub_path = epub_folder + '/' + epub_name

try:
Expand Down

0 comments on commit 1341163

Please sign in to comment.