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
4c074f11
Commit
4c074f11
authored
May 09, 2017
by
Qubad786
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Override video url with edx val encodings
parent
74f9858b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
3 deletions
+88
-3
common/lib/xmodule/xmodule/video_module/video_module.py
+25
-3
lms/djangoapps/courseware/tests/test_video_mongo.py
+63
-0
No files found.
common/lib/xmodule/xmodule/video_module/video_module.py
View file @
4c074f11
...
...
@@ -701,10 +701,32 @@ class VideoDescriptor(VideoFields, VideoTranscriptsMixin, VideoStudioViewHandler
'default_value'
:
[
get_youtube_link
(
youtube_id_1_0
[
'default_value'
])]
})
youtube_id_1_0_value
=
get_youtube_link
(
youtube_id_1_0
[
'value'
])
source_url
=
self
.
create_youtube_url
(
youtube_id_1_0
[
'value'
])
if
youtube_id_1_0_value
:
video_url
[
'value'
]
.
insert
(
0
,
youtube_id_1_0_value
)
# First try a lookup in VAL. If any video encoding is found given the video id then
# override the source_url with it.
if
self
.
edx_video_id
and
edxval_api
:
val_profiles
=
[
'youtube'
,
'desktop_webm'
,
'desktop_mp4'
]
if
HLSPlaybackEnabledFlag
.
feature_enabled
(
self
.
runtime
.
course_id
.
for_branch
(
None
)):
val_profiles
.
append
(
'hls'
)
# Get video encodings for val profiles.
val_video_encodings
=
edxval_api
.
get_urls_for_profiles
(
self
.
edx_video_id
,
val_profiles
)
# If multiple encodings are there in val, the priority will be: youtube > hls > mp4 and webm.
if
val_video_encodings
.
get
(
'youtube'
):
source_url
=
self
.
create_youtube_url
(
val_video_encodings
[
'youtube'
])
elif
val_video_encodings
.
get
(
'hls'
):
source_url
=
val_video_encodings
[
'hls'
]
elif
val_video_encodings
.
get
(
'desktop_mp4'
):
source_url
=
val_video_encodings
[
'desktop_mp4'
]
elif
val_video_encodings
.
get
(
'desktop_webm'
):
source_url
=
val_video_encodings
[
'desktop_webm'
]
# Only add if html5 sources do not already contain source_url.
if
source_url
and
source_url
not
in
video_url
[
'value'
]:
video_url
[
'value'
]
.
insert
(
0
,
source_url
)
metadata
=
{
'display_name'
:
display_name
,
...
...
lms/djangoapps/courseware/tests/test_video_mongo.py
View file @
4c074f11
...
...
@@ -982,6 +982,7 @@ class TestVideoCDNRewriting(BaseTestXmodule):
@attr
(
shard
=
1
)
@ddt.ddt
class
TestVideoDescriptorInitialization
(
BaseTestXmodule
):
"""
Make sure that module initialization works correctly.
...
...
@@ -1051,6 +1052,68 @@ class TestVideoDescriptorInitialization(BaseTestXmodule):
self
.
assertNotIn
(
'source'
,
fields
)
self
.
assertFalse
(
self
.
item_descriptor
.
download_video
)
@ddt.data
(
(
{
'desktop_webm'
:
'https://webm.com/dw.webm'
,
'hls'
:
'https://hls.com/hls.m3u8'
,
'youtube'
:
'v0TFmdO4ZP0'
,
'desktop_mp4'
:
'https://mp4.com/dm.mp4'
},
[
'https://www.youtube.com/watch?v=v0TFmdO4ZP0'
]
),
(
{
'desktop_webm'
:
'https://webm.com/dw.webm'
,
'hls'
:
'https://hls.com/hls.m3u8'
,
'youtube'
:
None
,
'desktop_mp4'
:
'https://mp4.com/dm.mp4'
},
[
'https://hls.com/hls.m3u8'
]
),
(
{
'desktop_webm'
:
'https://webm.com/dw.webm'
,
'hls'
:
None
,
'youtube'
:
None
,
'desktop_mp4'
:
'https://mp4.com/dm.mp4'
},
[
'https://mp4.com/dm.mp4'
]
),
(
{
'desktop_webm'
:
'https://webm.com/dw.webm'
,
'hls'
:
None
,
'youtube'
:
None
,
'desktop_mp4'
:
None
},
[
'https://webm.com/dw.webm'
]
),
(
{
'desktop_webm'
:
None
,
'hls'
:
None
,
'youtube'
:
None
,
'desktop_mp4'
:
None
},
[
'https://www.youtube.com/watch?v=3_yD_cEKoCk'
]
),
)
@ddt.unpack
@patch
(
'xmodule.video_module.video_module.HLSPlaybackEnabledFlag.feature_enabled'
,
Mock
(
return_value
=
True
))
def
test_val_encoding_in_context
(
self
,
val_video_encodings
,
video_url
):
"""
Tests that the val encodings correctly override the video url when the edx video id is set and
one or more encodings are present.
"""
with
patch
(
'xmodule.video_module.video_module.edxval_api.get_urls_for_profiles'
)
as
get_urls_for_profiles
:
get_urls_for_profiles
.
return_value
=
val_video_encodings
self
.
initialize_module
(
data
=
'<video display_name="Video" download_video="true" edx_video_id="12345-67890">[]</video>'
)
context
=
self
.
item_descriptor
.
get_context
()
self
.
assertEqual
(
context
[
'transcripts_basic_tab_metadata'
][
'video_url'
][
'value'
],
video_url
)
@attr
(
shard
=
1
)
@ddt.ddt
...
...
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