diff --git a/DeDRM_plugin/flatxml2html.py b/DeDRM_plugin/flatxml2html.py index 2fe80c3..9e80927 100644 --- a/DeDRM_plugin/flatxml2html.py +++ b/DeDRM_plugin/flatxml2html.py @@ -473,8 +473,12 @@ class DocParser(object): if (link > 0): linktype = self.link_type[link-1] title = self.link_title[link-1] - if (title == b"") or (parares.rfind(title.decode('utf-8')) < 0): - title=parares[lstart:].encode('utf-8') + if isinstance(title, bytes): + if (title == b"") or (parares.rfind(title.decode('utf-8')) < 0): + title=parares[lstart:].encode('utf-8') + else: + if (title == "") or (parares.rfind(title) < 0): + title=parares[lstart:] if linktype == 'external' : linkhref = self.link_href[link-1] linkhtml = '' % linkhref @@ -485,9 +489,15 @@ class DocParser(object): else : # just link to the current page linkhtml = '' - linkhtml += title.decode('utf-8') + if isinstance(title, bytes): + linkhtml += title.decode('utf-8') + else: + linkhtml += title linkhtml += '' - pos = parares.rfind(title.decode('utf-8')) + if isinstance(title, bytes): + pos = parares.rfind(title.decode('utf-8')) + else: + pos = parares.rfind(title) if pos >= 0: parares = parares[0:pos] + linkhtml + parares[pos+len(title):] else : diff --git a/DeDRM_plugin/topazextract.py b/DeDRM_plugin/topazextract.py index 5125d62..bdbf1eb 100644 --- a/DeDRM_plugin/topazextract.py +++ b/DeDRM_plugin/topazextract.py @@ -345,6 +345,8 @@ class TopazBook: for pid in pidlst: # use 8 digit pids here pid = pid[0:8] + if isinstance(pid, str): + pid = pid.encode('utf-8') print("Trying: {0}".format(pid)) bookKeys = [] data = keydata