From 2c8891a2b508d54bc58ad3fe27bd180dec3819e7 Mon Sep 17 00:00:00 2001 From: wustho Date: Tue, 22 Sep 2020 15:14:18 +0700 Subject: Fixed toc entry with missing or empty index location. --- epy.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'epy.py') diff --git a/epy.py b/epy.py index afdca4e..f92161a 100755 --- a/epy.py +++ b/epy.py @@ -209,7 +209,10 @@ class Epub: src = i.get("href") name = "".join(list(i.itertext())) src = src.split("#") - idx = contents.index(unquote(src[0])) + try: + idx = contents.index(unquote(src[0])) + except ValueError: + continue self.toc_entries[0].append(name) self.toc_entries[1].append(idx) if len(src) == 2: @@ -302,7 +305,10 @@ class Mobi(Epub): src = i.get("href") name = "".join(list(i.itertext())) src = src.split("#") - idx = contents.index(unquote(src[0])) + try: + idx = contents.index(unquote(src[0])) + except ValueError: + continue self.toc_entries[0].append(name) self.toc_entries[1].append(idx) if len(src) == 2: -- cgit