subtitles: Add documentation, limit uploads to *.vtt files, only show for video ...
authorBen Sturmfels <ben@sturm.com.au>
Thu, 30 Apr 2020 01:38:44 +0000 (11:38 +1000)
committerBen Sturmfels <ben@sturm.com.au>
Thu, 30 Apr 2020 02:05:47 +0000 (12:05 +1000)
docs/source/index.rst
mediagoblin/plugins/subtitles/README.rst [new file with mode: 0644]
mediagoblin/plugins/subtitles/forms.py
mediagoblin/plugins/subtitles/templates/mediagoblin/plugins/subtitles/subtitle_media_block.html
mediagoblin/plugins/subtitles/views.py

index fbc57154187dff4cc8a1bddac56c75bdf7d88e77..b13968a5e8f7731b4a656865438e579958069d69 100644 (file)
@@ -55,14 +55,15 @@ Part 2: Core plugin documentation
 .. toctree::
    :maxdepth: 1
 
-   plugindocs/flatpagesfile
-   plugindocs/sampleplugin
-   plugindocs/trim_whitespace
-   plugindocs/raven
    plugindocs/basic_auth
+   plugindocs/flatpagesfile
+   plugindocs/ldap
    plugindocs/openid
    plugindocs/persona
-   plugindocs/ldap
+   plugindocs/raven
+   plugindocs/sampleplugin
+   plugindocs/subtitles
+   plugindocs/trim_whitespace
 
 
 Part 3: Plugin Writer's Guide
diff --git a/mediagoblin/plugins/subtitles/README.rst b/mediagoblin/plugins/subtitles/README.rst
new file mode 100644 (file)
index 0000000..c45b6c2
--- /dev/null
@@ -0,0 +1,25 @@
+================
+Subtitles plugin
+================
+
+This plugin enables text captioning of videos (though not yet audio). Once the
+plugin is enabled, you'll see a link to upload subtitles in `WebVTT format`_ as
+supported by the Video.js `Text Tracks`_ feature.
+
+.. _WebVTT format: https://en.wikipedia.org/wiki/WebVTT
+.. _Text Tracks: https://docs.videojs.com/docs/guides/text-tracks.html
+
+.. _subtitles-setup:
+
+Enabling the subtitles plugin
+=============================
+
+1. Add the following to your MediaGoblin .ini file in the ``[plugins]`` section::
+
+    [[mediagoblin.plugins.subtitles]]
+
+2. Run::
+
+    $ ./bin/gmg dbupdate
+
+3. Restart your MediaGoblin process.
index de8ffbcd51c809c4d749a38c2839c16fcfd59853..acf2af31c5f33b4b3b82d48fc1f4224ee6025717 100644 (file)
 
 import wtforms
 
+from mediagoblin.tools.translate import lazy_pass_to_ugettext as _
+
 class CustomizeSubtitlesForm(wtforms.Form):
     subtitle = wtforms.TextAreaField(
         ('Subtitle'),
         [wtforms.validators.Optional()],
-        description=(""))
+        description=_('Subtitles in <a href="https://en.wikipedia.org/wiki/WebVTT" target="_blank">WebVTT format</a>'))
 
 class EditSubtitlesForm(wtforms.Form):
     subtitle_language = wtforms.StringField(
         'Language')
     subtitle_file = wtforms.FileField(
-        'File')
+        'File',
+        description=_('Subtitles in <a href="https://en.wikipedia.org/wiki/WebVTT" target="_blank">WebVTT format</a>'))
index 7426c9718fcda98229505860587e4c7be973dd51..4d4a203b0c90024e0740df1a9d2fcd7cf867b27f 100644 (file)
@@ -17,7 +17,7 @@
 #}
 
 {% block subtitle_block %}
-{% if "video.html" in media.media_manager.display_template or "audio.html" in media.media_manager.display_template %}
+{% if "video.html" in media.media_manager.display_template %}
       {%- if media.subtitle_files|count %}
         <h3>{% trans %}Subtitles{% endtrans %}</h3>
         <ul>
index 46b844af08d8fc71b952bf63f75278214433c4f3..e3375306b81919beb6a1e17fdbfe4a060934f0bb 100644 (file)
@@ -45,8 +45,10 @@ UNSAFE_MIMETYPES = [
 @user_may_delete_media
 @require_active_login
 def edit_subtitles(request, media):
-    allowed_extensions = ['aqt','gsub','jss','sub','ttxt','pjs','psb',
-                        'rt','smi','stl','ssf','srt','ssa','ass','usf','vtt','lrc']
+    # This was originally quite a long list of allowed extensions, but as far as
+    # I understand, Video.js only supports WebVTT format subtitles:
+    # https://docs.videojs.com/docs/guides/text-tracks.html
+    allowed_extensions = ['vtt']
     form = forms.EditSubtitlesForm(request.form)
 
     # Add any subtitles