def create_transcript(self, subs_id, language=u'en', filename='video.srt', youtube_id_1_0='', html5_sources=None):
        """
        create transcript.
        """
        transcripts = {}
        if language != u'en':
            transcripts = {language: filename}

        html5_sources = html5_sources or []
        self.video = ItemFactory.create(
            category='video',
            parent_location=self.vertical.location,
            sub=subs_id,
            youtube_id_1_0=youtube_id_1_0,
            transcripts=transcripts,
            edx_video_id=u'1234-5678-90',
            html5_sources=html5_sources
        )

        possible_subs = [subs_id, youtube_id_1_0] + transcripts_utils.get_html5_ids(html5_sources)
        for possible_sub in possible_subs:
            if possible_sub:
                transcripts_utils.save_subs_to_store(
                    self.subs_sjson,
                    possible_sub,
                    self.video,
                    language=language,
                )
    def create_transcript(self,
                          subs_id,
                          language=u'en',
                          filename='video.srt',
                          youtube_id_1_0='',
                          html5_sources=None):
        """
        create transcript.
        """
        transcripts = {}
        if language != u'en':
            transcripts = {language: filename}

        html5_sources = html5_sources or []
        self.video = ItemFactory.create(category='video',
                                        parent_location=self.vertical.location,
                                        sub=subs_id,
                                        youtube_id_1_0=youtube_id_1_0,
                                        transcripts=transcripts,
                                        edx_video_id=u'1234-5678-90',
                                        html5_sources=html5_sources)

        possible_subs = [subs_id, youtube_id_1_0
                         ] + transcripts_utils.get_html5_ids(html5_sources)
        for possible_sub in possible_subs:
            if possible_sub:
                transcripts_utils.save_subs_to_store(
                    self.subs_sjson,
                    possible_sub,
                    self.video,
                    language=language,
                )
 def test_html5_id_length(self):
     """
     Test that html5_id is parsed with length less than 255, as html5 ids are
     used as name for transcript objects and ultimately as filename while creating
     file for transcript at the time of exporting a course.
     Filename can't be longer than 255 characters.
     150 chars is agreed length.
     """
     html5_ids = transcripts_utils.get_html5_ids([get_random_string(255)])
     self.assertEqual(len(html5_ids[0]), 150)
 def test_html5_id_length(self):
     """
     Test that html5_id is parsed with length less than 255, as html5 ids are
     used as name for transcript objects and ultimately as filename while creating
     file for transcript at the time of exporting a course.
     Filename can't be longer than 255 characters.
     150 chars is agreed length.
     """
     html5_ids = transcripts_utils.get_html5_ids([get_random_string(255)])
     self.assertEqual(len(html5_ids[0]), 150)
 def test_subs_for_html5_vid_with_periods(self):
     """
     This is to verify a fix whereby subtitle files uploaded against
     a HTML5 video that contains periods in the name causes
     incorrect subs name parsing
     """
     html5_ids = transcripts_utils.get_html5_ids(['foo.mp4', 'foo.1.bar.mp4', 'foo/bar/baz.1.4.mp4', 'foo'])
     self.assertEqual(4, len(html5_ids))
     self.assertEqual(html5_ids[0], 'foo')
     self.assertEqual(html5_ids[1], 'foo.1.bar')
     self.assertEqual(html5_ids[2], 'baz.1.4')
     self.assertEqual(html5_ids[3], 'foo')
 def test_subs_for_html5_vid_with_periods(self):
     """
     This is to verify a fix whereby subtitle files uploaded against
     a HTML5 video that contains periods in the name causes
     incorrect subs name parsing
     """
     html5_ids = transcripts_utils.get_html5_ids(['foo.mp4', 'foo.1.bar.mp4', 'foo/bar/baz.1.4.mp4', 'foo'])
     self.assertEqual(4, len(html5_ids))
     self.assertEqual(html5_ids[0], 'foo')
     self.assertEqual(html5_ids[1], 'foo.1.bar')
     self.assertEqual(html5_ids[2], 'baz.1.4')
     self.assertEqual(html5_ids[3], 'foo')