Commit 24161fd4 authored by Thomas Bernhart's avatar Thomas Bernhart
Browse files

Only export thumbnails for non-image files

parent 4b1f4183
......@@ -30,6 +30,21 @@ def _normalize_file_extension(original_file_name):
return file_ext_mapping.get(ext.lower(), ext.lower())
def _is_image_file(file_name):
image_file_extensions = [
".jpeg",
".png"
]
normalized_file_ext = _normalize_file_extension(file_name)
return normalized_file_ext in image_file_extensions
def _should_export_thumbnail(accesscopy_file):
# only export thumbnail if accesscopy_file does not exist or is not an image file:
return accesscopy_file is None or (accesscopy_file is not None and not _is_image_file(accesscopy_file[1]))
def _create_logger(name, logfile):
# configure logger:
logger = logging.getLogger(name)
......@@ -106,9 +121,11 @@ def media_export(record_set_path, datastreamstore_path, http_files_path, rtmp_fi
_copy_file(accesscopy_file[0], path.join(record_set_path, "media"),
_normalize_document_id(document_id) + _normalize_file_extension(accesscopy_file[1]), logger)
thumbnail_file = media_file_searcher.search_thumbnail_file()
if thumbnail_file is not None:
_copy_file(thumbnail_file[0], path.join(record_set_path, "thumbnails"),
_normalize_document_id(document_id) + _normalize_file_extension(thumbnail_file[1]), logger)
# only export thumbnail if accesscopy_file does not exist or is not an image file:
if _should_export_thumbnail(accesscopy_file):
thumbnail_file = media_file_searcher.search_thumbnail_file()
if thumbnail_file is not None:
_copy_file(thumbnail_file[0], path.join(record_set_path, "thumbnails"),
_normalize_document_id(document_id) + _normalize_file_extension(thumbnail_file[1]), logger)
print("Finished media export for '" + record_set_path + "'")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment