Unverified Commit b18eb705 authored by Kevin Gutiérrez's avatar Kevin Gutiérrez Committed by GitHub
Browse files

Merge branch 'master' into patch-3

parents 4622433b 430f500d
...@@ -189,6 +189,12 @@ class AbstractVideo(CollectionMember, index.Indexed, models.Model): ...@@ -189,6 +189,12 @@ class AbstractVideo(CollectionMember, index.Indexed, models.Model):
def get_current_transcodes(self): def get_current_transcodes(self):
return self.transcodes.exclude(processing=True).filter(error_message__exact='') return self.transcodes.exclude(processing=True).filter(error_message__exact='')
def get_tracks(self):
tracks = []
if hasattr(self, 'track_listing'):
tracks = [t.track_tag() for t in self.track_listing.tracks.all()]
return tracks
def video_tag(self, attrs=None): def video_tag(self, attrs=None):
if attrs is None: if attrs is None:
attrs = {} attrs = {}
...@@ -207,12 +213,8 @@ class AbstractVideo(CollectionMember, index.Indexed, models.Model): ...@@ -207,12 +213,8 @@ class AbstractVideo(CollectionMember, index.Indexed, models.Model):
sources.append("<p>Sorry, your browser doesn't support playback for this video</p>") sources.append("<p>Sorry, your browser doesn't support playback for this video</p>")
tracks = []
if hasattr(self, 'track_listing'):
tracks = [t.track_tag() for t in self.track_listing.tracks.all()]
return mark_safe( return mark_safe(
"<video {0}>\n{1}\n{2}\n</video>".format(flatatt(attrs), "\n".join(sources), "\n".join(tracks))) "<video {0}>\n{1}\n{2}\n</video>".format(flatatt(attrs), "\n".join(sources), "\n".join(self.get_tracks())))
def do_transcode(self, media_format, quality): def do_transcode(self, media_format, quality):
transcode, created = self.transcodes.get_or_create( transcode, created = self.transcodes.get_or_create(
......
...@@ -78,45 +78,43 @@ ...@@ -78,45 +78,43 @@
</div> </div>
</div> </div>
<div class="row" style='margin-top: 2em;'> <div class="row" style='margin-top: 2em;'>
{% block transcode %} {% if can_transcode %}
{% if can_transcode %} <h2 class="u-text-transform-uppercase">{% trans "Transcodes" %}</h2>
<h2 class="u-text-transform-uppercase">{% trans "Transcodes" %}</h2> <p>{% trans "If you wish to generate HTML5 compliant transcodes use the form below. This may take a while depending on the length of the video." %}</p>
<p>{% trans "If you wish to generate HTML5 compliant transcodes use the form below. This may take a while depending on the length of the video." %}</p> {% if transcodes %}
{% if transcodes %} <h3 class="u-text-transform-uppercase">{% trans "Available Transcodes" %}</h3>
<h3 class="u-text-transform-uppercase">{% trans "Available Transcodes" %}</h3> <ul>
<ul> {% for transcode in transcodes %}
{% for transcode in transcodes %} <li>
{% blocktrans with media_format=transcode.media_format quality=transcode.quality %}{{ media_format }} ({{ quality }} quality){% endblocktrans %}
{% if transcode.processing %}
<span class='processing'>{% trans "(Processing... hold tight)" %} </span>
{% endif %}
{% if transcode.error_message %}
<span class='transcode-error'>{% trans "ERROR:" %}</span>
<div class='transcode-error'>
<pre> {{ transcode.error_message }}</pre>
</div>
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
<h3 class="u-text-transform-uppercase">{% trans "Create transcode" %}</h3>
<form action="{% url 'wagtailvideos:create_transcode' video.id %}" method="POST">
<ul class="fields">
{% csrf_token %}
{% include "wagtailadmin/shared/field_as_li.html" with field=transcode_form.media_format li_classes="label-above label-uppercase" %}
{% include "wagtailadmin/shared/field_as_li.html" with field=transcode_form.quality li_classes="label-above label-uppercase" %}
<li> <li>
{% blocktrans with media_format=transcode.media_format quality=transcode.quality %}{{ media_format }} ({{ quality }} quality){% endblocktrans %} <input class="button" type='submit' value="{% trans 'Start' %}" />
{% if transcode.processing %}
<span class='processing'>{% trans "(Processing... hold tight)" %} </span>
{% endif %}
{% if transcode.error_message %}
<span class='transcode-error'>{% trans "ERROR:" %}</span>
<div class='transcode-error'>
<pre> {{ transcode.error_message }}</pre>
</div>
{% endif %}
</li> </li>
{% endfor %}
</ul> </ul>
{% endif %} </form>
<h3 class="u-text-transform-uppercase">{% trans "Create transcode" %}</h3> {% else %}
<form action="{% url 'wagtailvideos:create_transcode' video.id %}" method="POST"> <br/><br/>
<ul class="fields"> <span class='transcode-error'>{% trans "Ffmpeg is not found on your server. Please install if you wish to transcode videos into an HTML5 video compliant format." %}</span>
{% csrf_token %} {% endif %}
{% include "wagtailadmin/shared/field_as_li.html" with field=transcode_form.media_format li_classes="label-above label-uppercase" %}
{% include "wagtailadmin/shared/field_as_li.html" with field=transcode_form.quality li_classes="label-above label-uppercase" %}
<li>
<input class="button" type='submit' value="{% trans 'Start' %}" />
</li>
</ul>
</form>
{% else %}
<br/><br/>
<span class='transcode-error'>{% trans "Ffmpeg is not found on your server. Please install if you wish to transcode videos into an HTML5 video compliant format." %}</span>
{% endif %}
{% endblock %}
{% if tracks_action_url %} {% if tracks_action_url %}
<h2 class="u-text-transform-uppercase">{% trans "Tracks" %}</h2> <h2 class="u-text-transform-uppercase">{% trans "Tracks" %}</h2>
<p>{% trans 'You can add/edit subtitles or accessibility captions for this video. For information about the filetype that should be used see the mozilla docs on <a href="https://developer.mozilla.org/en-US/docs/Web/API/WebVTT_API">WebVTT</a>' %}</p> <p>{% trans 'You can add/edit subtitles or accessibility captions for this video. For information about the filetype that should be used see the mozilla docs on <a href="https://developer.mozilla.org/en-US/docs/Web/API/WebVTT_API">WebVTT</a>' %}</p>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment