def absolute_uri(self): if self.uri is None: return None if is_url(self.uri): return self.uri else: if self.base_uri is None: raise ValueError('There can not be `absolute_uri` with no `base_uri` set') return _urijoin(self.base_uri, self.uri)
def load(uri, timeout=None, headers={}, custom_tags_parser=None, verify_ssl=True): ''' Retrieves the content from a given URI and returns a M3U8 object. Raises ValueError if invalid content or IOError if request fails. Raises socket.timeout(python 2.7+) or urllib2.URLError(python 2.6) if timeout happens when loading from uri ''' if is_url(uri): return _load_from_uri(uri, timeout, headers, custom_tags_parser, verify_ssl) else: return _load_from_file(uri, custom_tags_parser)
def _urijoin(base_uri, path): if is_url(base_uri): return urljoin(base_uri, path) else: return os.path.normpath(os.path.join(base_uri, path.strip('/')))