diff --git a/cps/epub.py b/cps/epub.py index 61a9d85c..c22bad7b 100644 --- a/cps/epub.py +++ b/cps/epub.py @@ -47,11 +47,9 @@ def get_epub_layout(book, book_data): 'n': 'urn:oasis:names:tc:opendocument:xmlns:container', 'pkg': 'http://www.idpf.org/2007/opf', } - file_path = os.path.normpath(os.path.join(config.config_calibre_dir, book.path, book_data.name + "." + book_data.format.lower())) epubZip = zipfile.ZipFile(file_path) - txt = epubZip.read('META-INF/container.xml') tree = etree.fromstring(txt) cfname = tree.xpath('n:rootfiles/n:rootfile/@full-path', namespaces=ns)[0] diff --git a/cps/kobo.py b/cps/kobo.py index 5cbc1844..de5d3235 100644 --- a/cps/kobo.py +++ b/cps/kobo.py @@ -21,6 +21,7 @@ import base64 import datetime import os import uuid +import zipfile from time import gmtime, strftime import json from urllib.parse import unquote @@ -460,18 +461,21 @@ def get_metadata(book): continue for kobo_format in KOBO_FORMATS[book_data.format]: # log.debug('Id: %s, Format: %s' % (book.id, kobo_format)) - if get_epub_layout(book, book_data) == 'pre-paginated': - kobo_format = 'EPUB3FL' - download_urls.append( - { - "Format": kobo_format, - "Size": book_data.uncompressed_size, - "Url": get_download_url_for_book(book, book_data.format), - # The Kobo forma accepts platforms: (Generic, Android) - "Platform": "Generic", - # "DrmType": "None", # Not required - } - ) + try: + if get_epub_layout(book, book_data) == 'pre-paginated': + kobo_format = 'EPUB3FL' + download_urls.append( + { + "Format": kobo_format, + "Size": book_data.uncompressed_size, + "Url": get_download_url_for_book(book, book_data.format), + # The Kobo forma accepts platforms: (Generic, Android) + "Platform": "Generic", + # "DrmType": "None", # Not required + } + ) + except (zipfile.BadZipfile, FileNotFoundError) as e: + log.error(e) book_uuid = book.uuid metadata = { diff --git a/test/Calibre-Web TestSummary_Linux.html b/test/Calibre-Web TestSummary_Linux.html index 0daf4ca3..e4d0ca4e 100644 --- a/test/Calibre-Web TestSummary_Linux.html +++ b/test/Calibre-Web TestSummary_Linux.html @@ -37,20 +37,20 @@
Start Time: 2023-02-21 20:53:24
+Start Time: 2023-02-26 18:55:48
Stop Time: 2023-02-22 03:08:32
+Stop Time: 2023-02-27 01:05:54
Duration: 5h 18 min
+Duration: 5h 13 min
Traceback (most recent call last): - File "/home/ozzie/Development/calibre-web-test/test/test_edit_books.py", line 948, in test_upload_book_epub - self.assertEqual('book9', details['title']) -AssertionError: 'book9' != 'book' -- book9 -? - -+ book-
Traceback (most recent call last): - File "/home/ozzie/Development/calibre-web-test/test/test_edit_books_metadata.py", line 84, in test_load_metadata - elif 'https://amazon.com/' == results[20]['source']: -IndexError: list index out of range-
Traceback (most recent call last): - File "/home/ozzie/Development/calibre-web-test/test/test_edit_ebooks_gdrive.py", line 185, in test_edit_title - self.assertEqual('The camicdemo', books[1][8]['title']) -IndexError: list index out of range+ File "/home/ozzie/Development/calibre-web-test/test/test_edit_ebooks_gdrive.py", line 230, in test_edit_title + self.assertEqual(ele.text, u'Very long extra super turbo cool title without any issue of displaying including ö utf-8 characters') +AttributeError: 'bool' object has no attribute 'text'
Traceback (most recent call last): - File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync.py", line 270, in test_sync_upload - self.assertEqual(['Noname 23'], data[0]['NewEntitlement']['BookMetadata']['Contributors']) -AssertionError: Lists differ: ['Noname 23'] != ['Unknown'] - -First differing element 0: -'Noname 23' -'Unknown' - -- ['Noname 23'] -+ ['Unknown']-
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync_big.py", line 477, in test_download_cover + books = self.inital_sync() + File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync_big.py", line 122, in inital_sync + self.assertEqual(r.status_code, 200) +AssertionError: 500 != 200+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync_big.py", line 352, in test_kobo_sync_multi_user + self.inital_sync(user1_kobo) + File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync_big.py", line 122, in inital_sync + self.assertEqual(r.status_code, 200) +AssertionError: 500 != 200+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync_big.py", line 270, in test_kobo_sync_selected_shelves + self.inital_sync() + File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync_big.py", line 122, in inital_sync + self.assertEqual(r.status_code, 200) +AssertionError: 500 != 200+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync_big.py", line 172, in test_sync_changed_book + self.inital_sync() + File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync_big.py", line 122, in inital_sync + self.assertEqual(r.status_code, 200) +AssertionError: 500 != 200+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync_big.py", line 247, in test_sync_reading_state + self.inital_sync() + File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync_big.py", line 122, in inital_sync + self.assertEqual(r.status_code, 200) +AssertionError: 500 != 200+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync_big.py", line 203, in test_sync_shelf + self.inital_sync() + File "/home/ozzie/Development/calibre-web-test/test/test_kobo_sync_big.py", line 122, in inital_sync + self.assertEqual(r.status_code, 200) +AssertionError: 500 != 200+
Traceback (most recent call last): - File "/home/ozzie/Development/calibre-web-test/test/test_reader.py", line 182, in test_comic_reader - self.assertTrue(content) -AssertionError: False is not true-
Traceback (most recent call last): - File "/home/ozzie/Development/calibre-web-test/test/test_reader.py", line 67, in test_txt_reader - self.assertTrue('hörte' in content.text, 'Encoding of textfile viewer is not respected properly') -AssertionError: False is not true : Encoding of textfile viewer is not respected properly-
Traceback (most recent call last): - File "/home/ozzie/Development/calibre-web-test/test/test_thumbnails.py", line 187, in test_cache_of_deleted_book - self.assertEqual(book_thumbnail_reference, 2) -AssertionError: 0 != 2-
Traceback (most recent call last): - File "/home/ozzie/Development/calibre-web-test/test/test_thumbnails.py", line 135, in test_cover_change_on_upload_new_cover - self.assertGreaterEqual(diff(BytesIO(updated_cover), BytesIO(original_cover), delete_diff_file=True), 0.03) -AssertionError: 0.02977373520222651 not greater than or equal to 0.03-
Traceback (most recent call last): - File "/home/ozzie/Development/calibre-web-test/test/test_thumbnails.py", line 247, in test_cover_on_upload_book - self.assertEqual(book_thumbnail_reference+2, count_files(thumbnail_cache_path)) -AssertionError: 222 != 220-
Traceback (most recent call last): - File "/home/ozzie/Development/calibre-web-test/test/test_thumbnails.py", line 320, in test_sideloaded_book - self.assertGreaterEqual(diff(BytesIO(list_cover), BytesIO(new_list_cover), delete_diff_file=True), 0.04) -AssertionError: 0.0 not greater than or equal to 0.04-
Traceback (most recent call last): - File "/home/ozzie/Development/calibre-web-test/test/test_upload_epubs.py", line 136, in test_upload_epub_cover - self.assertAlmostEqual(diff(BytesIO(original), BytesIO(cover_image), delete_diff_file=True), 0.0, delta=0.0001) -AssertionError: 0.04598719156221104 != 0.0 within 0.0001 delta (0.04598719156221104 difference)-
Traceback (most recent call last): - File "/home/ozzie/Development/calibre-web-test/test/test_upload_epubs.py", line 205, in test_upload_epub_cover_formats - self.assertAlmostEqual(diff(BytesIO(original), BytesIO(cover_image), delete_diff_file=True), 0.0058, -AssertionError: 0.051106144230518215 != 0.0058 within 0.0001 delta (0.045306144230518215 difference)-