aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mediagoblin/db/mongo/migrations.py14
-rw-r--r--mediagoblin/db/mongo/models.py3
-rw-r--r--mediagoblin/db/sql/models.py9
-rw-r--r--mediagoblin/media_types/video/processing.py6
-rw-r--r--mediagoblin/templates/mediagoblin/media_displays/video.html4
5 files changed, 31 insertions, 5 deletions
diff --git a/mediagoblin/db/mongo/migrations.py b/mediagoblin/db/mongo/migrations.py
index 59035f3b..c5766b0d 100644
--- a/mediagoblin/db/mongo/migrations.py
+++ b/mediagoblin/db/mongo/migrations.py
@@ -139,3 +139,17 @@ def remove_calculated_html(database):
drop_table_field(database, 'users', 'bio_html')
drop_table_field(database, 'media_entries', 'description_html')
drop_table_field(database, 'media_comments', 'content_html')
+
+@RegisterMigration(10)
+def convert_video_media_data(database):
+ """
+ Move media_data["video"] directly into media_data
+ """
+ collection = database['media_entries']
+ target = collection.find(
+ {'media_data.video': {'$exists': True}})
+
+ for document in target:
+ assert len(document['media_data']) == 1
+ document['media_data'] = document['media_data']['video']
+ collection.save(document)
diff --git a/mediagoblin/db/mongo/models.py b/mediagoblin/db/mongo/models.py
index 99c7905d..c86adbb6 100644
--- a/mediagoblin/db/mongo/models.py
+++ b/mediagoblin/db/mongo/models.py
@@ -220,6 +220,9 @@ class MediaEntry(Document, MediaEntryMixin):
id = MongoPK()
+ def media_data_init(self, **kwargs):
+ self.media_data.update(kwargs)
+
def get_comments(self, ascending=False):
if ascending:
order = ASCENDING
diff --git a/mediagoblin/db/sql/models.py b/mediagoblin/db/sql/models.py
index b52eac76..dbc9ca05 100644
--- a/mediagoblin/db/sql/models.py
+++ b/mediagoblin/db/sql/models.py
@@ -167,6 +167,15 @@ class MediaEntry(Base, MediaEntryMixin):
if media is not None:
return media.url_for_self(urlgen)
+ @property
+ def media_data(self):
+ # TODO: Replace with proper code to read the correct table
+ return {}
+
+ def media_data_init(self, **kwargs):
+ # TODO: Implement this
+ pass
+
class MediaFile(Base):
"""
diff --git a/mediagoblin/media_types/video/processing.py b/mediagoblin/media_types/video/processing.py
index 9dc23c55..3a479802 100644
--- a/mediagoblin/media_types/video/processing.py
+++ b/mediagoblin/media_types/video/processing.py
@@ -77,9 +77,9 @@ def process_video(entry):
entry.media_files['webm_640'] = medium_filepath
# Save the width and height of the transcoded video
- entry.media_data['video'] = {
- u'width': transcoder.dst_data.videowidth,
- u'height': transcoder.dst_data.videoheight}
+ entry.media_data_init(
+ width=transcoder.dst_data.videowidth,
+ height=transcoder.dst_data.videoheight)
# Create a temporary file for the video thumbnail
tmp_thumb = tempfile.NamedTemporaryFile()
diff --git a/mediagoblin/templates/mediagoblin/media_displays/video.html b/mediagoblin/templates/mediagoblin/media_displays/video.html
index ec4338fa..acd570e7 100644
--- a/mediagoblin/templates/mediagoblin/media_displays/video.html
+++ b/mediagoblin/templates/mediagoblin/media_displays/video.html
@@ -21,8 +21,8 @@
{% block mediagoblin_media %}
<div class="video-player" style="position: relative;">
<video class="video-js vjs-default-skin"
- width="{{ media.media_data.video.width }}"
- height="{{ media.media_data.video.height }}"
+ width="{{ media.media_data.width }}"
+ height="{{ media.media_data.height }}"
controls="controls"
preload="auto"
data-setup="">