Exemplo n.º 1
0
def create_transcript_file(video_id, language_code, file_format, resource_fs, static_dir):
    """
    Writes transcript file to file system.

    Arguments:
        video_id (str): Video id of the video transcript file is attached.
        language_code (str): Language code of the transcript.
        file_format (str): File format of the transcript file.
        static_dir (str): The Directory to store transcript file.
        resource_fs (SubFS): The file system to store transcripts.
    """
    transcript_filename = '{video_id}-{language_code}.srt'.format(
        video_id=video_id,
        language_code=language_code
    )
    transcript_data = get_video_transcript_data(video_id, language_code)
    if transcript_data:
        transcript_content = Transcript.convert(
            transcript_data['content'],
            input_format=file_format,
            output_format=Transcript.SRT
        )
        if not resource_fs.exists(static_dir):
            resource_fs.makedir(static_dir)
        create_file_in_fs(transcript_content, transcript_filename, resource_fs, static_dir)

    return transcript_filename
Exemplo n.º 2
0
Arquivo: api.py Projeto: edx/edx-val
def create_transcript_file(video_id, language_code, file_format, resource_fs, static_dir):
    """
    Writes transcript file to file system.

    Arguments:
        video_id (str): Video id of the video transcript file is attached.
        language_code (str): Language code of the transcript.
        file_format (str): File format of the transcript file.
        static_dir (str): The Directory to store transcript file.
        resource_fs (SubFS): The file system to store transcripts.
    """
    transcript_filename = '{video_id}-{language_code}.srt'.format(
        video_id=video_id,
        language_code=language_code
    )
    transcript_data = get_video_transcript_data(video_id, language_code)
    if transcript_data:
        transcript_content = Transcript.convert(
            transcript_data['content'],
            input_format=file_format,
            output_format=Transcript.SRT
        )
        create_file_in_fs(transcript_content, transcript_filename, resource_fs, static_dir)

    return transcript_filename