Skip to content

Commit 6030df7

Browse files
committed
chore: code ++
1 parent e595356 commit 6030df7

File tree

1 file changed

+59
-67
lines changed

1 file changed

+59
-67
lines changed

xblocks_contrib/video/transcripts_utils.py

Lines changed: 59 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -621,32 +621,32 @@ def clean_video_id(edx_video_id):
621621
return edx_video_id and edx_video_id.strip()
622622

623623

624-
def get_video_transcript_content(edx_video_id, language_code):
625-
"""
626-
Gets video transcript content, only if the corresponding feature flag is enabled for the given `course_id`.
624+
# def get_video_transcript_content(edx_video_id, language_code):
625+
# """
626+
# Gets video transcript content, only if the corresponding feature flag is enabled for the given `course_id`.
627627

628-
Arguments:
629-
language_code(unicode): Language code of the requested transcript
630-
edx_video_id(unicode): edx-val's video identifier
628+
# Arguments:
629+
# language_code(unicode): Language code of the requested transcript
630+
# edx_video_id(unicode): edx-val's video identifier
631631

632-
Returns:
633-
A dict containing transcript's file name and its sjson content.
634-
"""
635-
transcript = None
636-
edx_video_id = clean_video_id(edx_video_id)
637-
if edxval_api and edx_video_id:
638-
try:
639-
transcript = edxval_api.get_video_transcript_data(edx_video_id, language_code)
640-
except ValueError:
641-
log.exception(
642-
f"Error getting transcript from edx-val id: {edx_video_id}: language code {language_code}"
643-
)
644-
content = '{"start": [1],"end": [2],"text": ["An error occured obtaining the transcript."]}'
645-
transcript = dict(
646-
file_name='error-{edx_video_id}-{language_code}.srt',
647-
content=Transcript.convert(content, 'sjson', 'srt')
648-
)
649-
return transcript
632+
# Returns:
633+
# A dict containing transcript's file name and its sjson content.
634+
# """
635+
# transcript = None
636+
# edx_video_id = clean_video_id(edx_video_id)
637+
# if edxval_api and edx_video_id:
638+
# try:
639+
# transcript = edxval_api.get_video_transcript_data(edx_video_id, language_code)
640+
# except ValueError:
641+
# log.exception(
642+
# f"Error getting transcript from edx-val id: {edx_video_id}: language code {language_code}"
643+
# )
644+
# content = '{"start": [1],"end": [2],"text": ["An error occured obtaining the transcript."]}'
645+
# transcript = dict(
646+
# file_name='error-{edx_video_id}-{language_code}.srt',
647+
# content=Transcript.convert(content, 'sjson', 'srt')
648+
# )
649+
# return transcript
650650

651651

652652
def get_available_transcript_languages(edx_video_id):
@@ -667,24 +667,24 @@ def get_available_transcript_languages(edx_video_id):
667667
return available_languages
668668

669669

670-
def convert_video_transcript(file_name, content, output_format):
671-
"""
672-
Convert video transcript into desired format
670+
# def convert_video_transcript(file_name, content, output_format):
671+
# """
672+
# Convert video transcript into desired format
673673

674-
Arguments:
675-
file_name: name of transcript file along with its extension
676-
content: transcript content stream
677-
output_format: the format in which transcript will be converted
674+
# Arguments:
675+
# file_name: name of transcript file along with its extension
676+
# content: transcript content stream
677+
# output_format: the format in which transcript will be converted
678678

679-
Returns:
680-
A dict containing the new transcript filename and the content converted into desired format.
681-
"""
682-
name_and_extension = os.path.splitext(file_name)
683-
basename, input_format = name_and_extension[0], name_and_extension[1][1:]
684-
filename = f'{basename}.{output_format}'
685-
converted_transcript = Transcript.convert(content, input_format=input_format, output_format=output_format)
679+
# Returns:
680+
# A dict containing the new transcript filename and the content converted into desired format.
681+
# """
682+
# name_and_extension = os.path.splitext(file_name)
683+
# basename, input_format = name_and_extension[0], name_and_extension[1][1:]
684+
# filename = f'{basename}.{output_format}'
685+
# converted_transcript = Transcript.convert(content, input_format=input_format, output_format=output_format)
686686

687-
return dict(filename=filename, content=converted_transcript)
687+
# return dict(filename=filename, content=converted_transcript)
688688

689689

690690
# def clear_transcripts(block):
@@ -948,28 +948,28 @@ def get_transcripts_info(self, is_bumper=False):
948948
}
949949

950950

951-
@exception_decorator
952-
def get_transcript_from_val(edx_video_id, lang=None, output_format=Transcript.SRT):
953-
"""
954-
Get video transcript from edx-val.
955-
Arguments:
956-
edx_video_id (unicode): video identifier
957-
lang (unicode): transcript language
958-
output_format (unicode): transcript output format
959-
Returns:
960-
tuple containing content, filename, mimetype
961-
"""
962-
transcript = get_video_transcript_content(edx_video_id, lang)
963-
if not transcript:
964-
raise NotFoundError(f'Transcript not found for {edx_video_id}, lang: {lang}')
951+
# @exception_decorator
952+
# def get_transcript_from_val(edx_video_id, lang=None, output_format=Transcript.SRT):
953+
# """
954+
# Get video transcript from edx-val.
955+
# Arguments:
956+
# edx_video_id (unicode): video identifier
957+
# lang (unicode): transcript language
958+
# output_format (unicode): transcript output format
959+
# Returns:
960+
# tuple containing content, filename, mimetype
961+
# """
962+
# transcript = get_video_transcript_content(edx_video_id, lang)
963+
# if not transcript:
964+
# raise NotFoundError(f'Transcript not found for {edx_video_id}, lang: {lang}')
965965

966-
transcript_conversion_props = dict(transcript, output_format=output_format)
967-
transcript = convert_video_transcript(**transcript_conversion_props)
968-
filename = transcript['filename']
969-
content = transcript['content']
970-
mimetype = Transcript.mime_types[output_format]
966+
# transcript_conversion_props = dict(transcript, output_format=output_format)
967+
# transcript = convert_video_transcript(**transcript_conversion_props)
968+
# filename = transcript['filename']
969+
# content = transcript['content']
970+
# mimetype = Transcript.mime_types[output_format]
971971

972-
return content, filename, mimetype
972+
# return content, filename, mimetype
973973

974974

975975
def get_transcript_for_video(video_block, video_location, subs_id, file_name, language):
@@ -1165,10 +1165,6 @@ def get_transcript_from_contentstore(video, language, output_format, transcripts
11651165
#
11661166
# return output_transcript, output_filename, Transcript.mime_types[output_format]
11671167

1168-
# NOTE: This function is not used in xblocks-contrib. The implementation in edx-platform
1169-
# (xmodule.video_block.transcripts_utils.get_transcript_from_learning_core) is called
1170-
# via the VideoConfigService when needed.
1171-
11721168

11731169
# def get_transcript(video, lang=None, output_format=Transcript.SRT, youtube_id=None):
11741170
# """
@@ -1205,10 +1201,6 @@ def get_transcript_from_contentstore(video, language, output_format, transcripts
12051201
# transcripts_info=transcripts_info
12061202
# )
12071203

1208-
# NOTE: This function has been moved to VideoConfigService in edx-platform
1209-
# and is now accessed by calling video_config service's get_transcript() method directly.
1210-
# The implementation in edx-platform calls xmodule.video_block.transcripts_utils.get_transcript
1211-
12121204

12131205
def resolve_language_code_to_transcript_code(transcripts, dest_lang):
12141206
"""

0 commit comments

Comments
 (0)