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
610f43af
Commit
610f43af
authored
Dec 20, 2017
by
Qubad786
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EDUCATOR-1992 – Make transcript filenames human readable
parent
cd3d5f30
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
10 deletions
+42
-10
edxval/api.py
+1
-1
edxval/models.py
+22
-0
edxval/tests/constants.py
+1
-1
edxval/tests/data/wow.sjson
+6
-0
edxval/tests/test_api.py
+12
-8
No files found.
edxval/api.py
View file @
610f43af
...
@@ -247,7 +247,7 @@ def get_video_transcript_data(video_ids, language_code):
...
@@ -247,7 +247,7 @@ def get_video_transcript_data(video_ids, language_code):
try
:
try
:
video_transcript
=
VideoTranscript
.
objects
.
get
(
video_id
=
video_id
,
language_code
=
language_code
)
video_transcript
=
VideoTranscript
.
objects
.
get
(
video_id
=
video_id
,
language_code
=
language_code
)
transcript_data
=
dict
(
transcript_data
=
dict
(
file_name
=
video_transcript
.
transcript
.
name
,
file_name
=
video_transcript
.
file
name
,
content
=
video_transcript
.
transcript
.
file
.
read
()
content
=
video_transcript
.
transcript
.
file
.
read
()
)
)
break
break
...
...
edxval/models.py
View file @
610f43af
...
@@ -417,6 +417,28 @@ class VideoTranscript(TimeStampedModel):
...
@@ -417,6 +417,28 @@ class VideoTranscript(TimeStampedModel):
class
Meta
:
class
Meta
:
unique_together
=
(
'video_id'
,
'language_code'
)
unique_together
=
(
'video_id'
,
'language_code'
)
@property
def
filename
(
self
):
"""
Returns readable filename for a transcript
"""
try
:
video
=
Video
.
objects
.
get
(
edx_video_id
=
self
.
video_id
)
client_id
,
__
=
os
.
path
.
splitext
(
video
.
client_video_id
)
file_name
=
u'{name}-{language}.{format}'
.
format
(
name
=
client_id
,
language
=
self
.
language_code
,
format
=
self
.
file_format
)
except
Video
.
DoesNotExist
:
file_name
=
u'{name}-{language}.{format}'
.
format
(
name
=
self
.
video_id
,
language
=
self
.
language_code
,
format
=
self
.
file_format
)
return
file_name
@classmethod
@classmethod
def
get_or_none
(
cls
,
video_id
,
language_code
):
def
get_or_none
(
cls
,
video_id
,
language_code
):
"""
"""
...
...
edxval/tests/constants.py
View file @
610f43af
...
@@ -373,7 +373,7 @@ VIDEO_TRANSCRIPT_CIELO24 = dict(
...
@@ -373,7 +373,7 @@ VIDEO_TRANSCRIPT_CIELO24 = dict(
VIDEO_TRANSCRIPT_3PLAY
=
dict
(
VIDEO_TRANSCRIPT_3PLAY
=
dict
(
video_id
=
'super-soaker'
,
video_id
=
'super-soaker'
,
language_code
=
'de'
,
language_code
=
'de'
,
transcript
=
'wow.sjson'
,
transcript
=
'
edxval/tests/data/
wow.sjson'
,
provider
=
TranscriptProviderType
.
THREE_PLAY_MEDIA
,
provider
=
TranscriptProviderType
.
THREE_PLAY_MEDIA
,
file_format
=
TranscriptFormat
.
SJSON
,
file_format
=
TranscriptFormat
.
SJSON
,
)
)
...
...
edxval/tests/data/wow.sjson
0 → 100644
View file @
610f43af
{
"start": [10],
"end": [100],
"text": ["Hi, welcome to edxval."],
}
\ No newline at end of file
edxval/tests/test_api.py
View file @
610f43af
...
@@ -137,7 +137,6 @@ class CreateVideoTest(TestCase):
...
@@ -137,7 +137,6 @@ class CreateVideoTest(TestCase):
api
.
create_video
(
data
)
api
.
create_video
(
data
)
@ddt
@ddt
class
UpdateVideoTest
(
TestCase
):
class
UpdateVideoTest
(
TestCase
):
"""
"""
...
@@ -957,7 +956,7 @@ class ExportTest(TestCase):
...
@@ -957,7 +956,7 @@ class ExportTest(TestCase):
<encoded_video url="http://www.meowmagic.com" file_size="33" bitrate="44" profile="desktop"/>
<encoded_video url="http://www.meowmagic.com" file_size="33" bitrate="44" profile="desktop"/>
<encoded_video url="https://www.tmnt.com/tmnt101.m3u8" file_size="100" bitrate="0" profile="hls"/>
<encoded_video url="https://www.tmnt.com/tmnt101.m3u8" file_size="100" bitrate="0" profile="hls"/>
<transcripts>
<transcripts>
<transcript file_format="sjson" file_name="wow.sjson" language_code="de" provider="3PlayMedia" video_id="super-soaker"/>
<transcript file_format="sjson" file_name="
edxval/tests/data/
wow.sjson" language_code="de" provider="3PlayMedia" video_id="super-soaker"/>
<transcript file_format="srt" file_name="wow.srt" language_code="en" provider="Cielo24" video_id="super-soaker" />
<transcript file_format="srt" file_name="wow.srt" language_code="en" provider="Cielo24" video_id="super-soaker" />
</transcripts>
</transcripts>
</video_asset>
</video_asset>
...
@@ -1296,7 +1295,7 @@ class ImportTest(TestCase):
...
@@ -1296,7 +1295,7 @@ class ImportTest(TestCase):
<video_asset>
<video_asset>
<transcripts>
<transcripts>
<transcript file_name="wow.srt" language_code="en" file_format="srt" provider='Cielo24' video_id="{video_id}"/>
<transcript file_name="wow.srt" language_code="en" file_format="srt" provider='Cielo24' video_id="{video_id}"/>
<transcript file_name="wow.sjson" language_code="de" file_format="sjson" provider='3PlayMedia' video_id="{video_id}"/>
<transcript file_name="
edxval/tests/data/
wow.sjson" language_code="de" file_format="sjson" provider='3PlayMedia' video_id="{video_id}"/>
</transcripts>
</transcripts>
</video_asset>
</video_asset>
"""
.
format
(
video_id
=
external_video_id
))
"""
.
format
(
video_id
=
external_video_id
))
...
@@ -1328,7 +1327,7 @@ class ImportTest(TestCase):
...
@@ -1328,7 +1327,7 @@ class ImportTest(TestCase):
<video_asset>
<video_asset>
<transcripts>
<transcripts>
{transcript_xml}
{transcript_xml}
<transcript file_name="wow.sjson" language_code="de" file_format="sjson" provider='3PlayMedia' video_id="{video_id}"/>
<transcript file_name="
edxval/tests/data/
wow.sjson" language_code="de" file_format="sjson" provider='3PlayMedia' video_id="{video_id}"/>
</transcripts>
</transcripts>
</video_asset>
</video_asset>
"""
.
format
(
transcript_xml
=
transcript_xml
,
video_id
=
video_id
))
"""
.
format
(
transcript_xml
=
transcript_xml
,
video_id
=
video_id
))
...
@@ -1765,17 +1764,22 @@ class TranscriptTest(TestCase):
...
@@ -1765,17 +1764,22 @@ class TranscriptTest(TestCase):
transcript
=
api
.
get_video_transcript_data
(
video_ids
,
language_code
)
transcript
=
api
.
get_video_transcript_data
(
video_ids
,
language_code
)
self
.
assertEqual
(
transcript
,
result
)
self
.
assertEqual
(
transcript
,
result
)
def
test_get_video_transcript_data
(
self
):
@data
(
(
'de'
,
'Shallow Swordfish-de.sjson'
,
'edxval/tests/data/wow.sjson'
),
(
'ur'
,
'0987654321-ur.srt'
,
'edxval/tests/data/The_Arrow.srt'
)
)
@unpack
def
test_get_video_transcript_data
(
self
,
language_code
,
expected_file_name
,
expected_transcript_path
):
"""
"""
Verify that `get_video_transcript_data` api function works as expected.
Verify that `get_video_transcript_data` api function works as expected.
"""
"""
expected_transcript
=
{
expected_transcript
=
{
'file_name'
:
self
.
transcript_url
,
'file_name'
:
expected_file_name
,
'content'
:
File
(
open
(
self
.
arrow
_transcript_path
))
.
read
()
'content'
:
File
(
open
(
expected
_transcript_path
))
.
read
()
}
}
transcript
=
api
.
get_video_transcript_data
(
transcript
=
api
.
get_video_transcript_data
(
video_ids
=
[
'super-soaker'
,
'0987654321'
],
video_ids
=
[
'super-soaker'
,
'0987654321'
],
language_code
=
u'ur'
language_code
=
language_code
)
)
self
.
assertDictEqual
(
transcript
,
expected_transcript
)
self
.
assertDictEqual
(
transcript
,
expected_transcript
)
...
...
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