Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion openedx/core/djangoapps/video_config/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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}"
Expand Down
11 changes: 9 additions & 2 deletions openedx/core/djangoapps/video_config/transcripts_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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)

Expand Down
29 changes: 11 additions & 18 deletions xmodule/video_block/video_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -276,29 +276,22 @@ 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,
self.transcript_language,
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',
Expand Down
Loading