def __init__(self, config, audio): super().__init__() self._scanner = scan.Scanner(timeout=config["stream"]["timeout"], proxy_config=config["proxy"]) self._session = http.get_requests_session( proxy_config=config["proxy"], user_agent=( f"{stream.Extension.dist_name}/{stream.Extension.version}"), ) blacklist = config["stream"]["metadata_blacklist"] self._blacklist_re = re.compile( r"^(%s)$" % "|".join(fnmatch.translate(u) for u in blacklist)) self._timeout = config["stream"]["timeout"] self.library = StreamLibraryProvider(backend=self) self.playback = StreamPlaybackProvider(audio=audio, backend=self) self.playlists = None self.uri_schemes = audio_lib.supported_uri_schemes( config["stream"]["protocols"]) if "file" in self.uri_schemes and config["file"]["enabled"]: logger.warning( 'The stream/protocols config value includes the "file" ' 'protocol. "file" playback is now handled by Mopidy-File. ' "Please remove it from the stream/protocols config.") self.uri_schemes -= {"file"}
def __init__(self, config, audio): super(StreamBackend, self).__init__() self._scanner = scan.Scanner(timeout=config["stream"]["timeout"], proxy_config=config["proxy"]) self._session = http.get_requests_session( proxy_config=config["proxy"], user_agent="%s/%s" % (stream.Extension.dist_name, stream.Extension.version) ) blacklist = config["stream"]["metadata_blacklist"] self._blacklist_re = re.compile(r"^(%s)$" % "|".join(fnmatch.translate(u) for u in blacklist)) self._timeout = config["stream"]["timeout"] self.library = StreamLibraryProvider(backend=self) self.playback = StreamPlaybackProvider(audio=audio, backend=self) self.playlists = None self.uri_schemes = audio_lib.supported_uri_schemes(config["stream"]["protocols"]) if "file" in self.uri_schemes and config["file"]["enabled"]: logger.warning( 'The stream/protocols config value includes the "file" ' 'protocol. "file" playback is now handled by Mopidy-File. ' "Please remove it from the stream/protocols config." ) self.uri_schemes -= {"file"}
def __init__(self, config, audio): super(StreamBackend, self).__init__() self._scanner = scan.Scanner(timeout=config['stream']['timeout'], proxy_config=config['proxy']) self._session = http.get_requests_session( proxy_config=config['proxy'], user_agent='%s/%s' % (stream.Extension.dist_name, stream.Extension.version)) blacklist = config['stream']['metadata_blacklist'] self._blacklist_re = re.compile( r'^(%s)$' % '|'.join(fnmatch.translate(u) for u in blacklist)) self._timeout = config['stream']['timeout'] self.library = StreamLibraryProvider(backend=self) self.playback = StreamPlaybackProvider(audio=audio, backend=self) self.playlists = None self.uri_schemes = audio_lib.supported_uri_schemes( config['stream']['protocols']) if 'file' in self.uri_schemes and config['file']['enabled']: logger.warning( 'The stream/protocols config value includes the "file" ' 'protocol. "file" playback is now handled by Mopidy-File. ' 'Please remove it from the stream/protocols config.') self.uri_schemes -= {'file'}
def _download(self, uri): timeout = self._config['stream']['timeout'] / 1000.0 session = http.get_requests_session( proxy_config=self._config['proxy'], user_agent='%s/%s' % ( stream.Extension.dist_name, stream.Extension.version)) try: response = session.get( uri, stream=True, timeout=timeout) except requests.exceptions.Timeout: logger.warning( 'Download of stream playlist (%s) failed due to connection ' 'timeout after %.3fs', uri, timeout) return None deadline = time.time() + timeout content = [] for chunk in response.iter_content(4096): content.append(chunk) if time.time() > deadline: logger.warning( 'Download of stream playlist (%s) failed due to download ' 'taking more than %.3fs', uri, timeout) return None if not response.ok: logger.warning( 'Problem downloading stream playlist %s: %s', uri, response.reason) return None return b''.join(content)
def __init__(self, config, audio): super(StreamBackend, self).__init__() self._scanner = scan.Scanner( timeout=config['stream']['timeout'], proxy_config=config['proxy']) self._session = http.get_requests_session( proxy_config=config['proxy'], user_agent='%s/%s' % ( stream.Extension.dist_name, stream.Extension.version)) blacklist = config['stream']['metadata_blacklist'] self._blacklist_re = re.compile( r'^(%s)$' % '|'.join(fnmatch.translate(u) for u in blacklist)) self._timeout = config['stream']['timeout'] self.library = StreamLibraryProvider(backend=self) self.playback = StreamPlaybackProvider(audio=audio, backend=self) self.playlists = None self.uri_schemes = audio_lib.supported_uri_schemes( config['stream']['protocols']) if 'file' in self.uri_schemes and config['file']['enabled']: logger.warning( 'The stream/protocols config value includes the "file" ' 'protocol. "file" playback is now handled by Mopidy-File. ' 'Please remove it from the stream/protocols config.') self.uri_schemes -= {'file'}
def _download(self, uri): timeout = self._config['stream']['timeout'] / 1000.0 session = http.get_requests_session( proxy_config=self._config['proxy'], user_agent='%s/%s' % (stream.Extension.dist_name, stream.Extension.version)) try: response = session.get(uri, stream=True, timeout=timeout) except requests.exceptions.Timeout: logger.warning( 'Download of stream playlist (%s) failed due to connection ' 'timeout after %.3fs', uri, timeout) return None deadline = time.time() + timeout content = [] for chunk in response.iter_content(4096): content.append(chunk) if time.time() > deadline: logger.warning( 'Download of stream playlist (%s) failed due to download ' 'taking more than %.3fs', uri, timeout) return None if not response.ok: logger.warning('Problem downloading stream playlist %s: %s', uri, response.reason) return None return b''.join(content)
def __init__(self, audio, backend, config): super(StreamPlaybackProvider, self).__init__(audio, backend) self._config = config self._scanner = backend._scanner self._session = http.get_requests_session( proxy_config=config['proxy'], user_agent='%s/%s' % (stream.Extension.dist_name, stream.Extension.version))
def __init__(self, audio, backend, config): super(StreamPlaybackProvider, self).__init__(audio, backend) self._config = config self._scanner = backend._scanner self._session = http.get_requests_session( proxy_config=config['proxy'], user_agent='%s/%s' % ( stream.Extension.dist_name, stream.Extension.version))
def __init__(self, config, audio): super(PlaylistBackend, self).__init__() self.scanner = scan.Scanner(timeout=config["playlist"]["timeout"], proxy_config=config["proxy"]) self.session = http.get_requests_session( proxy_config=config["proxy"], user_agent=(f"{mopidy_playlist.Extension.dist_name}/" f"{mopidy_playlist.Extension.version}"), ) self.timeout = config["playlist"]["timeout"] self.max_lookups = config["playlist"]["max_lookups"] self.library = PlaylistLibraryProvider(backend=self) self.uri_schemes = {"playlist", "pl"}