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
2203de4a
Commit
2203de4a
authored
Sep 13, 2017
by
muhammad-ammar
Committed by
muzaffaryousaf
Oct 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
video ids info
parent
17e87f87
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
0 deletions
+64
-0
cms/djangoapps/contentstore/tests/test_transcripts_utils.py
+41
-0
common/lib/xmodule/xmodule/video_module/transcripts_utils.py
+23
-0
No files found.
cms/djangoapps/contentstore/tests/test_transcripts_utils.py
View file @
2203de4a
...
@@ -4,6 +4,7 @@ import copy
...
@@ -4,6 +4,7 @@ import copy
import
textwrap
import
textwrap
import
unittest
import
unittest
from
uuid
import
uuid4
from
uuid
import
uuid4
import
ddt
from
django.conf
import
settings
from
django.conf
import
settings
from
django.test.utils
import
override_settings
from
django.test.utils
import
override_settings
...
@@ -643,3 +644,43 @@ class TestSubsFilename(unittest.TestCase):
...
@@ -643,3 +644,43 @@ class TestSubsFilename(unittest.TestCase):
self
.
assertEqual
(
name
,
u'subs_˙∆©ƒƒƒ.srt.sjson'
)
self
.
assertEqual
(
name
,
u'subs_˙∆©ƒƒƒ.srt.sjson'
)
name
=
transcripts_utils
.
subs_filename
(
u"˙∆©ƒƒƒ"
,
'uk'
)
name
=
transcripts_utils
.
subs_filename
(
u"˙∆©ƒƒƒ"
,
'uk'
)
self
.
assertEqual
(
name
,
u'uk_subs_˙∆©ƒƒƒ.srt.sjson'
)
self
.
assertEqual
(
name
,
u'uk_subs_˙∆©ƒƒƒ.srt.sjson'
)
@ddt.ddt
class
TestVideoIdsInfo
(
unittest
.
TestCase
):
"""
Tests for `get_video_ids_info`.
"""
@ddt.data
(
{
'edx_video_id'
:
'000-000-000'
,
'youtube_id_1_0'
:
'12as34'
,
'html5_sources'
:
[
'www.abc.com/foo.mp4'
,
'www.abc.com/bar.webm'
,
'foo/bar/baz.m3u8'
],
'expected_result'
:
(
False
,
[
'000-000-000'
,
'12as34'
,
'foo'
,
'bar'
,
'baz'
])
},
{
'edx_video_id'
:
''
,
'youtube_id_1_0'
:
'12as34'
,
'html5_sources'
:
[
'www.abc.com/foo.mp4'
,
'www.abc.com/bar.webm'
,
'foo/bar/baz.m3u8'
],
'expected_result'
:
(
True
,
[
'12as34'
,
'foo'
,
'bar'
,
'baz'
])
},
{
'edx_video_id'
:
''
,
'youtube_id_1_0'
:
''
,
'html5_sources'
:
[
'www.abc.com/foo.mp4'
,
'www.abc.com/bar.webm'
,
],
'expected_result'
:
(
True
,
[
'foo'
,
'bar'
])
},
)
@ddt.unpack
def
test_get_video_ids_info
(
self
,
edx_video_id
,
youtube_id_1_0
,
html5_sources
,
expected_result
):
"""
Verify that `get_video_ids_info` works as expected.
"""
actual_result
=
transcripts_utils
.
get_video_ids_info
(
edx_video_id
,
youtube_id_1_0
,
html5_sources
)
self
.
assertEqual
(
actual_result
,
expected_result
)
common/lib/xmodule/xmodule/video_module/transcripts_utils.py
View file @
2203de4a
...
@@ -469,6 +469,29 @@ def get_or_create_sjson(item, transcripts):
...
@@ -469,6 +469,29 @@ def get_or_create_sjson(item, transcripts):
return
sjson_transcript
return
sjson_transcript
def
get_video_ids_info
(
edx_video_id
,
youtube_id_1_0
,
html5_sources
):
"""
Returns list internal or external video ids.
Arguments:
edx_video_id (str): edx_video_id
youtube_id_1_0 (str): youtube id
html5_sources (list): html5 video ids
Returns:
tuple: external or internal, video ids list
"""
clean
=
lambda
item
:
item
.
strip
()
if
isinstance
(
item
,
basestring
)
else
item
external
=
not
bool
(
clean
(
edx_video_id
))
video_ids
=
[
edx_video_id
,
youtube_id_1_0
]
+
get_html5_ids
(
html5_sources
)
# video_ids cleanup
video_ids
=
filter
(
lambda
item
:
bool
(
clean
(
item
)),
video_ids
)
return
external
,
video_ids
class
Transcript
(
object
):
class
Transcript
(
object
):
"""
"""
Container for transcript methods.
Container for transcript methods.
...
...
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