Example #1
0
    def test_video_with_multiple_transcripts_index_dictionary(self):
        """
        Test index dictionary of a video module with
        two transcripts uploaded by a user.
        """
        xml_data_transcripts = '''
            <video display_name="Test Video"
                   youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8"
                   show_captions="false"
                   download_track="false"
                   start_time="00:00:01"
                   download_video="false"
                   end_time="00:01:00">
              <source src="http://www.example.com/source.mp4"/>
              <track src="http://www.example.com/track"/>
              <handout src="http://www.example.com/handout"/>
              <transcript language="ge" src="subs_grmtran1.srt" />
              <transcript language="hr" src="subs_croatian1.srt" />
            </video>
        '''

        descriptor = instantiate_descriptor(data=xml_data_transcripts)
        save_to_store(SRT_FILEDATA, "subs_grmtran1.srt", 'text/srt', descriptor.location)
        save_to_store(CRO_SRT_FILEDATA, "subs_croatian1.srt", 'text/srt', descriptor.location)
        self.assertEqual(descriptor.index_dictionary(), {
            "content": {
                "display_name": "Test Video",
                "transcript_ge": "sprechen sie deutsch? Ja, ich spreche Deutsch",
                "transcript_hr": "Dobar dan! Kako ste danas?"
            },
            "content_type": "Video"
        })
Example #2
0
    def test_video_with_subs_and_transcript_index_dictionary(self):
        """
        Test index dictionary of a video module with
        YouTube subtitles and German transcript uploaded by a user.
        """
        xml_data_sub_transcript = '''
            <video display_name="Test Video"
                   youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8"
                   show_captions="false"
                   download_track="false"
                   sub="OEoXaMPEzfM"
                   start_time="00:00:01"
                   download_video="false"
                   end_time="00:01:00">
              <source src="http://www.example.com/source.mp4"/>
              <track src="http://www.example.com/track"/>
              <handout src="http://www.example.com/handout"/>
              <transcript language="ge" src="subs_grmtran1.srt" />
            </video>
        '''

        descriptor = instantiate_descriptor(data=xml_data_sub_transcript)
        download_youtube_subs('OEoXaMPEzfM', descriptor, settings)
        save_to_store(SRT_FILEDATA, "subs_grmtran1.srt", 'text/srt', descriptor.location)
        self.assertEqual(descriptor.index_dictionary(), {
            "content": {
                "display_name": "Test Video",
                "transcript_en": YOUTUBE_SUBTITLES,
                "transcript_ge": "sprechen sie deutsch? Ja, ich spreche Deutsch",
            },
            "content_type": "Video"
        })
Example #3
0
    def test_video_with_multiple_transcripts_index_dictionary(self):
        """
        Test index dictionary of a video module with
        two transcripts uploaded by a user.
        """
        xml_data_transcripts = '''
            <video display_name="Test Video"
                   youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8"
                   show_captions="false"
                   download_track="false"
                   start_time="00:00:01"
                   download_video="false"
                   end_time="00:01:00">
              <source src="http://www.example.com/source.mp4"/>
              <track src="http://www.example.com/track"/>
              <handout src="http://www.example.com/handout"/>
              <transcript language="ge" src="subs_grmtran1.srt" />
              <transcript language="hr" src="subs_croatian1.srt" />
            </video>
        '''

        descriptor = instantiate_descriptor(data=xml_data_transcripts)
        save_to_store(SRT_FILEDATA, "subs_grmtran1.srt", 'text/srt',
                      descriptor.location)
        save_to_store(CRO_SRT_FILEDATA, "subs_croatian1.srt", 'text/srt',
                      descriptor.location)
        self.assertEqual(
            descriptor.index_dictionary(), {
                "content": {
                    "display_name": "Test Video",
                    "transcript_ge":
                    "sprechen sie deutsch? Ja, ich spreche Deutsch",
                    "transcript_hr": "Dobar dan! Kako ste danas?"
                },
                "content_type": "Video"
            })
