From e4eac68e9f1d95f180e00085baea8b2dc8770653 Mon Sep 17 00:00:00 2001 From: Braden MacDonald Date: Sun, 15 Dec 2019 12:17:00 -0800 Subject: [PATCH] Support transcript files for video XBlocks in Blockstore --- .../xmodule/video_module/transcripts_utils.py | 87 +++++++++++++++++-- .../tests/test_static_assets.py | 56 ++++++++++++ 2 files changed, 136 insertions(+), 7 deletions(-) diff --git a/common/lib/xmodule/xmodule/video_module/transcripts_utils.py b/common/lib/xmodule/xmodule/video_module/transcripts_utils.py index 5009feb497..710b9296b8 100644 --- a/common/lib/xmodule/xmodule/video_module/transcripts_utils.py +++ b/common/lib/xmodule/xmodule/video_module/transcripts_utils.py @@ -20,10 +20,12 @@ from six import text_type from six.moves import range, zip from six.moves.html_parser import HTMLParser # pylint: disable=import-error -from opaque_keys.edx.locator import CourseLocator, LibraryLocator +from opaque_keys.edx.locator import BundleDefinitionLocator from xmodule.contentstore.content import StaticContent from xmodule.contentstore.django import contentstore from xmodule.exceptions import NotFoundError +from openedx.core.djangolib import blockstore_cache +from openedx.core.lib import blockstore_api from .bumper_utils import get_bumper_settings @@ -994,6 +996,77 @@ def get_transcript_from_contentstore(video, language, output_format, transcripts return transcript_content, transcript_name, Transcript.mime_types[output_format] +def get_transcript_from_blockstore(video_block, language, output_format, transcripts_info): + """ + Get video transcript from Blockstore. + + Blockstore expects video transcripts to be placed into the 'static/' + subfolder of the XBlock's folder in a Blockstore bundle. For example, if the + video XBlock's definition is in the standard location of + video/video1/definition.xml + Then the .srt files should be placed at e.g. + video/video1/static/video1-en.srt + This is the same place where other public static files are placed for other + XBlocks, such as image files used by HTML blocks. + + Video XBlocks in Blockstore must set the 'transcripts' XBlock field to a + JSON dictionary listing the filename of the transcript for each language: +