示例#1
0
 def test_get_videos_for_course(self):
     """
     Tests retrieving videos for a course id
     """
     videos = list(api.get_videos_for_course(self.course_id))
     self.assertEqual(len(videos), 1)
     self.assertEqual(videos[0]["edx_video_id"], constants.VIDEO_DICT_FISH["edx_video_id"])
     videos = list(api.get_videos_for_course("unknown"))
     self.assertEqual(len(videos), 0)
示例#2
0
def _get_videos(course):
    """
    Retrieves the list of videos from VAL corresponding to this course.
    """
    videos = list(get_videos_for_course(unicode(course.id), VideoSortField.created, SortDirection.desc))

    # This is required to see if edx video pipeline is enabled while converting the video status.
    course_video_upload_token = course.video_upload_pipeline.get('course_video_upload_token')

    # convert VAL's status to studio's Video Upload feature status.
    for video in videos:
        # If we are using "new video workflow" and status is `transcription_in_progress` then video encodes are ready.
        # This is because Transcription starts once all the encodes are complete except for YT, but according to
        # "new video workflow" YT is disabled as well as deprecated. So, Its precise to say that the Transcription
        # starts once all the encodings are complete *for the new video workflow*.
        is_video_encodes_ready = not course_video_upload_token and video['status'] == 'transcription_in_progress'
        # Update with transcript languages
        video['transcripts'] = get_available_transcript_languages(video_id=video['edx_video_id'])
        # Transcription status should only be visible if 3rd party transcripts are pending.
        video['transcription_status'] = (
            StatusDisplayStrings.get(video['status'])
            if not video['transcripts'] and is_video_encodes_ready else
            ''
        )
        # Convert the video status.
        video['status'] = convert_video_status(video, is_video_encodes_ready)

    return videos
示例#3
0
def _get_videos(course):
    """
    Retrieves the list of videos from VAL corresponding to this course.
    """
    videos = list(get_videos_for_course(course.id, VideoSortField.created, SortDirection.desc))

    # convert VAL's status to studio's Video Upload feature status.
    for video in videos:
        video["status"] = convert_video_status(video)

    return videos
示例#4
0
    def _videos_quality(self, course):
        video_blocks_in_course = modulestore().get_items(course.id, qualifiers={'category': 'video'})
        videos_in_val = list(get_videos_for_course(course.id))
        video_durations = [video['duration'] for video in videos_in_val]

        return dict(
            total_number=len(video_blocks_in_course),
            num_mobile_encoded=len(videos_in_val),
            num_with_val_id=len([v for v in video_blocks_in_course if v.edx_video_id]),
            durations=self._stats_dict(video_durations),
        )
示例#5
0
    def _videos_quality(self, course):  # lint-amnesty, pylint: disable=missing-function-docstring
        video_blocks_in_course = modulestore().get_items(course.id, qualifiers={'category': 'video'})
        videos, __ = get_videos_for_course(course.id)
        videos_in_val = list(videos)
        video_durations = [video['duration'] for video in videos_in_val]

        return dict(
            total_number=len(video_blocks_in_course),
            num_mobile_encoded=len(videos_in_val),
            num_with_val_id=len([v for v in video_blocks_in_course if v.edx_video_id]),
            durations=self._stats_dict(video_durations),
        )
示例#6
0
def _get_videos(course):
    """
    Retrieves the list of videos from VAL corresponding to this course.
    """
    videos = list(get_videos_for_course(unicode(course.id), VideoSortField.created, SortDirection.desc))

    # convert VAL's status to studio's Video Upload feature status.
    for video in videos:
        video["status"] = convert_video_status(video)
        video['transcripts'] = get_available_transcript_languages(video_id=video['edx_video_id'])

    return videos
    def _videos_quality(self, course):
        video_blocks_in_course = modulestore().get_items(
            course.id, qualifiers={'category': 'video'})
        videos_in_val = list(get_videos_for_course(course.id))
        video_durations = [video['duration'] for video in videos_in_val]

        return dict(
            total_number=len(video_blocks_in_course),
            num_mobile_encoded=len(videos_in_val),
            num_with_val_id=len(
                [v for v in video_blocks_in_course if v.edx_video_id]),
            durations=self._stats_dict(video_durations),
        )
示例#8
0
def _get_videos(course):
    """
    Retrieves the list of videos from VAL corresponding to this course.
    """
    videos = list(
        get_videos_for_course(unicode(course.id), VideoSortField.created,
                              SortDirection.desc))

    # convert VAL's status to studio's Video Upload feature status.
    for video in videos:
        video["status"] = convert_video_status(video)

    return videos
示例#9
0
def _get_videos(course, pagination_conf=None):
    """
    Retrieves the list of videos from VAL corresponding to this course.
    """
    videos, pagination_context = get_videos_for_course(
        six.text_type(course.id),
        VideoSortField.created,
        SortDirection.desc,
        pagination_conf
    )
    videos = list(videos)

    # This is required to see if edx video pipeline is enabled while converting the video status.
    course_video_upload_token = course.video_upload_pipeline.get('course_video_upload_token')
    # TODO: add 'transcript_ready' when we have moved to VEM to keep transcript and encode status separate
    transcription_statuses = ['partial_failure', 'transcription_in_progress']

    # convert VAL's status to studio's Video Upload feature status.
    for video in videos:
        # If we are using "new video workflow" and status is `transcription_in_progress` then video encodes are ready.
        # This is because Transcription starts once all the encodes are complete except for YT, but according to
        # "new video workflow" YT is disabled as well as deprecated. So, Its precise to say that the Transcription
        # starts once all the encodings are complete *for the new video workflow*.
        # If the video status is 'partial_failure', it means during the transcription flow, some transcription jobs
        # failed. As mentioned, transcript jobs start only when the encodes have finished
        is_video_encodes_ready = not course_video_upload_token and (video['status'] in transcription_statuses)
        # Update with transcript languages
        video['transcripts'] = get_available_transcript_languages(video_id=video['edx_video_id'])
        # Transcription status should only be visible if 3rd party transcripts are pending.
        # TODO: change logic to separate transcript status from video status
        video['transcription_status'] = (
            StatusDisplayStrings.get(video['status'])
            if not video['transcripts'] and is_video_encodes_ready else
            ''
        )
        # Convert the video status.
        video['status'] = convert_video_status(video, is_video_encodes_ready)

    return videos, pagination_context
示例#10
0
def _get_videos(course):
    """
    Retrieves the list of videos from VAL corresponding to this course.
    """
    is_video_transcript_enabled = VideoTranscriptEnabledFlag.feature_enabled(
        course.id)
    videos = list(
        get_videos_for_course(unicode(course.id), VideoSortField.created,
                              SortDirection.desc))

    # convert VAL's status to studio's Video Upload feature status.
    for video in videos:
        video["status"] = convert_video_status(video)

        if is_video_transcript_enabled:
            all_languages = get_all_transcript_languages()
            video['transcripts'] = {
                lang_code: all_languages[lang_code]
                for lang_code in get_available_transcript_languages(
                    [video['edx_video_id']])
            }

    return videos
示例#11
0
 def api_func(_expected_ids, sort_field, sort_direction):
     return api.get_videos_for_course(self.course_id, sort_field, sort_direction)
示例#12
0
 def api_func(_expected_ids, sort_field, sort_direction):
     return api.get_videos_for_course(
         self.course_id,
         sort_field,
         sort_direction,
     )