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

@@ -936,11 +936,11 @@ - + TestEditBooks 36 - 34 - 1 + 35 + 0 0 1 @@ -1228,34 +1228,11 @@ - +
TestEditBooks - test_upload_book_epub
- -
- FAIL -
- - - - + PASS @@ -1630,13 +1607,13 @@ AssertionError: 'book9' != 'book' - + TestLoadMetadata 1 - 0 - 0 1 0 + 0 + 0 Detail @@ -1644,31 +1621,11 @@ AssertionError: 'book9' != 'book' - +
TestLoadMetadata - test_load_metadata
- -
- ERROR -
- - - - + PASS @@ -1840,9 +1797,9 @@ 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'
@@ -2197,11 +2154,11 @@ IndexError: list index out of range - + TestKoboSync 11 - 10 - 1 + 11 + 0 0 0 @@ -2301,48 +2258,21 @@ IndexError: list index out of range - +
TestKoboSync - test_sync_upload
- -
- FAIL -
- - - - + PASS - + TestKoboSyncBig 6 - 6 0 + 6 0 0 @@ -2352,56 +2282,188 @@ First differing element 0: - +
TestKoboSyncBig - test_download_cover
- PASS + +
+ FAIL +
+ + + + - +
TestKoboSyncBig - test_kobo_sync_multi_user
- PASS + +
+ FAIL +
+ + + + - +
TestKoboSyncBig - test_kobo_sync_selected_shelves
- PASS + +
+ FAIL +
+ + + + - +
TestKoboSyncBig - test_sync_changed_book
- PASS + +
+ FAIL +
+ + + + - +
TestKoboSyncBig - test_sync_reading_state
- PASS + +
+ FAIL +
+ + + + - +
TestKoboSyncBig - test_sync_shelf
- PASS + +
+ FAIL +
+ + + + @@ -3270,11 +3332,11 @@ First differing element 0: - + TestReader 5 - 3 - 2 + 5 + 0 0 0 @@ -3284,31 +3346,11 @@ First differing element 0: - +
TestReader - test_comic_reader
- -
- FAIL -
- - - - + PASS @@ -3340,31 +3382,11 @@ AssertionError: False is not true - +
TestReader - test_txt_reader
- -
- FAIL -
- - - - + PASS @@ -3723,11 +3745,11 @@ AssertionError: False is not true : Encoding of textfile viewer is not respected - + TestThumbnails 8 - 3 - 4 + 7 + 0 0 1 @@ -3746,31 +3768,11 @@ AssertionError: False is not true : Encoding of textfile viewer is not respected - +
TestThumbnails - test_cache_of_deleted_book
- -
- FAIL -
- - - - + PASS @@ -3784,31 +3786,11 @@ AssertionError: 0 != 2 - +
TestThumbnails - test_cover_change_on_upload_new_cover
- -
- FAIL -
- - - - + PASS @@ -3822,31 +3804,11 @@ AssertionError: 0.02977373520222651 not greater than or equal to 0.03 - +
TestThumbnails - test_cover_on_upload_book
- -
- FAIL -
- - - - + PASS @@ -3860,31 +3822,11 @@ AssertionError: 222 != 220 - +
TestThumbnails - test_sideloaded_book
- -
- FAIL -
- - - - + PASS @@ -4003,11 +3945,11 @@ AssertionError: 0.0 not greater than or equal to 0.04 - + TestUploadEPubs 5 - 3 - 2 + 5 + 0 0 0 @@ -4017,60 +3959,20 @@ AssertionError: 0.0 not greater than or equal to 0.04 - +
TestUploadEPubs - test_upload_epub_cover
- -
- FAIL -
- - - - + PASS - +
TestUploadEPubs - test_upload_epub_cover_formats
- -
- FAIL -
- - - - + PASS @@ -4999,9 +4901,9 @@ AssertionError: 0.051106144230518215 != 0.0058 within 0.0001 delta (0.0453061442 Total 425 - 406 - 10 - 2 + 411 + 6 + 1 7   @@ -5450,7 +5352,7 @@ AssertionError: 0.051106144230518215 != 0.0058 within 0.0001 delta (0.0453061442