def contains_video(self): for field, inputs in self.content.items(): if 'file' in inputs: if Asset.get(inputs['file']).mime_type.startswith('video'): return True elif 'video' in inputs: return True return False
def __init__(self, slide_input, template): if 'video' not in slide_input and 'file' not in slide_input: raise ValueError('No video was specified in either video or file slide input type') self.content = {'background-1': slide_input} if 'background-1' not in Templates[template]: raise KeyError('The template %s has no background to put the video' % template) video_path = slide_input['video'] if 'video' in slide_input else Asset.get(slide_input['file']).path video_info = MediaInfo.parse(video_path) self.duration = video_info.tracks[0].duration + 1000 self.template = template
def get(self, asset_id): """ Waits for the given asset to be downloaded. Redirects the user to the asset when done. """ try: asset_id = int(asset_id) if self.download_manager.has_pending_task_for_asset(asset_id): task = self.download_manager.get_pending_task_for_asset(asset_id) task.result() resp.seeother('/' + Asset.get(asset_id)._get_path(force=True)) # Task is complete but asset may be still marked as in flight except SQLObjectNotFound: resp.notfound() except KeyError: resp.seeother('/cache/' + str(asset_id))
def _is_video(file_ref): asset = Asset.get(file_ref) return asset.mime_type.startswith('video')