diff --git a/cps/comic.py b/cps/comic.py index b094c60f..64711460 100644 --- a/cps/comic.py +++ b/cps/comic.py @@ -56,25 +56,25 @@ COVER_EXTENSIONS = ['.png', '.webp', '.bmp', '.jpg', '.jpeg'] def _cover_processing(tmp_file_name, img, extension): tmp_cover_name = os.path.join(os.path.dirname(tmp_file_name), 'cover.jpg') - if use_IM: - # convert to jpg because calibre only supports jpg - if extension in NO_JPEG_EXTENSIONS: - with Image(filename=tmp_file_name) as imgc: + if extension in NO_JPEG_EXTENSIONS: + if use_IM: + with Image(blob=img) as imgc: imgc.format = 'jpeg' imgc.transform_colorspace('rgb') - imgc.save(tmp_cover_name) + imgc.save(filename=tmp_cover_name) return tmp_cover_name - - if not img: + else: + return None + if img: + with open(tmp_cover_name, 'wb') as f: + f.write(img) + return tmp_cover_name + else: return None - with open(tmp_cover_name, 'wb') as f: - f.write(img) - return tmp_cover_name - def _extract_Cover_from_archive(original_file_extension, tmp_file_name, rarExecutable): - cover_data = None + cover_data = extension = None if original_file_extension.upper() == '.CBZ': cf = zipfile.ZipFile(tmp_file_name) for name in cf.namelist(): @@ -106,7 +106,7 @@ def _extract_Cover_from_archive(original_file_extension, tmp_file_name, rarExecu break except Exception as ex: log.debug('Rarfile failed with error: %s', ex) - return cover_data + return cover_data, extension def _extractCover(tmp_file_name, original_file_extension, rarExecutable): @@ -121,7 +121,7 @@ def _extractCover(tmp_file_name, original_file_extension, rarExecutable): cover_data = archive.getPage(index) break else: - cover_data = _extract_Cover_from_archive(original_file_extension, tmp_file_name, rarExecutable) + cover_data, extension = _extract_Cover_from_archive(original_file_extension, tmp_file_name, rarExecutable) return _cover_processing(tmp_file_name, cover_data, extension) diff --git a/test/Calibre-Web TestSummary_Linux.html b/test/Calibre-Web TestSummary_Linux.html index 978d371b..84bdae18 100644 --- a/test/Calibre-Web TestSummary_Linux.html +++ b/test/Calibre-Web TestSummary_Linux.html @@ -37,20 +37,20 @@
Start Time: 2022-01-17 18:51:33
+Start Time: 2022-01-18 21:11:17
Stop Time: 2022-01-18 07:49:35
+Stop Time: 2022-01-19 01:03:52
Duration: 12h 17 min
+Duration: 3h 12 min
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_edit_books_metadata.py", line 136, in test_load_metadata + self.assertGreaterEqual(diff(BytesIO(cover), BytesIO(original_cover), delete_diff_file=True), 0.05) +AssertionError: 0.0 not greater than or equal to 0.05+
Traceback (most recent call last): - File "/home/ozzie/Development/calibre-web-test/test/test_edit_ebooks_gdrive.py", line 250, in test_edit_title - self.fill_basic_config({"config_unicode_filename": 0}) - File "/home/ozzie/Development/calibre-web-test/test/helper_ui.py", line 358, in fill_basic_config - cls._fill_basic_config(elements) - File "/home/ozzie/Development/calibre-web-test/test/helper_ui.py", line 268, in _fill_basic_config - WebDriverWait(cls.driver, 5).until(EC.presence_of_element_located((By.ID, "config_port"))) - File "/home/ozzie/Development/calibre-web-test/venv/lib/python3.8/site-packages/selenium/webdriver/support/wait.py", line 89, in until - raise TimeoutException(message, screen, stacktrace) -selenium.common.exceptions.TimeoutException: Message: -Stacktrace: -WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:183:5 -NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.jsm:395:5 -element.find/</<@chrome://remote/content/marionette/element.js:300:16+ File "/home/ozzie/Development/calibre-web-test/test/test_edit_ebooks_gdrive.py", line 245, 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 350, in test_sync_shelf + self.assertEqual(1, len(data), data) +AssertionError: 1 != 0 : []+
Traceback (most recent call last): + File "/home/ozzie/Development/calibre-web-test/test/test_reader.py", line 230, in test_sound_listener + self.sound_test('music.flac', 'Unknown - music', '0:02') + File "/home/ozzie/Development/calibre-web-test/test/test_reader.py", line 219, in sound_test + self.assertEqual(duration, duration_item.text) +AssertionError: '0:02' != '0:01' +- 0:02 +? ^ ++ 0:01 +? ^+