Define max number of proxy errors
This commit is contained in:
parent
5f7622cac1
commit
b0d280678d
1 changed files with 12 additions and 0 deletions
|
@ -169,6 +169,12 @@ class GetYoutubeVideos:
|
|||
self._default_data['proxies'][self.selected_proxy]['failures'] += 1
|
||||
previous_proxy = self.selected_proxy
|
||||
for proxy in self._default_data['proxies']:
|
||||
if self.config['max_proxy_failures'] < self._default_data['proxies'][proxy]['failures']:
|
||||
self._log.error(
|
||||
"Reached the maximum number of proxy failures (%s)",
|
||||
self.config['max_proxy_failures']
|
||||
)
|
||||
return False
|
||||
if (
|
||||
less_failures == -1 or
|
||||
self._default_data['proxies'][proxy]['failures'] < less_failures
|
||||
|
@ -675,6 +681,12 @@ class GetYoutubeVideos:
|
|||
default=60*60*24*7,
|
||||
help='Max age in seconds for the cache'
|
||||
)
|
||||
@click.option(
|
||||
'--max-proxy-failures',
|
||||
'-A',
|
||||
default=3,
|
||||
help='Maximum number of failures for proxies to reach'
|
||||
)
|
||||
@click_config_file.configuration_option()
|
||||
def __main__(**kwargs):
|
||||
obj = GetYoutubeVideos(**kwargs)
|
||||
|
|
Loading…
Reference in a new issue