From 7e374cee3e34449595c9214c2d4e145bb10c985b Mon Sep 17 00:00:00 2001 From: precondition <57645186+precondition@users.noreply.github.com> Date: Thu, 10 Aug 2023 11:09:49 +0200 Subject: [PATCH 1/2] Catch FileNotFoundError due to undownloaded ebooks --- Obok_plugin/action.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Obok_plugin/action.py b/Obok_plugin/action.py index e4ef377..af656ec 100644 --- a/Obok_plugin/action.py +++ b/Obok_plugin/action.py @@ -374,7 +374,11 @@ class InterfacePluginAction(InterfaceAction): result['success'] = False result['fileobj'] = None - zin = zipfile.ZipFile(book.filename, 'r') + try: + zin = zipfile.ZipFile(book.filename, 'r') + except FileNotFoundError: + print(_("File not found. Make sure that the ebook has been properly downloaded in the Kobo app. ("), book.filename, _(")")) + return result #print ('Kobo library filename: {0}'.format(book.filename)) for userkey in self.userkeys: print (_('Trying key: '), codecs.encode(userkey, 'hex')) From 413182b97b8c362bb1f6a42f2681a4427a8d67bb Mon Sep 17 00:00:00 2001 From: precondition <57645186+precondition@users.noreply.github.com> Date: Fri, 11 Aug 2023 17:48:42 +0200 Subject: [PATCH 2/2] Obok.py/action.py: invoke _() only once --- Obok_plugin/action.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Obok_plugin/action.py b/Obok_plugin/action.py index af656ec..36562af 100644 --- a/Obok_plugin/action.py +++ b/Obok_plugin/action.py @@ -377,7 +377,7 @@ class InterfacePluginAction(InterfaceAction): try: zin = zipfile.ZipFile(book.filename, 'r') except FileNotFoundError: - print(_("File not found. Make sure that the ebook has been properly downloaded in the Kobo app. ("), book.filename, _(")")) + print (_('{0} - File "{1}" not found. Make sure the eBook has been properly downloaded in the Kobo app.').format(PLUGIN_NAME, book.filename)) return result #print ('Kobo library filename: {0}'.format(book.filename)) for userkey in self.userkeys: