diff --git a/cps/tasks/thumbnail.py b/cps/tasks/thumbnail.py index 5bf0466b..e66da036 100644 --- a/cps/tasks/thumbnail.py +++ b/cps/tasks/thumbnail.py @@ -17,6 +17,7 @@ # along with this program. If not, see . import os +from shutil import copyfile, copyfileobj from urllib.request import urlopen from .. import constants @@ -188,14 +189,18 @@ class TaskGenerateCoverThumbnails(CalibreTask): try: stream = urlopen(web_content_link) with Image(file=stream) as img: + filename = self.cache.get_cache_file_path(thumbnail.filename, + constants.CACHE_TYPE_THUMBNAILS) height = get_resize_height(thumbnail.resolution) if img.height > height: width = get_resize_width(thumbnail.resolution, img.width, img.height) img.resize(width=width, height=height, filter='lanczos') img.format = thumbnail.format - filename = self.cache.get_cache_file_path(thumbnail.filename, - constants.CACHE_TYPE_THUMBNAILS) img.save(filename=filename) + else: + with open(filename, 'rb') as fd: + copyfileobj(stream, fd) + except Exception as ex: # Bubble exception to calling function self.log.debug('Error generating thumbnail file: ' + str(ex)) @@ -210,12 +215,15 @@ class TaskGenerateCoverThumbnails(CalibreTask): with Image(filename=book_cover_filepath) as img: height = get_resize_height(thumbnail.resolution) + filename = self.cache.get_cache_file_path(thumbnail.filename, constants.CACHE_TYPE_THUMBNAILS) if img.height > height: width = get_resize_width(thumbnail.resolution, img.width, img.height) img.resize(width=width, height=height, filter='lanczos') img.format = thumbnail.format - filename = self.cache.get_cache_file_path(thumbnail.filename, constants.CACHE_TYPE_THUMBNAILS) img.save(filename=filename) + else: + # take cover as is + copyfile(book_cover_filepath, filename) @property def name(self): diff --git a/test/Calibre-Web TestSummary_Linux.html b/test/Calibre-Web TestSummary_Linux.html index 2c8c5f9c..735a1db2 100644 --- a/test/Calibre-Web TestSummary_Linux.html +++ b/test/Calibre-Web TestSummary_Linux.html @@ -37,20 +37,20 @@
-

Start Time: 2023-03-03 20:00:16

+

Start Time: 2023-03-20 06:27:14

-

Stop Time: 2023-03-04 02:33:04

+

Stop Time: 2023-03-20 13:00:29

-

Duration: 5h 37 min

+

Duration: 5h 35 min

