def parse_media_playlists(self): if not self.playlist.is_variant: return [] playlists = [] for p in self.playlist.playlists: uri = p.uri if streambot.is_full_uri(p.uri) else urlparse.urljoin( self.uri, p.uri) playlists.append(HLSPlaylist(uri)) for m in self.playlist.media: if not m.uri: continue uri = m.uri if streambot.is_full_uri(p.uri) else urlparse.urljoin( self.uri, m.uri) playlists.append(HLSPlaylist(uri)) return playlists
def __init__(self, uri): ''' @param uri Absolute URI of playlist ''' if not streambot.is_full_uri(uri): raise streambot.StreamBotError( 'HLSPlaylist URI is not absolute: {uri}'.format(uri=uri)) self.uri = uri self.playlist = None
def __init__(self, uri, is_byterange): ''' @param uri Absolute URI of segment ''' if not streambot.is_full_uri(uri): raise streambot.StreamBotError( 'HLSSegment URI is not absolute: {uri}'.format(uri=uri)) self.uri = uri self.is_byterange = is_byterange
def __init__(self, mpd_uri): ''' @param mpd_uri Absolute URI of playlist ''' if not streambot.is_full_uri(mpd_uri): raise streambot.StreamBotError( 'DASHPlaylist URI is not absolute: {uri}'.format(uri=mpd_uri)) self.uri = mpd_uri self.mpd = None
def _make_segment_url(mpd_base_url, period_base_url, adaptation_set_base_url, representation_base_url): mpd_base_url_value = mpd_base_url.base_url_value if mpd_base_url else '' period_base_url_value = period_base_url.base_url_value if period_base_url else '' adaptation_set_base_url_value = adaptation_set_base_url.base_url_value if adaptation_set_base_url else '' representation_base_url_value = representation_base_url.base_url_value if representation_base_url else '' if streambot.is_full_uri(representation_base_url_value): return representation_base_url_value url = ''.join([ mpd_base_url_value, period_base_url_value, adaptation_set_base_url_value, representation_base_url_value ]) return url
def parse_segments(self): if self.playlist.is_variant: return [] segments = [] for s in self.playlist.segments: if s.uri.startswith('#'): continue if streambot.is_full_uri(s.uri): segments.append(HLSSegment(uri=s.uri, is_byterange=s.byterange)) else: segments.append( HLSSegment(uri=urlparse.urljoin(self.uri, s.uri), is_byterange=s.byterange)) return segments
def test_is_full_uri_false(self): uri = 'asdf' self.assertFalse(streambot.is_full_uri(uri))
def test_is_full_uri_https(self): uri = 'https://example.com' self.assertTrue(streambot.is_full_uri(uri))