How to use the m3u8.parse function in m3u8

To help you get started, we’ve selected a few m3u8 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github globocom / m3u8 / tests / test_parser.py View on Github external
def test_date_range_in_parts():
    data = m3u8.parse(playlists.DATERANGE_IN_PART_PLAYLIST)

    assert data['segments'][0]['parts'][2]['dateranges'][0]['id'] == 'test_id'
    assert data['segments'][0]['parts'][2]['dateranges'][0]['start_date'] == '2020-03-10T07:48:02Z'
    assert data['segments'][0]['parts'][2]['dateranges'][0]['class'] == 'test_class'
    assert data['segments'][0]['parts'][2]['dateranges'][0]['end_on_next'] == 'YES'
github globocom / m3u8 / tests / test_parser.py View on Github external
def test_should_parse_ALLOW_CACHE():
    data = m3u8.parse(playlists.PLAYLIST_WITH_ENCRYPTED_SEGMENTS_AND_IV)
    assert 'no' == data['allow_cache']
github globocom / m3u8 / tests / test_parser.py View on Github external
def test_should_add_non_key_for_multiple_keys_unencrypted_and_encrypted():
    data = m3u8.parse(playlists.PLAYLIST_WITH_MULTIPLE_KEYS_UNENCRYPTED_AND_ENCRYPTED)
    # First two segments have no Key, so it's not in the dictionary
    assert 'key' not in data['segments'][0]
    assert 'key' not in data['segments'][1]
    third_segment_key = data['segments'][2]['key']
    assert "/hls-key/key.bin" == third_segment_key['uri']
    assert "AES-128" == third_segment_key['method']
    assert "0X10ef8f758ca555115584bb5b3c687f52" == third_segment_key['iv']
    last_segment_key = data['segments'][-1]['key']
    assert "/hls-key/key2.bin" == last_segment_key['uri']
    assert "AES-128" == last_segment_key['method']
    assert "0Xcafe8f758ca555115584bb5b3c687f52" == last_segment_key['iv']
github globocom / m3u8 / tests / test_parser.py View on Github external
def test_should_parse_program_date_time_from_playlist():
    data = m3u8.parse(playlists.SIMPLE_PLAYLIST_WITH_PROGRAM_DATE_TIME)
    assert cast_date_time('2014-08-13T13:36:33+00:00') == data['program_date_time']
github globocom / m3u8 / tests / test_parser.py View on Github external
def test_should_parse_start_with_precise():
    data = m3u8.parse(playlists.SIMPLE_PLAYLIST_WITH_START_PRECISE)
    assert data['start']['time_offset'] == 10.5
    assert data['start']['precise'] == 'YES'
github globocom / m3u8 / tests / test_parser.py View on Github external
def test_should_parse_variant_playlist_with_cc_subtitles_and_audio():
    data = m3u8.parse(playlists.VARIANT_PLAYLIST_WITH_CC_SUBS_AND_AUDIO)
    playlists_list = list(data['playlists'])

    assert True == data['is_variant']
    assert None == data['media_sequence']
    assert 2 == len(playlists_list)

    assert 'http://example.com/with-cc-hi.m3u8' == playlists_list[0]['uri']
    assert 1 == playlists_list[0]['stream_info']['program_id']
    assert 7680000 == playlists_list[0]['stream_info']['bandwidth']
    assert 'cc' == playlists_list[0]['stream_info']['closed_captions']
    assert 'sub' == playlists_list[0]['stream_info']['subtitles']
    assert 'aud' == playlists_list[0]['stream_info']['audio']

    assert 'http://example.com/with-cc-low.m3u8' == playlists_list[-1]['uri']
    assert 1 == playlists_list[-1]['stream_info']['program_id']
    assert 65000 == playlists_list[-1]['stream_info']['bandwidth']
github globocom / m3u8 / tests / test_parser.py View on Github external
def test_should_parse_quoted_title_from_playlist():
    data = m3u8.parse(playlists.SIMPLE_PLAYLIST_WITH_QUOTED_TITLE)
    assert 1 == len(data['segments'])
    assert 5220 == data['segments'][0]['duration']
    assert '"A sample title"' == data['segments'][0]['title']
    assert "http://media.example.com/entire.ts" == data['segments'][0]['uri']