Exemple #1
0
def test_add_unregistered_media_with_replace_flag_set():
    en_sub = Media(group_id='subs', type='SUBTITLES', name='English subs',
                   uri='en_subs.vtt')
    media_list = MediaList()

    media_list.add(en_sub, replace=True)

    assert len(media_list) == 1
Exemple #2
0
def test_medialist_uri_method():
    langs = ['English', 'French', 'German']
    ml = MediaList()
    for lang in langs:
        ml.append(Media(type='AUDIO', group_id='audio-group', name=lang, uri=('/%s.m3u8' % lang)))

    assert len(ml.uri) == len(langs)
    assert ml.uri[0] == '/%s.m3u8' % langs[0]
    assert ml.uri[1] == '/%s.m3u8' % langs[1]
    assert ml.uri[2] == '/%s.m3u8' % langs[2]
Exemple #3
0
def test_equivalent_media_element_added_if_specified():
    en_sub_1 = Media(group_id='subs', type='SUBTITLES', name='English subs',
                     uri='en_subs.vtt')
    en_sub_2 = Media(group_id='subs', type='SUBTITLES', name='English subs',
                     uri='en_subs_2.vtt', default='YES')
    media_list = MediaList([en_sub_1])

    media_list.add(en_sub_2, replace=True)

    assert len(media_list) == 1
    en_sub = media_list.pop()
    assert en_sub.uri == 'en_subs_2.vtt' and en_sub.default == 'YES'
 def add_base_path_to_playlists(self, paths, initial_manifest):
     medias = MediaList()
     playlists = PlaylistList()
     for i, path in enumerate(paths):
         manifest_path = self.job.output_url + path + self.OUTPUT_FILE_NAME
         manifest = m3u8.loads(self.read_file(manifest_path))
         for playlist in manifest.playlists:
             playlist.uri = path + playlist.uri
             playlists.append(playlist)
         for media in manifest.media:
             media.uri = path + media.uri
             media.group_id += "_{}".format(str(i))
             medias.append(media)
     initial_manifest.media = medias
     initial_manifest.playlists = playlists