mirror of
https://github.com/yihong0618/bilingual_book_maker.git
synced 2025-06-06 11:35:49 +00:00
fix: fix the issue with the progress bar not updating properly (#85)
* feat: parse xhtml based epub by detect automatically * fix: fix the issue with the progress bar not updating properly * refactor: refactor on logic --------- Co-authored-by: yihong0618 <zouzou0208@gmail.com>
This commit is contained in:
parent
e9066d063b
commit
4184566ed5
@ -178,7 +178,6 @@ class BEPUB:
|
||||
p_to_save_len = len(self.p_to_save)
|
||||
try:
|
||||
for item in self.origin_book.get_items():
|
||||
pbar.update(index)
|
||||
if item.get_type() == ITEM_DOCUMENT:
|
||||
soup = bs(item.content, "html.parser")
|
||||
p_list = soup.findAll("p")
|
||||
@ -198,6 +197,8 @@ class BEPUB:
|
||||
index += 1
|
||||
if index % 50 == 0:
|
||||
self._save_progress()
|
||||
# pbar.update(delta) not pbar.update(index)?
|
||||
pbar.update(1)
|
||||
if IS_TEST and index > TEST_NUM:
|
||||
break
|
||||
item.content = soup.prettify().encode()
|
||||
@ -230,7 +231,11 @@ class BEPUB:
|
||||
try:
|
||||
for item in self.origin_book.get_items():
|
||||
if item.get_type() == ITEM_DOCUMENT:
|
||||
soup = bs(item.content, "html.parser")
|
||||
soup = (
|
||||
bs(item.content, "xml")
|
||||
if item.file_name.endswith(".xhtml")
|
||||
else bs(item.content, "html.parser")
|
||||
)
|
||||
p_list = soup.findAll("p")
|
||||
for p in p_list:
|
||||
if not p.text or self._is_special_text(p.text):
|
||||
|
Loading…
x
Reference in New Issue
Block a user