Merge pull request #32099 from open-craft/navin/fix-video-transcripts

This commit is contained in:
Edward Zarecor
2023-05-18 14:29:34 -04:00
committed by GitHub
4 changed files with 9 additions and 2 deletions

View File

@@ -256,6 +256,7 @@ class TestUploadTranscripts(BaseTranscripts):
expected_edx_video_id = edx_video_id if edx_video_id else json_response['edx_video_id']
video = modulestore().get_item(self.video_usage_key)
self.assertEqual(video.edx_video_id, expected_edx_video_id)
self.assertDictEqual(video.transcripts, {'en': f'{expected_edx_video_id}-en.srt'})
# Verify transcript content
actual_transcript = get_video_transcript_content(video.edx_video_id, language_code='en')
@@ -319,6 +320,8 @@ class TestUploadTranscripts(BaseTranscripts):
expected_status_code=400,
expected_message='There is a problem with this transcript file. Try to upload a different file.'
)
video = modulestore().get_item(self.video_usage_key)
self.assertDictEqual(video.transcripts, {})
def test_transcript_upload_unknown_category(self):
"""

View File

@@ -231,6 +231,8 @@ def upload_transcripts(request):
file_data=ContentFile(sjson_subs),
)
video.transcripts['en'] = f"{edx_video_id}-en.srt"
video.save_with_metadata(request.user)
if transcript_created is None:
response = JsonResponse({'status': 'Invalid Video ID'}, status=400)

View File

@@ -981,7 +981,7 @@ class TestStudioTranscriptTranslationPostDispatch(TestVideo): # lint-amnesty, p
assert response.status == '201 Created'
response = json.loads(response.text)
assert response['language_code'], 'uk'
self.assertDictEqual(self.block.transcripts, {})
self.assertDictEqual(self.block.transcripts, {'uk': f'{response["edx_video_id"]}-uk.srt'})
assert edxval_api.get_video_transcript_data(video_id=response['edx_video_id'], language_code='uk')
def test_studio_transcript_post_bad_content(self):
@@ -999,6 +999,8 @@ class TestStudioTranscriptTranslationPostDispatch(TestVideo): # lint-amnesty, p
response = self.block.studio_transcript(request=request, dispatch="translation")
assert response.status_code == 400
assert response.json['error'] == 'There is a problem with this transcript file. Try to upload a different file.'
# transcripts fields should not be updated
self.assertDictEqual(self.block.transcripts, {})
@ddt.ddt

View File

@@ -473,7 +473,6 @@ class VideoStudioViewHandlers:
`POST`:
Upload srt file. Check possibility of generation of proper sjson files.
For now, it works only for self.transcripts, not for `en`.
Do not update self.transcripts, as fields are updated on save in Studio.
`GET:
Return filename from storage. SRT format is sent back on success. Filename should be in GET dict.
@@ -529,6 +528,7 @@ class VideoStudioViewHandlers:
'edx_video_id': edx_video_id,
'language_code': new_language_code
}
self.transcripts[new_language_code] = f'{edx_video_id}-{new_language_code}.srt'
response = Response(json.dumps(payload), status=201)
except (TranscriptsGenerationException, UnicodeDecodeError):
response = Response(