Example #4
0
    def test_index_dictionary(self):
        xml_data = '''
            <video display_name="Test Video"
                   youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8"
                   show_captions="false"
                   download_track="false"
                   start_time="00:00:01"
                   download_video="false"
                   end_time="00:01:00">
              <source src="http://www.example.com/source.mp4"/>
              <track src="http://www.example.com/track"/>
              <handout src="http://www.example.com/handout"/>
            </video>
        '''
        descriptor = instantiate_descriptor(data=xml_data)
        self.assertEqual(descriptor.index_dictionary(), {
            "content": {
                "display_name": "Test Video"
            },
            "content_type": "Video"
        })

        xml_data_sub = '''
            <video display_name="Test Video"
                   youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8"
                   show_captions="false"
                   download_track="false"
                   sub="OEoXaMPEzfM"
                   start_time="00:00:01"
                   download_video="false"
                   end_time="00:01:00">
              <source src="http://www.example.com/source.mp4"/>
              <track src="http://www.example.com/track"/>
              <handout src="http://www.example.com/handout"/>
            </video>
        '''

        descriptor = instantiate_descriptor(data=xml_data_sub)
        download_youtube_subs('OEoXaMPEzfM', descriptor, settings)
        self.assertEqual(
            descriptor.index_dictionary(), {
                "content": {
                    "display_name":
                    "Test Video",
                    "transcript_en":
                    ("LILA FISHER: Hi, welcome to Edx. I'm Lila Fisher, an Edx fellow helping to put together these"
                     "courses. As you know, our courses are entirely online. So before we start learning about the"
                     "subjects that brought you here, let's learn about the tools that you will use to navigate through"
                     "the course material. Let's start with what is on your screen right now. You are watching a video"
                     "of me talking. You have several tools associated with these videos. Some of them are standard"
                     "video buttons, like the play Pause Button on the bottom left. Like most video players, you can see"
                     "how far you are into this particular video segment and how long the entire video segment is."
                     "Something that you might not be used to is the speed option. While you are going through the"
                     "videos, you can speed up or slow down the video player with these buttons. Go ahead and try that"
                     "now. Make me talk faster and slower. If you ever get frustrated by the pace of speech, you can"
                     "adjust it this way. Another great feature is the transcript on the side. This will follow along"
                     "with everything that I am saying as I am saying it, so you can read along if you like. You can"
                     "also click on any of the words, and you will notice that the video jumps to that word. The video"
                     "slider at the bottom of the video will let you navigate through the video quickly. If you ever"
                     "find the transcript distracting, you can toggle the captioning button in order to make it go away"
                     "or reappear. Now that you know about the video player, I want to point out the sequence navigator."
                     "Right now you're in a lecture sequence, which interweaves many videos and practice exercises. You"
                     "can see how far you are in a particular sequence by observing which tab you're on. You can"
                     "navigate directly to any video or exercise by clicking on the appropriate tab. You can also"
                     "progress to the next element by pressing the Arrow button, or by clicking on the next tab. Try"
                     "that now. The tutorial will continue in the next video.")
                },
                "content_type": "Video"
            })

        xml_data_sub_transcript = '''
            <video display_name="Test Video"
                   youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8"
                   show_captions="false"
                   download_track="false"
                   sub="OEoXaMPEzfM"
                   start_time="00:00:01"
                   download_video="false"
                   end_time="00:01:00">
              <source src="http://www.example.com/source.mp4"/>
              <track src="http://www.example.com/track"/>
              <handout src="http://www.example.com/handout"/>
              <transcript language="ge" src="subs_grmtran1.srt" />
            </video>
        '''

        descriptor = instantiate_descriptor(data=xml_data_sub_transcript)
        save_to_store(SRT_FILEDATA, "subs_grmtran1.srt", 'text/srt',
                      descriptor.location)
        self.assertEqual(
            descriptor.index_dictionary(), {
                "content": {
                    "display_name":
                    "Test Video",
                    "transcript_en":
                    ("LILA FISHER: Hi, welcome to Edx. I'm Lila Fisher, an Edx fellow helping to put together these"
                     "courses. As you know, our courses are entirely online. So before we start learning about the"
                     "subjects that brought you here, let's learn about the tools that you will use to navigate through"
                     "the course material. Let's start with what is on your screen right now. You are watching a video"
                     "of me talking. You have several tools associated with these videos. Some of them are standard"
                     "video buttons, like the play Pause Button on the bottom left. Like most video players, you can see"
                     "how far you are into this particular video segment and how long the entire video segment is."
                     "Something that you might not be used to is the speed option. While you are going through the"
                     "videos, you can speed up or slow down the video player with these buttons. Go ahead and try that"
                     "now. Make me talk faster and slower. If you ever get frustrated by the pace of speech, you can"
                     "adjust it this way. Another great feature is the transcript on the side. This will follow along"
                     "with everything that I am saying as I am saying it, so you can read along if you like. You can"
                     "also click on any of the words, and you will notice that the video jumps to that word. The video"
                     "slider at the bottom of the video will let you navigate through the video quickly. If you ever"
                     "find the transcript distracting, you can toggle the captioning button in order to make it go away"
                     "or reappear. Now that you know about the video player, I want to point out the sequence navigator."
                     "Right now you're in a lecture sequence, which interweaves many videos and practice exercises. You"
                     "can see how far you are in a particular sequence by observing which tab you're on. You can"
                     "navigate directly to any video or exercise by clicking on the appropriate tab. You can also"
                     "progress to the next element by pressing the Arrow button, or by clicking on the next tab. Try"
                     "that now. The tutorial will continue in the next video."
                     ),
                    "transcript_ge":
                    "sprechen sie deutsch? Ja, ich spreche Deutsch"
                },
                "content_type": "Video"
            })

        xml_data_transcripts = '''
            <video display_name="Test Video"
                   youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8"
                   show_captions="false"
                   download_track="false"
                   start_time="00:00:01"
                   download_video="false"
                   end_time="00:01:00">
              <source src="http://www.example.com/source.mp4"/>
              <track src="http://www.example.com/track"/>
              <handout src="http://www.example.com/handout"/>
              <transcript language="ge" src="subs_grmtran1.srt" />
              <transcript language="hr" src="subs_croatian1.srt" />
            </video>
        '''

        descriptor = instantiate_descriptor(data=xml_data_transcripts)
        save_to_store(SRT_FILEDATA, "subs_grmtran1.srt", 'text/srt',
                      descriptor.location)
        save_to_store(CRO_SRT_FILEDATA, "subs_croatian1.srt", 'text/srt',
                      descriptor.location)
        self.assertEqual(
            descriptor.index_dictionary(), {
                "content": {
                    "display_name": "Test Video",
                    "transcript_ge":
                    "sprechen sie deutsch? Ja, ich spreche Deutsch",
                    "transcript_hr": "Dobar dan! Kako ste danas?"
                },
                "content_type": "Video"
            })
    def setUp(self):
        """ Common setup. """
        super(TestMigrateTranscripts, self).setUp()
        self.store = modulestore()
        self.course = CourseFactory.create()
        self.course_2 = CourseFactory.create()

        video = {
            'edx_video_id': 'test_edx_video_id',
            'client_video_id': 'test1.mp4',
            'duration': 42.0,
            'status': 'upload',
            'courses': [six.text_type(self.course.id)],
            'encoded_videos': [],
            'created': datetime.now(pytz.utc)
        }
        api.create_video(video)

        video_sample_xml = '''
            <video display_name="Test Video"
                   edx_video_id="test_edx_video_id"
                   youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8"
                   show_captions="false"
                   download_track="false"
                   start_time="1.0"
                   download_video="false"
                   end_time="60.0">
              <source src="http://www.example.com/source.mp4"/>
              <track src="http://www.example.com/track"/>
              <handout src="http://www.example.com/handout"/>
              <transcript language="ge" src="subs_grmtran1.srt" />
              <transcript language="hr" src="subs_croatian1.srt" />
            </video>
        '''

        video_sample_xml_2 = '''
            <video display_name="Test Video 2"
                   edx_video_id="test_edx_video_id_2"
                   youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8"
                   show_captions="false"
                   download_track="false"
                   start_time="1.0"
                   download_video="false"
                   end_time="60.0">
              <source src="http://www.example.com/source.mp4"/>
              <track src="http://www.example.com/track"/>
              <handout src="http://www.example.com/handout"/>
              <transcript language="ge" src="not_found.srt" />
            </video>
        '''
        self.video_descriptor = ItemFactory.create(
            parent_location=self.course.location, category='video',
            **VideoBlock.parse_video_xml(video_sample_xml)
        )
        self.video_descriptor_2 = ItemFactory.create(
            parent_location=self.course_2.location, category='video',
            **VideoBlock.parse_video_xml(video_sample_xml_2)
        )

        save_to_store(SRT_FILEDATA, 'subs_grmtran1.srt', 'text/srt', self.video_descriptor.location)
        save_to_store(CRO_SRT_FILEDATA, 'subs_croatian1.srt', 'text/srt', self.video_descriptor.location)
