diff --git a/m3u8/parser.py b/m3u8/parser.py index cb16fe3d..5478e56d 100644 --- a/m3u8/parser.py +++ b/m3u8/parser.py @@ -447,7 +447,7 @@ def _parse_byterange(line, state, **kwargs): def _parse_targetduration(**parse_kwargs): - return _parse_simple_parameter(cast_to=float, **parse_kwargs) + return _parse_simple_parameter(cast_to=int, **parse_kwargs) def _parse_media_sequence(**parse_kwargs): diff --git a/tests/playlists.py b/tests/playlists.py index 4a5e497b..bcf5d290 100755 --- a/tests/playlists.py +++ b/tests/playlists.py @@ -65,7 +65,7 @@ PLAYLIST_WITH_NON_INTEGER_DURATION = """ #EXTM3U -#EXT-X-TARGETDURATION:5220.5 +#EXT-X-TARGETDURATION:5221 #EXTINF:5220.5, http://media.example.com/entire.ts """ diff --git a/tests/test_parser.py b/tests/test_parser.py index a228c4af..a5015711 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -28,7 +28,7 @@ def test_should_parse_simple_playlist_from_string(): def test_should_parse_non_integer_duration_from_playlist_string(): data = m3u8.parse(playlists.PLAYLIST_WITH_NON_INTEGER_DURATION) - assert 5220.5 == data["targetduration"] + assert 5221 == data["targetduration"] assert [5220.5] == [c["duration"] for c in data["segments"]]