def absolute_uri(self): if parser.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 _urijoin(base_uri, path): if parser.is_url(base_uri): parsed_url = urlparse.urlparse(base_uri) prefix = parsed_url.scheme + '://' + parsed_url.netloc new_path = posixpath.normpath(parsed_url.path + '/' + path) return urlparse.urljoin(prefix, new_path.strip('/')) else: return os.path.normpath(os.path.join(base_uri, path.strip('/')))
def load(uri): ''' Retrieves the content from a given URI and returns a M3U8 object. Raises ValueError if invalid content or IOError if request fails. ''' if is_url(uri): return _load_from_uri(uri) else: return _load_from_file(uri)
def load(uri, timeout=None): ''' 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) else: return _load_from_file(uri)
def load(uri, timeout=None, headers={}, custom_tags_parser=None, http_client=DefaultHTTPClient(), 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. ''' if is_url(uri): content, base_uri = http_client.download(uri, timeout, headers, verify_ssl) return M3U8(content, base_uri=base_uri, custom_tags_parser=custom_tags_parser) else: return _load_from_file(uri, custom_tags_parser)
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 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. ''' 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 parser.is_url(base_uri): return url_parser.urljoin(base_uri, path) else: return os.path.normpath(os.path.join(base_uri, path.strip('/')))
def _urijoin(base_uri, path): if is_url(base_uri): return url_parser.urljoin(base_uri, path) else: return os.path.normpath(os.path.join(base_uri, path.strip('/')))