Unverified Commit 9007ffef authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

fix missing file extension issue


Signed-off-by: Sebastian Schüpbach's avatarSebastian Schüpbach <sebastian.schuepbach@unibas.ch>
parent 14c18280
Pipeline #16877 passed with stages
in 4 minutes and 38 seconds
......@@ -113,7 +113,6 @@ def _get_values_from_thumbnail_object(msg, _access_status):
def _get_values_from_digital_object(msg, access_status):
obj_type = None
file_extension = ''
return_values = {
'access': access_status
......@@ -123,17 +122,6 @@ def _get_values_from_digital_object(msg, access_status):
if 'hasMimeType' in msg:
mimetype = msg['hasMimeType']
return_values['mimetype'] = mimetype
if 'locator' in msg and 'https://memobase.ch/' not in msg['locator']:
uri = msg['locator']
else:
if obj_type == 'image':
file_extension = 'jp2'
if obj_type == 'audio':
file_extension = 'mp4'
if obj_type == 'video':
file_extension = 'mp4'
uri = os.environ['URI_BASE'] + return_values['sig'] + '.' + file_extension
return_values['uri'] = uri
if 'height' in msg:
height = msg['height']
return_values['height'] = height
......@@ -145,18 +133,27 @@ def _get_values_from_digital_object(msg, access_status):
return_values['duration'] = duration
if 'isDistributedOn' in msg:
return_values['type'] = msg['isDistributedOn']
if _is_remote_file(uri):
if access_status == 'public':
return_values['proto'] = 'redirect'
else:
return_values['proto'] = 'proxy'
if _is_remote_file(msg):
return_values['uri'] = msg['locator']
if access_status == 'public':
return_values['proto'] = 'redirect'
else:
return_values['proto'] = 'file'
return_values['proto'] = 'proxy'
else:
return_values['proto'] = 'file'
if return_values['type'] == 'image':
file_extension = 'jp2'
if return_values['type'] == 'audio':
file_extension = 'mp4'
if return_values['type'] == 'video':
file_extension = 'mp4'
return_values['uri'] = os.environ['URI_BASE'] + return_values['sig'] + '.' + file_extension
return return_values
def _is_remote_file(uri):
return uri.startswith('http')
def _is_remote_file(msg):
return 'locator' in msg and msg['locator'].startswith('http') \
and not msg['locator'].startswith('https://memobase.ch/')
def _is_directly_fetchable(digital_object_resource):
......
......@@ -4,7 +4,7 @@
"@id": "https://memobase.ch/digital/SRF-UMusik-BE_MG_DUR_B62276-1",
"@type": "https://www.ica.org/standards/RiC/ontology#Instantiation",
"isDistributedOn": "audio",
"locator": "mms://drsstream.memobase.ch/Memobase/48534D2D4C4F434154494F4E2D312E307AA29F92768A2A3935010000D83056DA.wma",
"locator": "https://drsstream.memobase.ch/Memobase/48534D2D4C4F434154494F4E2D312E307AA29F92768A2A3935010000D83056DA.wma",
"identifiedBy": "https://memobase.ch/digital/SRF-UMusik-BE_MG_DUR_B62276-1#genidc7523eee-3f8f-4d56-bbea-acb188847569",
"instantiates": "https://memobase.ch/record/SRF-UMusik-BE_MG_DUR_B62276",
"isDerivedFromInstantiation": "https://memobase.ch/physical/SRF-UMusik-BE_MG_DUR_B62276-1",
......
......@@ -50,7 +50,7 @@ class Test(TestCase):
return res
def setUp(self) -> None:
os.environ['URI_BASE'] = 'awefwef'
os.environ['URI_BASE'] = 'file:///data/'
def test__get_access_status_if_resource_is_private(self):
access_status = MediametadataToDB._get_access_status(
......@@ -68,7 +68,7 @@ class Test(TestCase):
'access': 'public',
'proto': 'file',
'type': 'audio',
'uri': 'rtmp://intstream.memobase.ch:1935/memobase/mp3:BAB_MC169A.mp3'
'uri': 'file:///data/BAB-PA_43-BAB_MC169A-1.mp4'
}
digital_object = Test._load_file_and_get_res('BAB-PA_43-BAB_MC169A.json',
Test._get_digital_object)
......
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