diff --git a/make_book.py b/make_book.py index d0783bb..3728741 100644 --- a/make_book.py +++ b/make_book.py @@ -162,9 +162,12 @@ class BEPUB: new_book.toc = self.origin_book.toc all_items = list(self.origin_book.get_items()) # we just translate tag p - all_p_length = sum( - [len(bs(i.content, "html.parser").findAll("p")) for i in all_items] - ) + all_p_length = 0 + for i in all_items: + if i.file_name.endswith(".xhtml"): + all_p_length += len(bs(i.content, "html.parser").findAll("p")) + else: + all_p_length += len(bs(i.content, "xml").findAll("p")) if IS_TEST: pbar = tqdm(total=TEST_NUM) else: diff --git a/requirements.txt b/requirements.txt index 3cca106..53a9d59 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,4 @@ openai requests ebooklib rich -tqdm +tqdm \ No newline at end of file