[Python-modules-commits] [python-m3u8] 01/04: Import python-m3u8_0.3.2.orig.tar.gz
Ondrej Koblizek
kobla-guest at moszumanska.debian.org
Mon Apr 24 12:31:39 UTC 2017
This is an automated email from the git hooks/post-receive script.
kobla-guest pushed a commit to branch master
in repository python-m3u8.
commit 62bd056c0a0d01b7790fc3fe9e5a7224ba665c40
Author: Ondřej Kobližek <koblizeko at gmail.com>
Date: Mon Apr 24 13:35:09 2017 +0200
Import python-m3u8_0.3.2.orig.tar.gz
---
.travis.yml | 6 ++++++
README.rst | 2 +-
m3u8/model.py | 1 +
m3u8/parser.py | 15 ++++++++++++++-
m3u8/protocol.py | 1 +
setup.py | 2 +-
tests/playlists.py | 9 +++++++++
tests/test_model.py | 5 +++++
tests/test_parser.py | 5 +++++
9 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 80ef662..e62c355 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,5 +4,11 @@ python:
- "2.6"
- "2.7"
- "3.3"
+ - "3.4"
+ - "3.5"
+ - "3.6"
+ - "3.6-dev"
+ - "3.7-dev"
+ - "nightly"
script: ./runtests
after_success: coveralls
diff --git a/README.rst b/README.rst
index 31c75a6..891de7b 100644
--- a/README.rst
+++ b/README.rst
@@ -177,7 +177,7 @@ If you plan to implement a new feature or something that will take more
than a few minutes, please open an issue to make sure we don't work on
the same thing.
-.. _m3u8: http://tools.ietf.org/html/draft-pantos-http-live-streaming-09
+.. _m3u8: https://tools.ietf.org/html/draft-pantos-http-live-streaming-20
.. _#EXT-X-KEY: http://tools.ietf.org/html/draft-pantos-http-live-streaming-07#section-3.3.4
.. _issue 1: https://github.com/globocom/m3u8/issues/1
.. _variant streams: http://tools.ietf.org/html/draft-pantos-http-live-streaming-08#section-6.2.4
diff --git a/m3u8/model.py b/m3u8/model.py
index f39dd68..0b13349 100644
--- a/m3u8/model.py
+++ b/m3u8/model.py
@@ -176,6 +176,7 @@ class M3U8(object):
uri=ifr_pl['uri'],
iframe_stream_info=ifr_pl['iframe_stream_info'])
)
+ self.segment_map_uri = self.data.get('segment_map_uri')
def __unicode__(self):
return self.dumps()
diff --git a/m3u8/parser.py b/m3u8/parser.py
index 1e472da..5aa117e 100644
--- a/m3u8/parser.py
+++ b/m3u8/parser.py
@@ -136,6 +136,10 @@ def parse(content, strict=False):
elif line.startswith(protocol.ext_x_endlist):
data['is_endlist'] = True
+ elif line.startswith(protocol.ext_x_map):
+ data['segment_map_uri'] = _parse_segment_map_uri(line)
+
+ # Comments and whitespace
elif line.startswith('#'):
# comment
pass
@@ -304,7 +308,16 @@ def _parse_cueout_start(line, state, prevline):
if _cueout_state:
state['current_cue_out_scte35'] = _cueout_state[0]
state['current_cue_out_duration'] = _cueout_state[1]
-
+
+
+def _parse_segment_map_uri(line):
+ """
+ :param line: '#EXT-X-MAP:URI="fileSequence0.mp4"'
+ :rtype: str
+ """
+ return remove_quotes(line.replace(protocol.ext_x_map+':', '').split('=', 1)[1])
+
+
def string_to_lines(string):
return string.strip().replace('\r\n', '\n').split('\n')
diff --git a/m3u8/protocol.py b/m3u8/protocol.py
index 2fb3be5..5d2e678 100644
--- a/m3u8/protocol.py
+++ b/m3u8/protocol.py
@@ -25,3 +25,4 @@ ext_x_scte35 = '#EXT-OATCLS-SCTE35'
ext_x_cue_start = '#EXT-X-CUE-OUT'
ext_x_cue_end = '#EXT-X-CUE-IN'
ext_x_cue_span = '#EXT-X-CUE-SPAN'
+ext_x_map = '#EXT-X-MAP'
diff --git a/setup.py b/setup.py
index c450f0f..96c16db 100644
--- a/setup.py
+++ b/setup.py
@@ -12,7 +12,7 @@ setup(
name="m3u8",
author='Globo.com',
author_email='videos3 at corp.globo.com',
- version="0.3.1",
+ version="0.3.2",
license='MIT',
zip_safe=False,
include_package_data=True,
diff --git a/tests/playlists.py b/tests/playlists.py
index fe405a1..8bb85be 100755
--- a/tests/playlists.py
+++ b/tests/playlists.py
@@ -598,6 +598,15 @@ MULTI_MEDIA_PLAYLIST = '''#EXTM3U
448/chunklist_w370587926_b688000_vo_slen_t64TWFpbg==.m3u8
'''
+MAP_URI_PLAYLIST = '''#EXTM3U
+#EXT-X-TARGETDURATION:2
+#EXT-X-VERSION:7
+#EXT-X-MEDIA-SEQUENCE:1
+#EXT-X-PLAYLIST-TYPE:VOD
+#EXT-X-INDEPENDENT-SEGMENTS
+#EXT-X-MAP:URI="fileSequence0.mp4"
+'''
+
RELATIVE_PLAYLIST_FILENAME = abspath(join(dirname(__file__), 'playlists/relative-playlist.m3u8'))
RELATIVE_PLAYLIST_URI = TEST_HOST + '/path/to/relative-playlist.m3u8'
diff --git a/tests/test_model.py b/tests/test_model.py
index 5672291..f4e985a 100755
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -690,6 +690,11 @@ def test_m3u8_should_propagate_base_uri_to_key():
assert '/any/key.bin' == obj.keys[0].absolute_uri
+def test_segment_map_uri_attribute():
+ obj = m3u8.M3U8(playlists.MAP_URI_PLAYLIST)
+ assert obj.segment_map_uri == "fileSequence0.mp4"
+
+
# custom asserts
def assert_file_content(filename, expected):
diff --git a/tests/test_parser.py b/tests/test_parser.py
index 3e0df79..7a77ecb 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -251,3 +251,8 @@ def test_commaless_extinf_strict():
with pytest.raises(ParseError) as e:
m3u8.parse(playlists.SIMPLE_PLAYLIST_COMMALESS_EXTINF, strict=True)
assert str(e.value) == 'Syntax error in manifest on line 3: #EXTINF:5220'
+
+
+def test_should_parse_segment_map_uri():
+ data = m3u8.parse(playlists.MAP_URI_PLAYLIST)
+ assert data['segment_map_uri'] == "fileSequence0.mp4"
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-m3u8.git
More information about the Python-modules-commits
mailing list