Video media_data: Change layout in the mongo world
Change the media_data for video from entry.media_data["video"] to use entry.media_data directly. Also start a bare MediaEntry.media_data_init(**kwargs) method for setting up the media_data and possibly initialising it with kwargs.
This commit is contained in:
parent
94df840b3b
commit
5ff575827b
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -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="">
|
||||
|
Loading…
x
Reference in New Issue
Block a user