def test_playlist(self): playlist_dict = { "build_jobs": [], "id": "36f6ab50-4e33-4da8-b853-2261d74fb64b", "created_at": "2019-08-06T11:11:02", "updated_at": "2019-08-06T13:11:02", "name": "2019-08-06 13:11:02 New playlist ", "shots": [], "project_id": str(self.project.id), "episode_id": str(self.episode.id), "type": "Playlist" } Playlist.create_from_import(playlist_dict) playlist = Playlist.get(playlist_dict["id"]) self.assertEqual(playlist.name, playlist_dict["name"])
def get_playlist_with_preview_file_revisions(playlist_id): """ Return given playlist. Shot list is augmented with all previews available for a given shot. """ playlist = Playlist.get(playlist_id) if playlist is None: raise PlaylistNotFoundException() playlist_dict = playlist.serialize() if playlist_dict["shots"] is None: playlist_dict["shots"] = [] for shot in playlist_dict["shots"]: try: preview_file = PreviewFile.get(shot["preview_file_id"]) if preview_file is None or preview_file.extension != 'mp4': preview_file = PreviewFile.query \ .filter_by(task_id=preview_file.task_id) \ .filter_by(extension="mp4") \ .join(Task) \ .join(TaskType) \ .order_by(TaskType.priority.desc()) \ .order_by(TaskType.name) \ .order_by(PreviewFile.revision.desc()) \ .first() if preview_file is not None: shot["preview_file_id"] = str(preview_file.id) shot["extension"] = preview_file.extension shot["annotations"] = preview_file.annotations shot["task_id"] = fields.serialize_value(preview_file.task_id) else: del shot["preview_file_id"] except Exception as e: print(e) try: shot["preview_files"] = get_preview_files_for_shot(shot["shot_id"]) except ShotNotFoundException: playlist_dict["shots"].remove(shot) return playlist_dict
def get_playlist_with_preview_file_revisions(playlist_id): """ Return given playlist. Shot list is augmented with all previews available for a given shot. """ playlist = Playlist.get(playlist_id) if playlist is None: raise PlaylistNotFoundException() playlist_dict = playlist.serialize() playlist_dict["build_jobs"] = [] for build_job in reversed(playlist.build_jobs): playlist_dict["build_jobs"].append(fields.serialize_dict({ "id": build_job.id, "status": build_job.status, "created_at": build_job.created_at })) if playlist_dict["shots"] is None: playlist_dict["shots"] = [] ( playlist_dict, preview_file_map ) = set_preview_files_for_shots(playlist_dict) for shot in playlist_dict["shots"]: try: preview_file = preview_file_map.get(shot["preview_file_id"], None) if preview_file is not None: shot["preview_file_id"] = str(preview_file.id) shot["extension"] = preview_file.extension shot["annotations"] = preview_file.annotations shot["task_id"] = fields.serialize_value(preview_file.task_id) else: del shot["preview_file_id"] except Exception as e: print(e) return playlist_dict
def get_playlist_with_preview_file_revisions(playlist_id): """ Return given playlist. Shot list is augmented with all previews available for a given shot. """ playlist = Playlist.get(playlist_id) if playlist is None: raise PlaylistNotFoundException() playlist_dict = playlist.serialize() if playlist_dict["shots"] is None: playlist_dict["shots"] = [] for shot in playlist_dict["shots"]: shot["preview_files"] = get_preview_files_for_shot( shot["shot_id"] ) return playlist_dict