Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_add_segment_to_playlist():
obj = m3u8.M3U8()
obj.add_segment(
Segment(
'entire.ts',
'http://1.2/',
duration=1
)
def test_add_part_to_segment():
obj = Segment(
uri='fileSequence271.ts',
duration=4.00008
)
obj.add_part(
PartialSegment(
None,
'filePart271.0.ts',
0.33334
)
)
result = obj.dumps(None)
expected = '#EXT-X-PART:DURATION=0.33334,URI="filePart271.0.ts"'
assert expected in result
def test_base_path_should_just_return_uri_if_absolute():
segment = Segment('http://1.2/entire.ts', '')
assert 'http://1.2/entire.ts' == segment.absolute_uri
def test_should_correctly_update_base_path_if_its_blank():
segment = Segment('entire.ts', 'http://1.2/')
assert not segment.base_path
segment.base_path = "base_path"
assert "http://1.2/base_path/entire.ts" == segment.absolute_uri
def test_segment_str_method():
segment = Segment('entire.ts', 'http://1.2/', duration=1)
expected = '#EXTINF:1,\nentire.ts'
result = str(segment).strip()
assert result == expected
def _initialize_attributes(self):
self.keys = [ Key(base_uri=self.base_uri, **params) if params else None
for params in self.data.get('keys', []) ]
self.segments = SegmentList([ Segment(base_uri=self.base_uri, keyobject=find_key(segment.get('key', {}), self.keys), **segment)
for segment in self.data.get('segments', []) ])
#self.keys = get_uniques([ segment.key for segment in self.segments ])
for attr, param in self.simple_attributes:
setattr(self, attr, self.data.get(param))
self.files = []
for key in self.keys:
# Avoid None key, it could be the first one, don't repeat them
if key and key.uri not in self.files:
self.files.append(key.uri)
self.files.extend(self.segments.uri)
self.media = MediaList([ Media(base_uri=self.base_uri, **media)
for media in self.data.get('media', []) ])
self.playlists = PlaylistList([ Playlist(base_uri=self.base_uri, media=self.media, **playlist)
def base_path(self):
return super(Segment, self).base_path