Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-val
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-val
Commits
8c24c786
Commit
8c24c786
authored
Sep 19, 2017
by
Qubad786
Committed by
muzaffaryousaf
Oct 12, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Api util to get available transcript languages.
parent
4855051e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
edxval/api.py
+19
-0
edxval/tests/test_api.py
+14
-0
No files found.
edxval/api.py
View file @
8c24c786
...
@@ -223,6 +223,25 @@ def get_video_transcript_data(video_ids, language_code):
...
@@ -223,6 +223,25 @@ def get_video_transcript_data(video_ids, language_code):
return
transcript_data
return
transcript_data
def
get_available_transcript_languages
(
video_ids
):
"""
Get available transcript languages
Arguments:
video_ids(list): list containing edx_video_id and external video ids extracted from
external sources of a video component.
Returns:
A list containing unique transcript language codes for the video ids.
"""
available_languages
=
VideoTranscript
.
objects
.
filter
(
video_id__in
=
video_ids
)
.
values_list
(
'language_code'
,
flat
=
True
)
return
list
(
set
(
available_languages
))
def
get_video_transcript_url
(
video_id
,
language_code
):
def
get_video_transcript_url
(
video_id
,
language_code
):
"""
"""
Returns course video transcript url or None if no transcript
Returns course video transcript url or None if no transcript
...
...
edxval/tests/test_api.py
View file @
8c24c786
...
@@ -1936,6 +1936,20 @@ class TranscriptTest(TestCase):
...
@@ -1936,6 +1936,20 @@ class TranscriptTest(TestCase):
self
.
assertEqual
(
file_open_exception
.
exception
.
strerror
,
u'No such file or directory'
)
self
.
assertEqual
(
file_open_exception
.
exception
.
strerror
,
u'No such file or directory'
)
def
test_get_available_transcript_languages
(
self
):
"""
Verify that `get_available_transcript_languages` works as expected.
"""
dupe_lang_video_id
=
'duplicate_lang_video'
VideoTranscript
.
objects
.
create
(
**
dict
(
constants
.
VIDEO_TRANSCRIPT_CIELO24
,
video_id
=
dupe_lang_video_id
))
# `super-soaker` has got 'en' and 'de' transcripts
# `self.video_id` has got 'ur' transcript
# `duplicate_lang_video` has got 'en' transcript
# `non_existent_video_id` that does not have transcript
video_ids
=
[
'super-soaker'
,
self
.
video_id
,
dupe_lang_video_id
,
'non_existent_video_id'
]
transcript_languages
=
api
.
get_available_transcript_languages
(
video_ids
=
video_ids
)
self
.
assertItemsEqual
(
transcript_languages
,
[
'de'
,
'en'
,
'ur'
])
@ddt
@ddt
class
TranscriptPreferencesTest
(
TestCase
):
class
TranscriptPreferencesTest
(
TestCase
):
...
...
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