diff --git a/main.py b/main.py index c960538..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] @@ -185,7 +189,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)) @@ -201,7 +208,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))