Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
25d48209
Commit
25d48209
authored
Nov 07, 2012
by
Carlos Andrés Rocha
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #955 from MITx/louis/srt_downloads
Add support for subtitle download link
parents
27cffb93
b1cfee45
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
common/lib/xmodule/xmodule/video_module.py
+18
-4
lms/templates/video.html
+6
-0
No files found.
common/lib/xmodule/xmodule/video_module.py
View file @
25d48209
...
@@ -32,6 +32,7 @@ class VideoModule(XModule):
...
@@ -32,6 +32,7 @@ class VideoModule(XModule):
self
.
position
=
0
self
.
position
=
0
self
.
show_captions
=
xmltree
.
get
(
'show_captions'
,
'true'
)
self
.
show_captions
=
xmltree
.
get
(
'show_captions'
,
'true'
)
self
.
source
=
self
.
_get_source
(
xmltree
)
self
.
source
=
self
.
_get_source
(
xmltree
)
self
.
track
=
self
.
_get_track
(
xmltree
)
if
instance_state
is
not
None
:
if
instance_state
is
not
None
:
state
=
json
.
loads
(
instance_state
)
state
=
json
.
loads
(
instance_state
)
...
@@ -40,13 +41,25 @@ class VideoModule(XModule):
...
@@ -40,13 +41,25 @@ class VideoModule(XModule):
def
_get_source
(
self
,
xmltree
):
def
_get_source
(
self
,
xmltree
):
# find the first valid source
# find the first valid source
source
=
None
return
self
.
_get_first_external
(
xmltree
,
'source'
)
for
element
in
xmltree
.
findall
(
'source'
):
def
_get_track
(
self
,
xmltree
):
# find the first valid track
return
self
.
_get_first_external
(
xmltree
,
'track'
)
def
_get_first_external
(
self
,
xmltree
,
tag
):
"""
Will return the first valid element
of the given tag.
'valid' means has a non-empty 'src' attribute
"""
result
=
None
for
element
in
xmltree
.
findall
(
tag
):
src
=
element
.
get
(
'src'
)
src
=
element
.
get
(
'src'
)
if
src
:
if
src
:
source
=
src
result
=
src
break
break
return
source
return
result
def
handle_ajax
(
self
,
dispatch
,
get
):
def
handle_ajax
(
self
,
dispatch
,
get
):
'''
'''
...
@@ -85,6 +98,7 @@ class VideoModule(XModule):
...
@@ -85,6 +98,7 @@ class VideoModule(XModule):
'id'
:
self
.
location
.
html_id
(),
'id'
:
self
.
location
.
html_id
(),
'position'
:
self
.
position
,
'position'
:
self
.
position
,
'source'
:
self
.
source
,
'source'
:
self
.
source
,
'track'
:
self
.
track
,
'display_name'
:
self
.
display_name
,
'display_name'
:
self
.
display_name
,
# TODO (cpennington): This won't work when we move to data that isn't on the filesystem
# TODO (cpennington): This won't work when we move to data that isn't on the filesystem
'data_dir'
:
self
.
metadata
[
'data_dir'
],
'data_dir'
:
self
.
metadata
[
'data_dir'
],
...
...
lms/templates/video.html
View file @
25d48209
...
@@ -18,3 +18,9 @@
...
@@ -18,3 +18,9 @@
<p>
Download video
<a
href=
"${source}"
>
here
</a>
.
</p>
<p>
Download video
<a
href=
"${source}"
>
here
</a>
.
</p>
</div>
</div>
% endif
% endif
% if track:
<div
class=
"video-tracks"
>
<p>
Download subtitles
<a
href=
"${track}"
>
here
</a>
.
</p>
</div>
% endif
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