Unverified Commit 46c5a252 authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

don't make presence of access flag requirement for thumbnail


Signed-off-by: Sebastian Schüpbach's avatarSebastian Schüpbach <sebastian.schuepbach@unibas.ch>
parent 64cc61d7
Pipeline #18496 passed with stages
in 2 minutes and 6 seconds
......@@ -96,10 +96,10 @@ def _get_values_from_thumbnail_object(msg, _access_status) -> dict:
'sig': '{}-poster'.format(msg['@id'].split('/')[-2]),
'uri': 'file:///data/{}-poster.jp2'.format(msg['@id'].split('/')[-2])}
if 'height' in msg:
height = msg['height']
height = _normalize_dimension(msg['height'])
return_values['height'] = height
if 'width' in msg:
width = msg['width']
width = _normalize_dimension(msg['width'])
return_values['width'] = width
return return_values
......@@ -111,10 +111,10 @@ def _get_values_from_digital_object(msg, access_status) -> dict:
file_extension = ''
return_values = {'access': access_status, 'sig': msg['@id'].split('/')[-1]}
if 'height' in msg:
height = msg['height']
height = _normalize_dimension(msg['height'])
return_values['height'] = height
if 'width' in msg:
width = msg['width']
width = _normalize_dimension(msg['width'])
return_values['width'] = width
if 'duration' in msg:
duration = _normalize_duration(msg['duration'])
......@@ -227,9 +227,8 @@ def _has_audio_snippet(record) -> bool:
record['uri'].startswith('file://')
# TODO: Eventually remove
def _has_http_locator(digital_object) -> bool:
return 'locator' in digital_object and digital_object['locator'].startswith('http')
def _normalize_dimension(dimension) -> int:
return round(float(dimension))
def _normalize_duration(duration) -> int:
......@@ -340,13 +339,12 @@ class MediametadataToDB:
record_id = _get_record_id(record)
logging.debug(f'Processing record {record_id}')
access_status = _get_access_status(record, record_id)
if access_status == 'public' or access_status == 'closed':
enrichable = False
for record_resource in record:
if 'type' in record_resource and \
record_resource['type'] == 'digitalObject' and \
_has_http_locator(record_resource):
enrichable = True
enrichable = False
for record_resource in record:
if 'type' in record_resource and \
record_resource['type'] == 'digitalObject':
enrichable = True
if access_status == 'public' or access_status == 'closed':
enriched_data = \
_try_fetch_from_json_object(record_resource,
_get_values_from_digital_object,
......@@ -357,25 +355,25 @@ class MediametadataToDB:
"Could not process digitalObject")
else:
record_values_for_db.append(enriched_data)
if 'type' in record_resource and \
record_resource['type'] == 'thumbnail':
enrichable = True
enriched_data = \
_try_fetch_from_json_object(record_resource,
_get_values_from_thumbnail_object,
access_status)
record_values_for_db.append(enriched_data)
if not enrichable:
reporter.send_message(record_id,
"IGNORE",
"Resource has no digitalObject or thumbnail")
else:
logging.info(f'Ignoring record {record_id} since' +
f' access of digitalObject is {access_status}')
# else:
# logging.info(f'Ignoring record {record_id} since' +
# f' access of digitalObject is {access_status}')
# reporter.send_message(record_id,
# "IGNORE",
# "Ignoring record since access of " +
# "digitalObject is unavailable")
if 'type' in record_resource and \
record_resource['type'] == 'thumbnail':
enrichable = True
enriched_data = \
_try_fetch_from_json_object(record_resource,
_get_values_from_thumbnail_object,
access_status)
record_values_for_db.append(enriched_data)
if not enrichable:
reporter.send_message(record_id,
"IGNORE",
"Ignoring record since access of " +
"digitalObject is unavailable")
"Resource has no digitalObject or thumbnail")
if record_number % 100 == 0:
results = _write_values_in_db(mariadb_cursor, record_values_for_db)
mariadb_connection.commit()
......
......@@ -80,9 +80,9 @@ class Test(TestCase):
'sig': 'mfk-FLM-167202-1',
'access': 'private',
'mimetype': 'video/mpeg',
'height': '384.0',
'width': '512.0',
'duration': '524.970667',
'height': 384,
'width': 512,
'duration': 524,
'uri': 'http://datenbanksammlungen.mfk.ch/eMP/' +
'eMuseumPlus?service=MultimediaAsset&objectId=144755&memobaseExt=mp4',
'type': 'video',
......@@ -98,9 +98,9 @@ class Test(TestCase):
'sig': 'mfk-FLM-167202-1',
'access': 'public',
'mimetype': 'video/mpeg',
'height': '384.0',
'width': '512.0',
'duration': '524.970667',
'height': 384,
'width': 512,
'duration': 524,
'uri': 'http://datenbanksammlungen.mfk.ch/eMP/' +
'eMuseumPlus?service=MultimediaAsset&objectId=144755&memobaseExt=mp4',
'type': 'video',
......
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