Commit be819fc7 authored by birk's avatar birk
Browse files

bugfix for lost video previews

parent b2692c40
......@@ -132,21 +132,24 @@ class MediaFileData():
self.content_type = None
self.data_stream = '{}{}'.format(server_,json_[
'_json-roa']['relations']['data-stream']['href'])
self.previews = {}
self.previews = []
def add_preview(self, preview_):
# TODO: Remove once the API delivers this for MediaFile.
if self.media_type is None or self.media_type is 'image':
self.media_type = preview_.media_type
self.previews[preview_.thumbnail] = preview_
self.previews.append(preview_)
def get_preview(self, size_:str="x_large"):
# maximum, x_large, large, medium, small_125, small
p = None
for k, v in self.previews.items():
if v.content_type == 'video/mp4':
return v
return self.previews.get(size_)
# look for videos first
for i in self.previews:
if i.content_type == 'video/mp4':
return i
for i in self.previews:
if i.thumbnail == size_:
return i
return None
def guess_media_type(self):
# This is just an ugly way to determine the media type as the API doesn't tell.
......
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