@@ -234,6 +234,521 @@ + + TestBackupMetadata + 16 + 1 + 1 + 14 + 0 + + Detail + + + + + + + +
TestBackupMetadata - test_backup_all
+ + +
+ FAIL +
+ + + + + + + + + + +
TestBackupMetadata - test_backup_change_book_author
+ + +
+ ERROR +
+ + + + + + + + + + +
TestBackupMetadata - test_backup_change_book_description
+ + +
+ ERROR +
+ + + + + + + + + + +
TestBackupMetadata - test_backup_change_book_language
+ + +
+ ERROR +
+ + + + + + + + + + +
TestBackupMetadata - test_backup_change_book_publisher
+ + +
+ ERROR +
+ + + + + + + + + + +
TestBackupMetadata - test_backup_change_book_publishing_date
+ + +
+ ERROR +
+ + + + + + + + + + +
TestBackupMetadata - test_backup_change_book_rating
+ + +
+ ERROR +
+ + + + + + + + + + +
TestBackupMetadata - test_backup_change_book_seriesindex
+ + +
+ ERROR +
+ + + + + + + + + + +
TestBackupMetadata - test_backup_change_book_tags
+ + +
+ ERROR +
+ + + + + + + + + + +
TestBackupMetadata - test_backup_change_book_title
+ + +
+ ERROR +
+ + + + + + + + + + +
TestBackupMetadata - test_backup_change_custom_bool
+ + +
+ ERROR +
+ + + + + + + + + + +
TestBackupMetadata - test_backup_change_custom_float
+ + +
+ ERROR +
+ + + + + + + + + + +
TestBackupMetadata - test_backup_change_custom_int
+ + +
+ ERROR +
+ + + + + + + + + + +
TestBackupMetadata - test_backup_change_custom_rating
+ + +
+ ERROR +
+ + + + + + + + + + +
TestBackupMetadata - test_gdrive
+ + PASS + + + + + + +
TestBackupMetadata - test_upload_book
+ + +
+ ERROR +
+ + + + + + + + + TestCli 12 @@ -242,13 +757,13 @@ 0 0 - Detail + Detail - +
TestCli - test_already_started
@@ -257,7 +772,7 @@ - +
TestCli - test_bind_to_single_interface
@@ -266,7 +781,7 @@ - +
TestCli - test_change_password
@@ -275,7 +790,7 @@ - +
TestCli - test_cli_SSL_files
@@ -284,7 +799,7 @@ - +
TestCli - test_cli_different_folder
@@ -293,7 +808,7 @@ - +
TestCli - test_cli_different_settings_database
@@ -302,7 +817,7 @@ - +
TestCli - test_dryrun_update
@@ -311,7 +826,7 @@ - +
TestCli - test_enable_reconnect
@@ -320,7 +835,7 @@ - +
TestCli - test_environ_port_setting
@@ -329,7 +844,7 @@ - +
TestCli - test_no_database
@@ -338,7 +853,7 @@ - +
TestCli - test_settingsdb_not_writeable
@@ -347,7 +862,7 @@ - +
TestCli - test_writeonly_static_files
@@ -365,13 +880,13 @@ 0 0 - Detail + Detail - +
TestCliGdrivedb - test_cli_gdrive_folder
@@ -380,7 +895,7 @@ - +
TestCliGdrivedb - test_cli_gdrive_location
@@ -389,7 +904,7 @@ - +
TestCliGdrivedb - test_gdrive_db_nonwrite
@@ -398,7 +913,7 @@ - +
TestCliGdrivedb - test_no_database
@@ -416,13 +931,13 @@ 0 0 - Detail + Detail - +
TestCoverEditBooks - test_invalid_jpg_hdd
@@ -431,7 +946,7 @@ - +
TestCoverEditBooks - test_upload_jpg
@@ -449,13 +964,13 @@ 0 0 - Detail + Detail - +
TestDeleteDatabase - test_delete_books_in_database
@@ -473,13 +988,13 @@ 0 0 - Detail + Detail - +
TestEbookConvertCalibre - test_calibre_log
@@ -488,7 +1003,7 @@ - +
TestEbookConvertCalibre - test_convert_deactivate
@@ -497,7 +1012,7 @@ - +
TestEbookConvertCalibre - test_convert_email
@@ -506,7 +1021,7 @@ - +
TestEbookConvertCalibre - test_convert_failed_and_email
@@ -515,7 +1030,7 @@ - +
TestEbookConvertCalibre - test_convert_only
@@ -524,7 +1039,7 @@ - +
TestEbookConvertCalibre - test_convert_options
@@ -533,7 +1048,7 @@ - +
TestEbookConvertCalibre - test_convert_parameter
@@ -542,7 +1057,7 @@ - +
TestEbookConvertCalibre - test_convert_wrong_excecutable
@@ -551,7 +1066,7 @@ - +
TestEbookConvertCalibre - test_convert_xss
@@ -560,7 +1075,7 @@ - +
TestEbookConvertCalibre - test_email_failed
@@ -569,7 +1084,7 @@ - +
TestEbookConvertCalibre - test_email_only
@@ -578,7 +1093,7 @@ - +
TestEbookConvertCalibre - test_kindle_send_not_configured
@@ -587,7 +1102,7 @@ - +
TestEbookConvertCalibre - test_ssl_smtp_setup_error
@@ -596,7 +1111,7 @@ - +
TestEbookConvertCalibre - test_starttls_smtp_setup_error
@@ -605,7 +1120,7 @@ - +
TestEbookConvertCalibre - test_user_convert_xss
@@ -623,13 +1138,13 @@ 0 0 - Detail + Detail - +
TestEbookConvertCalibreGDrive - test_convert_email
@@ -638,7 +1153,7 @@ - +
TestEbookConvertCalibreGDrive - test_convert_failed_and_email
@@ -647,7 +1162,7 @@ - +
TestEbookConvertCalibreGDrive - test_convert_only
@@ -656,7 +1171,7 @@ - +
TestEbookConvertCalibreGDrive - test_convert_parameter
@@ -665,7 +1180,7 @@ - +
TestEbookConvertCalibreGDrive - test_email_failed
@@ -674,7 +1189,7 @@ - +
TestEbookConvertCalibreGDrive - test_email_only
@@ -692,13 +1207,13 @@ 0 0 - Detail + Detail - +
TestEbookConvertKepubify - test_convert_deactivate
@@ -707,7 +1222,7 @@ - +
TestEbookConvertKepubify - test_convert_only
@@ -716,7 +1231,7 @@ - +
TestEbookConvertKepubify - test_convert_wrong_excecutable
@@ -734,13 +1249,13 @@ 0 0 - Detail + Detail - +
TestEbookConvertGDriveKepubify - test_convert_deactivate
@@ -749,7 +1264,7 @@ - +
TestEbookConvertGDriveKepubify - test_convert_only
@@ -758,7 +1273,7 @@ - +
TestEbookConvertGDriveKepubify - test_convert_wrong_excecutable
@@ -776,13 +1291,13 @@ 0 1 - Detail + Detail - +
TestEditAdditionalBooks - test_cbz_comicinfo
@@ -791,7 +1306,7 @@ - +
TestEditAdditionalBooks - test_change_upload_formats
@@ -800,7 +1315,7 @@ - +
TestEditAdditionalBooks - test_delete_book
@@ -809,7 +1324,7 @@ - +
TestEditAdditionalBooks - test_delete_role
@@ -818,7 +1333,7 @@ - +
TestEditAdditionalBooks - test_details_popup
@@ -827,7 +1342,7 @@ - +
TestEditAdditionalBooks - test_edit_book_identifier
@@ -836,7 +1351,7 @@ - +
TestEditAdditionalBooks - test_edit_book_identifier_capital
@@ -845,7 +1360,7 @@ - +
TestEditAdditionalBooks - test_edit_book_identifier_standard
@@ -854,7 +1369,7 @@ - +
TestEditAdditionalBooks - test_edit_special_book_identifier
@@ -863,7 +1378,7 @@ - +
TestEditAdditionalBooks - test_title_sort
@@ -872,7 +1387,7 @@ - +
TestEditAdditionalBooks - test_upload_cbz_coverformats
@@ -881,7 +1396,7 @@ - +
TestEditAdditionalBooks - test_upload_edit_role
@@ -890,7 +1405,7 @@ - +
TestEditAdditionalBooks - test_upload_metadata_cbr
@@ -899,7 +1414,7 @@ - +
TestEditAdditionalBooks - test_upload_metadata_cbt
@@ -908,7 +1423,7 @@ - +
TestEditAdditionalBooks - test_xss_author_edit
@@ -917,7 +1432,7 @@ - +
TestEditAdditionalBooks - test_xss_comment_edit
@@ -926,7 +1441,7 @@ - +
TestEditAdditionalBooks - test_xss_custom_comment_edit
@@ -944,13 +1459,13 @@ 0 1 - Detail + Detail - +
TestEditBooks - test_download_book
@@ -959,7 +1474,7 @@ - +
TestEditBooks - test_edit_author
@@ -968,7 +1483,7 @@ - +
TestEditBooks - test_edit_category
@@ -977,7 +1492,7 @@ - +
TestEditBooks - test_edit_comments
@@ -986,7 +1501,7 @@ - +
TestEditBooks - test_edit_custom_bool
@@ -995,7 +1510,7 @@ - +
TestEditBooks - test_edit_custom_categories
@@ -1004,7 +1519,7 @@ - +
TestEditBooks - test_edit_custom_comment
@@ -1013,7 +1528,7 @@ - +
TestEditBooks - test_edit_custom_date
@@ -1022,7 +1537,7 @@ - +
TestEditBooks - test_edit_custom_float
@@ -1031,7 +1546,7 @@ - +
TestEditBooks - test_edit_custom_int
@@ -1040,7 +1555,7 @@ - +
TestEditBooks - test_edit_custom_rating
@@ -1049,7 +1564,7 @@ - +
TestEditBooks - test_edit_custom_single_select
@@ -1058,7 +1573,7 @@ - +
TestEditBooks - test_edit_custom_text
@@ -1067,7 +1582,7 @@ - +
TestEditBooks - test_edit_language
@@ -1076,7 +1591,7 @@ - +
TestEditBooks - test_edit_publisher
@@ -1085,7 +1600,7 @@ - +
TestEditBooks - test_edit_publishing_date
@@ -1094,7 +1609,7 @@ - +
TestEditBooks - test_edit_rating
@@ -1103,7 +1618,7 @@ - +
TestEditBooks - test_edit_series
@@ -1112,7 +1627,7 @@ - +
TestEditBooks - test_edit_title
@@ -1121,19 +1636,19 @@ - +
TestEditBooks - test_rename_uppercase_lowercase
- SKIP + SKIP
-