Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Websites UFRPE
Wagtail Videos
Commits
e998fd3b
Commit
e998fd3b
authored
Aug 03, 2016
by
Seb
Browse files
Added ffmpeg check for edit screen, disabled transcoding if not there
parent
69785b13
Changes
3
Hide whitespace changes
Inline
Side-by-side
wagtailvideos/models.py
View file @
e998fd3b
...
@@ -28,6 +28,8 @@ from wagtail.wagtailcore.models import CollectionMember
...
@@ -28,6 +28,8 @@ from wagtail.wagtailcore.models import CollectionMember
from
wagtail.wagtailsearch
import
index
from
wagtail.wagtailsearch
import
index
from
wagtail.wagtailsearch.queryset
import
SearchableQuerySetMixin
from
wagtail.wagtailsearch.queryset
import
SearchableQuerySetMixin
from
wagtailvideos.utils
import
ffmpeg_installed
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -149,6 +151,9 @@ class AbstractVideo(CollectionMember, TagSearchable):
...
@@ -149,6 +151,9 @@ class AbstractVideo(CollectionMember, TagSearchable):
if
self
.
duration
:
if
self
.
duration
:
return
self
.
duration
return
self
.
duration
if
not
ffmpeg_installed
():
return
None
file_path
=
self
.
file
.
path
file_path
=
self
.
file
.
path
try
:
try
:
# FIXME prints out extra stuff on travis, pip stderr to dev/null
# FIXME prints out extra stuff on travis, pip stderr to dev/null
...
@@ -165,6 +170,9 @@ class AbstractVideo(CollectionMember, TagSearchable):
...
@@ -165,6 +170,9 @@ class AbstractVideo(CollectionMember, TagSearchable):
if
self
.
thumbnail
:
if
self
.
thumbnail
:
return
self
.
thumbnail
return
self
.
thumbnail
if
not
ffmpeg_installed
():
return
None
file_path
=
self
.
file
.
path
file_path
=
self
.
file
.
path
file_name
=
self
.
filename
(
include_ext
=
False
)
+
'_thumb.jpg'
file_name
=
self
.
filename
(
include_ext
=
False
)
+
'_thumb.jpg'
...
...
wagtailvideos/templates/wagtailvideos/videos/edit.html
View file @
e998fd3b
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
</div>
</div>
<div
class=
"col5 divider-after"
>
<div
class=
"col5 divider-after"
>
<h2
class=
"label"
>
{% trans "Video preview" %}
</h2>
{% video video controls style=max-width:100% %}
<h2
class=
"label"
>
{% trans "Video preview" %}
</h2>
{% video video controls style=max-width:100% %}
{% if can_transcode %}
<h3
class=
"label"
>
Transcodes
</h3>
<h3
class=
"label"
>
Transcodes
</h3>
<p>
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>
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 %}
...
@@ -53,15 +54,20 @@
...
@@ -53,15 +54,20 @@
</li>
</li>
</ul>
</ul>
</form>
</form>
{% endif %}
</div>
</div>
<div
class=
"col2 "
>
<div
class=
"col2 "
>
<dl>
<dl>
{% if video.thumbnail %}
<dt>
{% trans "Thumbnail" %}
</dt>
<dt>
{% trans "Thumbnail" %}
</dt>
<dd><img
src=
'{{ video.thumbnail.url }}'
/></dd>
<dd><img
src=
'{{ video.thumbnail.url }}'
/></dd>
{% endif %}
<dt>
{% trans "Filesize" %}
</dt>
<dt>
{% trans "Filesize" %}
</dt>
<dd>
{% if filesize %}{{ filesize|filesizeformat }}{% else %}{% trans "File not found" %}{% endif %}
</dd>
<dd>
{% if filesize %}{{ filesize|filesizeformat }}{% else %}{% trans "File not found" %}{% endif %}
</dd>
{% if video.duration %}
<dt>
{% trans "Duration" %}
</dt>
<dt>
{% trans "Duration" %}
</dt>
<dd>
{{ video.formatted_duration }}
</dd>
<dd>
{{ video.formatted_duration }}
</dd>
{% endif %}
</dl>
</dl>
</div>
</div>
</div>
</div>
...
...
wagtailvideos/views/videos.py
View file @
e998fd3b
...
@@ -17,6 +17,7 @@ from wagtail.wagtailsearch.backends import get_search_backends
...
@@ -17,6 +17,7 @@ from wagtail.wagtailsearch.backends import get_search_backends
from
wagtailvideos.forms
import
VideoTranscodeAdminForm
,
get_video_form
from
wagtailvideos.forms
import
VideoTranscodeAdminForm
,
get_video_form
from
wagtailvideos.models
import
Video
from
wagtailvideos.models
import
Video
from
wagtailvideos.permissions
import
permission_policy
from
wagtailvideos.permissions
import
permission_policy
from
wagtailvideos.utils
import
ffmpeg_installed
permission_checker
=
PermissionPolicyChecker
(
permission_policy
)
permission_checker
=
PermissionPolicyChecker
(
permission_policy
)
...
@@ -69,6 +70,7 @@ def index(request):
...
@@ -69,6 +70,7 @@ def index(request):
})
})
return
response
return
response
@
permission_checker
.
require
(
'change'
)
@
permission_checker
.
require
(
'change'
)
def
edit
(
request
,
video_id
):
def
edit
(
request
,
video_id
):
VideoForm
=
get_video_form
(
Video
)
VideoForm
=
get_video_form
(
Video
)
...
@@ -117,12 +119,12 @@ def edit(request, video_id):
...
@@ -117,12 +119,12 @@ def edit(request, video_id):
'video'
:
video
,
'video'
:
video
,
'form'
:
form
,
'form'
:
form
,
'filesize'
:
video
.
get_file_size
(),
'filesize'
:
video
.
get_file_size
(),
'can_transcode'
:
ffmpeg_installed
(),
'transcodes'
:
video
.
transcodes
.
all
(),
'transcodes'
:
video
.
transcodes
.
all
(),
'transcode_form'
:
VideoTranscodeAdminForm
(
video
=
video
),
'transcode_form'
:
VideoTranscodeAdminForm
(
video
=
video
),
'user_can_delete'
:
permission_policy
.
user_has_permission_for_instance
(
request
.
user
,
'delete'
,
video
)
'user_can_delete'
:
permission_policy
.
user_has_permission_for_instance
(
request
.
user
,
'delete'
,
video
)
})
})
def
create_transcode
(
request
,
video_id
):
def
create_transcode
(
request
,
video_id
):
if
request
.
method
!=
'POST'
:
if
request
.
method
!=
'POST'
:
return
HttpResponseNotAllowed
([
'POST'
])
return
HttpResponseNotAllowed
([
'POST'
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment