Skip to content

Commit

Permalink
feat: Updated code to get english transcript from filename
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisChV committed Jan 15, 2025
1 parent 3885dd1 commit a723e96
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions xmodule/video_block/transcripts_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,26 @@ def get_transcript_from_contentstore(video, language, output_format, transcripts
except (KeyError, NotFoundError):
continue

if transcript_content is None and language == 'en':
# `get_transcript_for_video`` can get the transcript using just the filename,
# but in the above loop the filename from 'en' is overwritten.
#
# If it doesn't yet have the transcription and the language is 'en',
# check again but this time using the original filename.
#
# The use case for which this has been implemented is when copying a video from
# a library and pasting it into a course.
# The asset is copied, but we only have the filename to obtain the content.
try:
input_format, base_name, transcript_content = get_transcript_for_video(
video.location,
subs_id=sub_id,
file_name=other_languages['en'],
language=language
)
except (KeyError, NotFoundError):
pass

if transcript_content is None:
raise NotFoundError('No transcript for `{lang}` language'.format(
lang=language
Expand Down

0 comments on commit a723e96

Please sign in to comment.