From b605253f334a208d7f651d17c949a75bb084aa58 Mon Sep 17 00:00:00 2001
From: Boris Bobrov <breton@cynicmansion.ru>
Date: Fri, 20 Mar 2015 02:43:16 +0300
Subject: [PATCH] Move check that metadata exists earlier
Because of gstreamer-1.0 we need to migrate from old format of storing
metadata to new one. It seems that there are cases when original
metadata is empty for some reason.
The patch adds an earlier check that original metadata exists, skipping
everything is it doesn't.
Closes bug 5071
---
mediagoblin/media_types/video/migrations.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mediagoblin/media_types/video/migrations.py b/mediagoblin/media_types/video/migrations.py
index 8088220..2445cd4 100644
a
|
b
|
def change_metadata_format(db):
|
59 | 59 | vid_data = inspect_table(db_metadata, "video__mediadata") |
60 | 60 | |
61 | 61 | for row in db.execute(vid_data.select()): |
62 | | metadata = json.loads(row.orig_metadata) |
63 | | |
64 | | if not metadata: |
| 62 | if not row.orig_metadata: |
65 | 63 | continue |
66 | 64 | |
| 65 | metadata = json.loads(row.orig_metadata) |
| 66 | |
67 | 67 | # before this migration there was info about only one video or audio |
68 | 68 | # stream. So, we store existing info as the first item in the list |
69 | 69 | new_metadata = {'audio': [], 'video': [], 'common': {}} |
… |
… |
def change_metadata_format(db):
|
85 | 85 | for k, v in audio_key_map.items() if metadata.get(k))] |
86 | 86 | new_metadata['common'] = dict((v, metadata.get(k)) |
87 | 87 | for k, v in common_key_map.items() if metadata.get(k)) |
88 | | |
| 88 | |
89 | 89 | # 'mimetype' should be in tags |
90 | 90 | new_metadata['common']['tags'] = {'mimetype': metadata.get('mimetype')} |
91 | 91 | if 'tags' in metadata: |