diff --git a/xmodule/video_block/transcripts_utils.py b/xmodule/video_block/transcripts_utils.py index bb97e331ef45..75086d84ba79 100644 --- a/xmodule/video_block/transcripts_utils.py +++ b/xmodule/video_block/transcripts_utils.py @@ -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