diff --git a/openedx/core/djangoapps/video_config/services.py b/openedx/core/djangoapps/video_config/services.py index 3e311cf77944..e46d575e9542 100644 --- a/openedx/core/djangoapps/video_config/services.py +++ b/openedx/core/djangoapps/video_config/services.py @@ -123,6 +123,7 @@ def get_transcript( lang: str | None = None, output_format: str = 'srt', youtube_id: str | None = None, + is_bumper=False, ) -> tuple[bytes, str, str]: """ Retrieve a transcript from the runtime's storage. @@ -135,7 +136,7 @@ def get_transcript( TranscriptNotFoundError: If the transcript cannot be found or retrieved """ try: - return get_transcript(video_block, lang, output_format, youtube_id) + return get_transcript(video_block, lang, output_format, youtube_id, is_bumper) except NotFoundError as exc: raise TranscriptNotFoundError( f"Failed to get transcript: {exc}" diff --git a/openedx/core/djangoapps/video_config/transcripts_utils.py b/openedx/core/djangoapps/video_config/transcripts_utils.py index 2ad873930e74..15cae30a2f62 100644 --- a/openedx/core/djangoapps/video_config/transcripts_utils.py +++ b/openedx/core/djangoapps/video_config/transcripts_utils.py @@ -1049,7 +1049,7 @@ def get_transcript_from_learning_core(video_block, language, output_format, tran return output_transcript, output_filename, Transcript.mime_types[output_format] -def get_transcript(video, lang=None, output_format=Transcript.SRT, youtube_id=None): +def get_transcript(video, lang=None, output_format=Transcript.SRT, youtube_id=None, is_bumper=False): """ Get video transcript from edx-val or content store. @@ -1062,7 +1062,14 @@ def get_transcript(video, lang=None, output_format=Transcript.SRT, youtube_id=No Returns: tuple containing content, filename, mimetype """ - transcripts_info = video.get_transcripts_info() + transcripts_info = video.get_transcripts_info(is_bumper) + if is_bumper: + return get_transcript_from_contentstore( + video, + lang, + Transcript.SJSON, + transcripts_info + ) if not lang: lang = video.get_default_transcript_language(transcripts_info) diff --git a/xmodule/video_block/video_handlers.py b/xmodule/video_block/video_handlers.py index 41ae314d599e..8a4943b04f08 100644 --- a/xmodule/video_block/video_handlers.py +++ b/xmodule/video_block/video_handlers.py @@ -22,7 +22,6 @@ from openedx.core.djangoapps.video_config.transcripts_utils import ( Transcript, clean_video_id, - get_transcript_from_contentstore, subs_filename, ) from xblocks_contrib.video.exceptions import ( @@ -38,6 +37,7 @@ def get_transcript( lang: str | None = None, output_format: str = 'srt', youtube_id: str | None = None, + is_bumper: bool = False, ) -> tuple[bytes, str, str]: """ Retrieve a transcript using a video block's configuration service. @@ -51,7 +51,7 @@ def get_transcript( video_config_service = video_block.runtime.service(video_block, 'video_config') if not video_config_service: raise Exception("Video config service not found") - return video_config_service.get_transcript(video_block, lang, output_format, youtube_id) + return video_config_service.get_transcript(video_block, lang, output_format, youtube_id, is_bumper) # Disable no-member warning: @@ -276,21 +276,14 @@ def transcript(self, request, dispatch): self.transcript_language = language try: - if is_bumper: - content, filename, mimetype = get_transcript_from_contentstore( - self, - self.transcript_language, - Transcript.SJSON, - transcripts - ) - else: - content, filename, mimetype = get_transcript( - self, - lang=self.transcript_language, - output_format=Transcript.SJSON, - youtube_id=request.GET.get('videoId'), - ) - + youtube_id = None if is_bumper else request.GET.get('videoId') + content, filename, mimetype = get_transcript( + self, + lang=self.transcript_language, + output_format=Transcript.SJSON, + youtube_id=youtube_id, + is_bumper=is_bumper + ) response = self.make_transcript_http_response( content, filename, @@ -298,7 +291,7 @@ def transcript(self, request, dispatch): mimetype, add_attachment_header=False ) - except (NotFoundError, TranscriptNotFoundError) as exc: + except TranscriptNotFoundError as exc: edx_video_id = clean_video_id(self.edx_video_id) log.warning( '[Translation Dispatch] %s: %s',