From ebe03fc9af3a9969ee56b44b0e1abce8cbe7948b Mon Sep 17 00:00:00 2001 From: Luca Baffa Date: Sat, 6 Feb 2021 06:21:57 +0000 Subject: [PATCH 1/3] specialise override check for epub v3 --- main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index c960538..f445010 100644 --- a/main.py +++ b/main.py @@ -185,7 +185,10 @@ def add_metadata(self, container): # prevent overriding if prefs['force_override'] \ or not container.opf_xpath( - '//*[contains(@property, "{}")]'.format(value)): + ''' + //*[contains(@property, "{}") + and contains(text(), "{}")] + '''.format(value, text)): element = lxml.etree.Element('meta') element.set('property', ('schema:' + value)) From fe640b48f9897535c5901aa2689574540e86715f Mon Sep 17 00:00:00 2001 From: Luca Baffa Date: Sat, 6 Feb 2021 06:29:56 +0000 Subject: [PATCH 2/3] specialise override check for epub v2 --- main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index f445010..a228ef2 100644 --- a/main.py +++ b/main.py @@ -204,7 +204,10 @@ def add_metadata(self, container): # prevent overriding if prefs['force_override'] \ or not container.opf_xpath( - '//*[contains(@name, "{}")]'.format(value)): + ''' + //*[contains(@name, "{}") + and contains(@content, "{}")] + '''.format(value, text)): element = lxml.etree.Element('meta') element.set('name', ('schema:' + value)) From dd4b2ab54bd32478478da4697216a37b3c91effa Mon Sep 17 00:00:00 2001 From: Luca Baffa Date: Sat, 6 Feb 2021 07:33:55 +0000 Subject: [PATCH 3/3] make sure the file is an epub --- main.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.py b/main.py index a228ef2..a173dc5 100644 --- a/main.py +++ b/main.py @@ -47,6 +47,10 @@ def main(self): return error_dialog(self.gui, 'No book open', 'Need to have a book open first', show=True) + if container.book_type != 'epub': + raise Exception('Access Aide supports EPUB files only, {} given.' \ + .format(container.book_type)) + # get book main language try: lang = container.opf_xpath('//dc:language/text()')[0]