reset list of proxies
This commit is contained in:
parent
c9e9e20293
commit
1fb92df315
1 changed files with 9 additions and 7 deletions
|
@ -63,6 +63,7 @@ class GetYoutubeVideos:
|
|||
}
|
||||
if len(self.config['proxy']) > 0:
|
||||
self.selected_proxy = self.config['proxy'][0]
|
||||
self.proxies = self.config['proxy']
|
||||
else:
|
||||
self.selected_proxy = ''
|
||||
self.proxy_index = 0
|
||||
|
@ -107,15 +108,15 @@ class GetYoutubeVideos:
|
|||
os.chmod('/var/lib/prometheus/node-exporter/get_youtube_videos.prom', stat.S_IROTH)
|
||||
|
||||
def _change_proxy(self, video_id):
|
||||
if len(self.config['proxy']) > 0:
|
||||
if isinstance(self.config['proxy'], list):
|
||||
if len(self.proxies) > 0:
|
||||
if isinstance(self.proxies, list):
|
||||
self._log.debug(
|
||||
"Removing failing proxy '%s'",
|
||||
self.selected_proxy
|
||||
)
|
||||
self.config['proxy'].pop(self.proxy_index)
|
||||
if self.proxy_index<len(self.config['proxy'])-1:
|
||||
self.selected_proxy = self.config['proxy'][self.proxy_index]
|
||||
self.proxies.pop(self.proxy_index)
|
||||
if self.proxy_index<len(self.proxies)-1:
|
||||
self.selected_proxy = self.proxies[self.proxy_index]
|
||||
self.proxy_index += 1
|
||||
self._log.warning(
|
||||
"Got an error fetching video information. Setting proxy to '%s'...",
|
||||
|
@ -123,10 +124,11 @@ class GetYoutubeVideos:
|
|||
)
|
||||
return self._get_video_info(video_id)
|
||||
self._log.debug(
|
||||
"No more proxies to try"
|
||||
"No more proxies to try. Resetting list."
|
||||
)
|
||||
self.proxy_index = 0
|
||||
self.selected_proxy = ''
|
||||
self.proxies = self.config['proxy']
|
||||
self.selected_proxy = self.proxies[0]
|
||||
return None
|
||||
|
||||
def _get_video_info(self, video_id):
|
||||
|
|
Loading…
Reference in a new issue