Unverified Commit aadb4805 authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files
parent 3c869126
Pipeline #16821 passed with stages
in 4 minutes and 8 seconds
...@@ -123,9 +123,6 @@ def _get_values_from_digital_object(msg, access_status): ...@@ -123,9 +123,6 @@ def _get_values_from_digital_object(msg, access_status):
if 'hasMimeType' in msg: if 'hasMimeType' in msg:
mimetype = msg['hasMimeType'] mimetype = msg['hasMimeType']
return_values['mimetype'] = mimetype return_values['mimetype'] = mimetype
# create value for field 'type' form mimetype:
obj_type = mimetype.split('/')[0]
return_values['type'] = obj_type
if 'locator' in msg and 'https://memobase.ch/' not in msg['locator']: if 'locator' in msg and 'https://memobase.ch/' not in msg['locator']:
uri = msg['locator'] uri = msg['locator']
else: else:
...@@ -147,12 +144,8 @@ def _get_values_from_digital_object(msg, access_status): ...@@ -147,12 +144,8 @@ def _get_values_from_digital_object(msg, access_status):
duration = msg['duration'] duration = msg['duration']
return_values['duration'] = duration return_values['duration'] = duration
if 'isDistributedOn' in msg: if 'isDistributedOn' in msg:
# //@formatter:off return_values['type'] = msg['isDistributedOn']
if uri.startswith('http'): if _is_remote_file(uri):
if not (msg['isDistributedOn'] == 'audio' or msg['isDistributedOn'] == 'image' or
msg['isDistributedOn'] == 'video'):
# // @formatter:on
return_values['type'] = msg['isDistributedOn']
if access_status == 'public': if access_status == 'public':
return_values['proto'] = 'redirect' return_values['proto'] = 'redirect'
else: else:
...@@ -162,6 +155,16 @@ def _get_values_from_digital_object(msg, access_status): ...@@ -162,6 +155,16 @@ def _get_values_from_digital_object(msg, access_status):
return return_values return return_values
def _is_remote_file(uri):
return uri.startswith('http')
def _is_directly_fetchable(digital_object_resource):
return digital_object_resource['isDistributedOn'] == 'audio' or \
digital_object_resource['isDistributedOn'] == 'image' or \
digital_object_resource['isDistributedOn'] == 'video'
def _get_access_status(graph, record_id): def _get_access_status(graph, record_id):
for resource in graph: for resource in graph:
if 'type' in resource and resource['type'] == 'access' and \ if 'type' in resource and resource['type'] == 'access' and \
......
...@@ -66,8 +66,9 @@ class Test(TestCase): ...@@ -66,8 +66,9 @@ class Test(TestCase):
res = { res = {
'sig': 'BAB-PA_43-BAB_MC169A-1', 'sig': 'BAB-PA_43-BAB_MC169A-1',
'access': 'public', 'access': 'public',
'uri': 'rtmp://intstream.memobase.ch:1935/memobase/mp3:BAB_MC169A.mp3', 'proto': 'file',
'type': 'audio' 'type': 'audio',
'uri': 'rtmp://intstream.memobase.ch:1935/memobase/mp3:BAB_MC169A.mp3'
} }
digital_object = Test._load_file_and_get_res('BAB-PA_43-BAB_MC169A.json', digital_object = Test._load_file_and_get_res('BAB-PA_43-BAB_MC169A.json',
Test._get_digital_object) Test._get_digital_object)
......
Supports Markdown
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