def create_or_update_video_transcript(video_id, language_code, metadata, file_data=None):
    """
    Create or Update video transcript for an existing video.

    Arguments:
        video_id: it can be an edx_video_id or an external_id extracted from external sources in a video component.
        language_code: language code of a video transcript
        metadata (dict): A dict containing (to be overwritten) properties
        file_data (InMemoryUploadedFile): Transcript data to be saved for a course video.

    Returns:
        video transcript url
    """
    # Filter wanted properties
    metadata = {
        prop: value
        for prop, value in six.iteritems(metadata)
        if prop in ['provider', 'language_code', 'file_name', 'file_format'] and value
    }

    file_format = metadata.get('file_format')
    if file_format and file_format not in list(dict(TranscriptFormat.CHOICES).keys()):
        raise InvalidTranscriptFormat('{} transcript format is not supported'.format(file_format))

    provider = metadata.get('provider')
    if provider and provider not in list(dict(TranscriptProviderType.CHOICES).keys()):
        raise InvalidTranscriptProvider('{} transcript provider is not supported'.format(provider))

    try:
        # Video should be present in edxval in order to attach transcripts to it.
        video = Video.objects.get(edx_video_id=video_id)
        video_transcript, __ = VideoTranscript.create_or_update(video, language_code, metadata, file_data)
    except Video.DoesNotExist:
        return None

    return video_transcript.url()
def create_or_update_video_transcript ( video_id , language_code , metadata , file_data = None ) : metadata = { prop : value for prop , value in six . iteritems ( metadata ) if prop in [ 'provider' , 'language_code' , 'file_name' , 'file_format' ] and value } file_format = metadata . get ( 'file_format' ) if file_format and file_format not in list ( dict ( TranscriptFormat . CHOICES ) . keys ( ) ) : raise InvalidTranscriptFormat ( '{} transcript format is not supported' . format ( file_format ) ) provider = metadata . get ( 'provider' ) if provider and provider not in list ( dict ( TranscriptProviderType . CHOICES ) . keys ( ) ) : raise InvalidTranscriptProvider ( '{} transcript provider is not supported' . format ( provider ) ) try : video = Video . objects . get ( edx_video_id = video_id ) video_transcript , __ = VideoTranscript . create_or_update ( video , language_code , metadata , file_data ) except Video . DoesNotExist : return None return video_transcript . url ( )
Create or Update video transcript for an existing video.

    Arguments:
        video_id: it can be an edx_video_id or an external_id extracted from external sources in a video component.
        language_code: language code of a video transcript
        metadata (dict): A dict containing (to be overwritten) properties
        file_data (InMemoryUploadedFile): Transcript data to be saved for a course video.

    Returns:
        video transcript url