Add proxy/port to configuration
This commit is contained in:
parent
608b9c9b6c
commit
de80c33753
@ -33,9 +33,14 @@ class SpotifySessionManager(process.BaseThread, PyspotifySessionManager):
|
||||
self.cache_location = config['spotify']['cache_dir']
|
||||
self.settings_location = config['spotify']['cache_dir']
|
||||
|
||||
# Add proxy port only if available
|
||||
full_proxy = config['proxy']['hostname']
|
||||
if 'port' in config['proxy']:
|
||||
full_proxy = full_proxy + ':' + str(config['proxy']['port'])
|
||||
|
||||
PyspotifySessionManager.__init__(
|
||||
self, config['spotify']['username'], config['spotify']['password'],
|
||||
proxy=config['proxy']['hostname'],
|
||||
proxy=full_proxy,
|
||||
proxy_username=config['proxy']['username'],
|
||||
proxy_password=config['proxy']['password'])
|
||||
|
||||
|
||||
@ -29,6 +29,7 @@ _proxy_schema = ConfigSchema('proxy')
|
||||
_proxy_schema['hostname'] = Hostname(optional=True)
|
||||
_proxy_schema['username'] = String(optional=True)
|
||||
_proxy_schema['password'] = Secret(optional=True)
|
||||
_proxy_schema['port'] = Port(optional=True)
|
||||
|
||||
# NOTE: if multiple outputs ever comes something like LogLevelConfigSchema
|
||||
#_outputs_schema = config.AudioOutputConfigSchema()
|
||||
|
||||
@ -39,6 +39,7 @@ def convert(settings):
|
||||
helper('audio/output', 'OUTPUT')
|
||||
|
||||
helper('proxy/hostname', 'SPOTIFY_PROXY_HOST')
|
||||
helper('proxy/port', 'SPOTIFY_PROXY_PORT')
|
||||
helper('proxy/username', 'SPOTIFY_PROXY_USERNAME')
|
||||
helper('proxy/password', 'SPOTIFY_PROXY_PASSWORD')
|
||||
|
||||
|
||||
@ -16,3 +16,4 @@ output = autoaudiosink
|
||||
hostname =
|
||||
username =
|
||||
password =
|
||||
port =
|
||||
@ -117,7 +117,10 @@ class Integer(ConfigValue):
|
||||
self._choices = choices
|
||||
|
||||
def deserialize(self, value):
|
||||
value = int(value)
|
||||
try:
|
||||
value = int(value)
|
||||
except:
|
||||
value = 0
|
||||
validators.validate_choice(value, self._choices)
|
||||
validators.validate_minimum(value, self._minimum)
|
||||
validators.validate_maximum(value, self._maximum)
|
||||
@ -222,7 +225,8 @@ class Port(Integer):
|
||||
allocate a port for us.
|
||||
"""
|
||||
# TODO: consider probing if port is free or not?
|
||||
def __init__(self, choices=None):
|
||||
def __init__(self, choices=None, optional=False):
|
||||
self._required = not optional
|
||||
super(Port, self).__init__(
|
||||
minimum=0, maximum=2 ** 16 - 1, choices=choices)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user