Example #6
0
    def test_index_dictionary(self):
        xml_data = '''
            <video display_name="Test Video"
                   youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8"
                   show_captions="false"
                   download_track="false"
                   start_time="00:00:01"
                   download_video="false"
                   end_time="00:01:00">
              <source src="http://www.example.com/source.mp4"/>
              <track src="http://www.example.com/track"/>
              <handout src="http://www.example.com/handout"/>
            </video>
        '''
        descriptor = instantiate_descriptor(data=xml_data)
        self.assertEqual(descriptor.index_dictionary(), {
            "content": {"display_name": "Test Video"},
            "content_type": "Video"
        })

        xml_data_sub = '''
            <video display_name="Test Video"
                   youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8"
                   show_captions="false"
                   download_track="false"
                   sub="OEoXaMPEzfM"
                   start_time="00:00:01"
                   download_video="false"
                   end_time="00:01:00">
              <source src="http://www.example.com/source.mp4"/>
              <track src="http://www.example.com/track"/>
              <handout src="http://www.example.com/handout"/>
            </video>
        '''

        descriptor = instantiate_descriptor(data=xml_data_sub)
        download_youtube_subs('OEoXaMPEzfM', descriptor, settings)
        self.assertEqual(descriptor.index_dictionary(), {
            "content": {
                "display_name": "Test Video",
                "transcript_en": (
                    "LILA FISHER: Hi, welcome to Edx. I'm Lila Fisher, an Edx fellow helping to put together these"
                    "courses. As you know, our courses are entirely online. So before we start learning about the"
                    "subjects that brought you here, let's learn about the tools that you will use to navigate through"
                    "the course material. Let's start with what is on your screen right now. You are watching a video"
                    "of me talking. You have several tools associated with these videos. Some of them are standard"
                    "video buttons, like the play Pause Button on the bottom left. Like most video players, you can see"
                    "how far you are into this particular video segment and how long the entire video segment is."
                    "Something that you might not be used to is the speed option. While you are going through the"
                    "videos, you can speed up or slow down the video player with these buttons. Go ahead and try that"
                    "now. Make me talk faster and slower. If you ever get frustrated by the pace of speech, you can"
                    "adjust it this way. Another great feature is the transcript on the side. This will follow along"
                    "with everything that I am saying as I am saying it, so you can read along if you like. You can"
                    "also click on any of the words, and you will notice that the video jumps to that word. The video"
                    "slider at the bottom of the video will let you navigate through the video quickly. If you ever"
                    "find the transcript distracting, you can toggle the captioning button in order to make it go away"
                    "or reappear. Now that you know about the video player, I want to point out the sequence navigator."
                    "Right now you're in a lecture sequence, which interweaves many videos and practice exercises. You"
                    "can see how far you are in a particular sequence by observing which tab you're on. You can"
                    "navigate directly to any video or exercise by clicking on the appropriate tab. You can also"
                    "progress to the next element by pressing the Arrow button, or by clicking on the next tab. Try"
                    "that now. The tutorial will continue in the next video."
                )
            },
            "content_type": "Video"
        })

        xml_data_sub_transcript = '''
            <video display_name="Test Video"
                   youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8"
                   show_captions="false"
                   download_track="false"
                   sub="OEoXaMPEzfM"
                   start_time="00:00:01"
                   download_video="false"
                   end_time="00:01:00">
              <source src="http://www.example.com/source.mp4"/>
              <track src="http://www.example.com/track"/>
              <handout src="http://www.example.com/handout"/>
              <transcript language="ge" src="subs_grmtran1.srt" />
            </video>
        '''

        descriptor = instantiate_descriptor(data=xml_data_sub_transcript)
        save_to_store(SRT_FILEDATA, "subs_grmtran1.srt", 'text/srt', descriptor.location)
        self.assertEqual(descriptor.index_dictionary(), {
            "content": {
                "display_name": "Test Video",
                "transcript_en": (
                    "LILA FISHER: Hi, welcome to Edx. I'm Lila Fisher, an Edx fellow helping to put together these"
                    "courses. As you know, our courses are entirely online. So before we start learning about the"
                    "subjects that brought you here, let's learn about the tools that you will use to navigate through"
                    "the course material. Let's start with what is on your screen right now. You are watching a video"
                    "of me talking. You have several tools associated with these videos. Some of them are standard"
                    "video buttons, like the play Pause Button on the bottom left. Like most video players, you can see"
                    "how far you are into this particular video segment and how long the entire video segment is."
                    "Something that you might not be used to is the speed option. While you are going through the"
                    "videos, you can speed up or slow down the video player with these buttons. Go ahead and try that"
                    "now. Make me talk faster and slower. If you ever get frustrated by the pace of speech, you can"
                    "adjust it this way. Another great feature is the transcript on the side. This will follow along"
                    "with everything that I am saying as I am saying it, so you can read along if you like. You can"
                    "also click on any of the words, and you will notice that the video jumps to that word. The video"
                    "slider at the bottom of the video will let you navigate through the video quickly. If you ever"
                    "find the transcript distracting, you can toggle the captioning button in order to make it go away"
                    "or reappear. Now that you know about the video player, I want to point out the sequence navigator."
                    "Right now you're in a lecture sequence, which interweaves many videos and practice exercises. You"
                    "can see how far you are in a particular sequence by observing which tab you're on. You can"
                    "navigate directly to any video or exercise by clicking on the appropriate tab. You can also"
                    "progress to the next element by pressing the Arrow button, or by clicking on the next tab. Try"
                    "that now. The tutorial will continue in the next video."
                ),
                "transcript_ge": "sprechen sie deutsch? Ja, ich spreche Deutsch"
            },
            "content_type": "Video"
        })

        xml_data_transcripts = '''
            <video display_name="Test Video"
                   youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8"
                   show_captions="false"
                   download_track="false"
                   start_time="00:00:01"
                   download_video="false"
                   end_time="00:01:00">
              <source src="http://www.example.com/source.mp4"/>
              <track src="http://www.example.com/track"/>
              <handout src="http://www.example.com/handout"/>
              <transcript language="ge" src="subs_grmtran1.srt" />
              <transcript language="hr" src="subs_croatian1.srt" />
            </video>
        '''

        descriptor = instantiate_descriptor(data=xml_data_transcripts)
        save_to_store(SRT_FILEDATA, "subs_grmtran1.srt", 'text/srt', descriptor.location)
        save_to_store(CRO_SRT_FILEDATA, "subs_croatian1.srt", 'text/srt', descriptor.location)
        self.assertEqual(descriptor.index_dictionary(), {
            "content": {
                "display_name": "Test Video",
                "transcript_ge": "sprechen sie deutsch? Ja, ich spreche Deutsch",
                "transcript_hr": "Dobar dan! Kako ste danas?"
            },
            "content_type": "Video"
        })
    def setUp(self):
        """ Common setup. """
        super(TestMigrateTranscripts, self).setUp()
        self.store = modulestore()
        self.course = CourseFactory.create()
        self.course_2 = CourseFactory.create()

        video = {
            'edx_video_id': 'test_edx_video_id',
            'client_video_id': 'test1.mp4',
            'duration': 42.0,
            'status': 'upload',
            'courses': [unicode(self.course.id)],
            'encoded_videos': [],
            'created': datetime.now(pytz.utc)
        }
        api.create_video(video)

        video_sample_xml = '''
            <video display_name="Test Video"
                   edx_video_id="test_edx_video_id"
                   youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8"
                   show_captions="false"
                   download_track="false"
                   start_time="00:00:01"
                   download_video="false"
                   end_time="00:01:00">
              <source src="http://www.example.com/source.mp4"/>
              <track src="http://www.example.com/track"/>
              <handout src="http://www.example.com/handout"/>
              <transcript language="ge" src="subs_grmtran1.srt" />
              <transcript language="hr" src="subs_croatian1.srt" />
            </video>
        '''

        video_sample_xml_2 = '''
            <video display_name="Test Video 2"
                   edx_video_id="test_edx_video_id_2"
                   youtube="1.0:p2Q6BrNhdh8,0.75:izygArpw-Qo,1.25:1EeWXzPdhSA,1.5:rABDYkeK0x8"
                   show_captions="false"
                   download_track="false"
                   start_time="00:00:01"
                   download_video="false"
                   end_time="00:01:00">
              <source src="http://www.example.com/source.mp4"/>
              <track src="http://www.example.com/track"/>
              <handout src="http://www.example.com/handout"/>
              <transcript language="ge" src="not_found.srt" />
            </video>
        '''
        self.video_descriptor = ItemFactory.create(
            parent_location=self.course.location, category='video',
            data={'data': video_sample_xml}
        )
        self.video_descriptor_2 = ItemFactory.create(
            parent_location=self.course_2.location, category='video',
            data={'data': video_sample_xml_2}
        )

        save_to_store(SRT_FILEDATA, 'subs_grmtran1.srt', 'text/srt', self.video_descriptor.location)
        save_to_store(CRO_SRT_FILEDATA, 'subs_croatian1.srt', 'text/srt', self.video_descriptor.location)