diff --git a/slixfeed/__main__.py b/slixfeed/__main__.py index ce8f213..10a94fa 100644 --- a/slixfeed/__main__.py +++ b/slixfeed/__main__.py @@ -190,6 +190,9 @@ def main(): config_dir = config.get_default_config_directory() logging.info('Reading configuration from {}'.format(config_dir)) print('Reading configuration from {}'.format(config_dir)) + network_settings = config.get_values('settings.toml', 'network') + print('User agent:', network_settings['user_agent'] or 'Slixfeed/0.1') + if network_settings['http_proxy']: print('HTTP Proxy:', network_settings['http_proxy']) # values = config.get_value('accounts', 'XMPP Proxy', # ['socks5_host', 'socks5_port']) diff --git a/slixfeed/fetch.py b/slixfeed/fetch.py index f0ff0dc..1b89ff1 100644 --- a/slixfeed/fetch.py +++ b/slixfeed/fetch.py @@ -119,11 +119,10 @@ async def http(url): msg: list or str Document or error message. """ - user_agent = (config.get_values('settings.toml', 'network')['user_agent'] - or 'Slixfeed/0.1') + network_settings = config.get_values('settings.toml', 'network') + user_agent = (network_settings['user_agent'] or 'Slixfeed/0.1') headers = {'User-Agent': user_agent} - proxy = (config.get_values('settings.toml', 'network')['http_proxy'] - or None) + proxy = (network_settings['http_proxy'] or None) timeout = ClientTimeout(total=10) async with ClientSession(headers=headers) as session: # async with ClientSession(trust_env=True) as session: