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
6c4e4e85
Commit
6c4e4e85
authored
Nov 28, 2017
by
muhammad-ammar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
address feedback
parent
ab1e81ba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
16 deletions
+20
-16
cms/djangoapps/contentstore/views/tests/test_transcripts.py
+8
-4
cms/djangoapps/contentstore/views/transcripts_ajax.py
+12
-12
No files found.
cms/djangoapps/contentstore/views/tests/test_transcripts.py
View file @
6c4e4e85
...
...
@@ -135,17 +135,21 @@ class TestUploadTranscripts(BaseTranscripts):
self
.
ufeff_srt_file
=
tempfile
.
NamedTemporaryFile
(
suffix
=
'.srt'
)
def
assert_transcript_upload
(
self
,
filename
,
expected_transcript_content
):
def
assert_transcript_upload
(
self
,
subs_id
,
expected_transcript_content
):
"""
Verify that transcript is uploaded as expected
Verify that transcript is uploaded as expected.
Arguments:
subs_id (str): subtitle id
expected_transcript_content (str): transcript content be checked
"""
# verify that transcript should not be in contentstore
content_location
=
StaticContent
.
compute_location
(
self
.
course
.
id
,
'subs_{0}.srt.sjson'
.
format
(
filename
))
content_location
=
StaticContent
.
compute_location
(
self
.
course
.
id
,
'subs_{0}.srt.sjson'
.
format
(
subs_id
))
with
self
.
assertRaises
(
NotFoundError
):
contentstore
()
.
find
(
content_location
)
# verify uploaded transcript content
transcript_data
=
edxval_api
.
get_video_transcript_data
([
filename
],
'en'
)
transcript_data
=
edxval_api
.
get_video_transcript_data
([
subs_id
],
'en'
)
sjson_transcript
=
transcript_data
[
'content'
]
uploaded_transcript_content
=
transcripts_utils
.
Transcript
.
convert
(
sjson_transcript
,
...
...
cms/djangoapps/contentstore/views/transcripts_ajax.py
View file @
6c4e4e85
...
...
@@ -11,15 +11,16 @@ import logging
import
os
import
requests
from
django.conf
import
settings
from
django.contrib.auth.decorators
import
login_required
from
django.core.exceptions
import
PermissionDenied
from
django.core.files.base
import
ContentFile
from
django.http
import
Http404
,
HttpResponse
from
django.utils.translation
import
ugettext
as
_
from
edxval
import
api
as
edxval_api
from
opaque_keys
import
InvalidKeyError
from
opaque_keys.edx.keys
import
UsageKey
from
student.auth
import
has_course_author_access
from
util.json_request
import
JsonResponse
from
xmodule.contentstore.content
import
StaticContent
...
...
@@ -28,20 +29,19 @@ from xmodule.exceptions import NotFoundError
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
from
xmodule.video_module.transcripts_utils
import
(
GetTranscriptsFromYouTubeException
,
Transcript
,
TranscriptsRequestValidationException
,
copy_or_rename_transcript
,
download_youtube_subs
,
GetTranscriptsFromYouTubeException
,
get_video_transcript_content
,
generate_subs_from_source
,
get_transcripts_from_youtube
,
get_video_transcript_content
,
is_val_transcript_feature_enabled_for_course
,
manage_video_subtitles_save
,
remove_subs_from_store
,
Transcript
,
TranscriptsRequestValidationException
,
youtube_video_transcript_name
,
youtube_video_transcript_name
)
from
edxval
import
api
as
edxval_api
__all__
=
[
'upload_transcripts'
,
...
...
@@ -125,20 +125,20 @@ def upload_transcripts(request):
sjson_subs
=
generate_subs_from_source
({},
source_subs_ext
,
source_subs_filedata
,
item
)
for
video_dict
in
video_list
:
video_
name
=
video_dict
[
'video'
]
video_
id
=
video_dict
[
'video'
]
# We are creating transcripts for every video source in case a video source is deleted in future.
edxval_api
.
create_or_update_video_transcript
(
video_id
=
video_
name
,
video_id
=
video_
id
,
language_code
=
'en'
,
file_name
=
'subs.sjson'
,
# S3 filename will be `
uuid.sjson` like 5d30d3e44c
ebacf6163976388cae.sjson
file_name
=
'subs.sjson'
,
# S3 filename will be `
{uuid}.sjson` like 5d30d3eh
ebacf6163976388cae.sjson
file_format
=
'sjson'
,
provider
=
'Custom'
,
file_data
=
ContentFile
(
json
.
dumps
(
sjson_subs
)),
)
item
.
sub
=
video_
name
item
.
sub
=
video_
id
item
.
save_with_metadata
(
request
.
user
)
response
[
'subs'
]
=
video_
name
response
[
'subs'
]
=
video_
id
response
[
'status'
]
=
'Success'
except
Exception
as
ex
:
return
error_response
(
response
,
ex
.
message
)
...
...
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