Commit 80008817 authored by Thomas Bernhart's avatar Thomas Bernhart
Browse files

Correctly select right media/thumbnail file to export

parent 991a2a87
......@@ -12,33 +12,40 @@ class MediaFileSearcher:
def search_media_file(self):
accesscopy_file = self.foxml_reader.get_accesscopy_datastream_file()
locator = self.foxml_reader.get_locator()
if accesscopy_file is not None:
return path.join(self.datastream_store_path, accesscopy_file), path.basename(self.foxml_reader.get_accesscopy_datastream_original_filename())
return self.__get_file_from_datastream_store(accesscopy_file, self.foxml_reader.get_accesscopy_datastream_original_filename())
elif locator is not None:
return self.__get_file_from_locator(locator)
else:
locator = self.foxml_reader.get_locator()
if locator is not None:
# search streaming resource
if locator.startswith('https://memobase.ch/files/'):
http_resource_file = self.__get_http_resource_file(locator)
return http_resource_file, path.basename(http_resource_file)
elif locator.startswith('rtmp://intstream.memobase.ch:1935/memobase/'):
rtmp_resource_file = self.__get_rtmp_resource_file(locator)
return rtmp_resource_file, path.basename(rtmp_resource_file)
else:
return None
else:
return None
return None
def search_thumbnail_file(self):
thumbnail_file = self.foxml_reader.get_thumbnail_datastream_file()
if thumbnail_file is not None:
ext = path.splitext(self.foxml_reader.get_thumbnail_datastream_original_filename())[1]
return path.join(self.datastream_store_path, thumbnail_file), path.basename(self.foxml_reader.get_thumbnail_datastream_original_filename())
return self.__get_file_from_datastream_store(thumbnail_file, self.foxml_reader.get_thumbnail_datastream_original_filename())
else:
return None
def __get_file_from_datastream_store(self, relative_file_path, original_filename):
full_file_path = path.join(self.datastream_store_path, relative_file_path)
return full_file_path, path.basename(original_filename)
def __get_file_from_locator(self, locator):
# search streaming resource
if locator.startswith('https://memobase.ch/files/'):
return self.__get_http_resource_file(locator)
elif locator.startswith('rtmp://intstream.memobase.ch:1935/memobase/'):
return self.__get_rtmp_resource_file(locator)
else:
return None
def __get_http_resource_file(self, locator):
return path.join(self.http_files_path, locator[len('https://memobase.ch/files/'):])
http_resource_path = path.join(self.http_files_path, locator[len('https://memobase.ch/files/'):])
if path.isfile(http_resource_path):
return http_resource_path, path.basename(http_resource_path)
else:
return None
def __get_rtmp_resource_file(self, locator):
rtmp_rel_path = locator[len('rtmp://intstream.memobase.ch:1935/memobase/'):]
......@@ -47,8 +54,8 @@ class MediaFileSearcher:
source_path2 = path.join(self.rtmp_files_path, 'open', source_filename)
if path.isfile(source_path1):
return source_path1
return source_path1, path.basename(source_path1)
elif path.isfile(source_path2):
return source_path2
return source_path2, path.basename(source_path2)
else:
return None
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