From 809ebf4536ed652325013d1a78e2239849e85cd5 Mon Sep 17 00:00:00 2001 From: vijeth-aradhya Date: Sun, 16 Jul 2017 20:43:08 +0530 Subject: [PATCH] Add get_all_media() in MediaEntryMixin Returns all available qualties of a media with it's dimensions and resolution label. --- mediagoblin/db/mixin.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/mediagoblin/db/mixin.py b/mediagoblin/db/mixin.py index e8b121d0..b47dc0e7 100644 --- a/mediagoblin/db/mixin.py +++ b/mediagoblin/db/mixin.py @@ -249,6 +249,33 @@ class MediaEntryMixin(GenerateSlugMixin, GeneratePublicIDMixin): if media_size in media_sizes: return media_size, self.media_files[media_size] + def get_all_media(self): + """ + Returns all available qualties of a media + """ + fetch_order = self.media_manager.media_fetch_order + + # No fetching order found? well, give up! + if not fetch_order: + return None + + media_sizes = self.media_files.keys() + + all_media_path = [] + + for media_size in fetch_order: + if media_size in media_sizes: + file_metadata = self.get_file_metadata(media_size) + size = file_metadata['medium_size'] + if media_size != 'webm': + all_media_path.append((media_size[5:], size, + self.media_files[media_size])) + else: + sall_media_path.append(('default', size, + self.media_files[media_size])) + + return all_media_path + def main_mediafile(self): pass -- 2.25.1