fix: fix transcript replacement

Fixed an issue where changing the transcript language code would
cause both the old and new transcript to be displayed.
But in this case, you won’t be able to download the transcript
from the old code, since the link is invalid.
This commit is contained in:
Dima Alipov
2024-04-08 10:55:15 +03:00
committed by Dmytro
parent a4d3bf91db
commit 911bf73c04

View File

@@ -467,6 +467,7 @@ class VideoStudioViewHandlers:
return error
# pylint: disable=too-many-statements
@XBlock.handler
def studio_transcript(self, request, dispatch):
"""
@@ -534,6 +535,10 @@ class VideoStudioViewHandlers:
'edx_video_id': edx_video_id,
'language_code': new_language_code
}
# If a new transcript is added, then both new_language_code and
# language_code fields will have the same value.
if language_code != new_language_code:
self.transcripts.pop(language_code, None)
self.transcripts[new_language_code] = f'{edx_video_id}-{new_language_code}.srt'
response = Response(json.dumps(payload), status=201)
except (TranscriptsGenerationException, UnicodeDecodeError):