fix script not downloading when list_proxy is empty

This commit is contained in:
Francesco Grazioso 2024-06-11 20:49:10 +02:00
parent 35a410c3c6
commit edc6efab69
2 changed files with 7 additions and 5 deletions

View File

@ -158,7 +158,8 @@ class M3U8_Segments:
console.log(f"[cyan]N. Valid ip: [red]{len(self.valid_proxy)}") console.log(f"[cyan]N. Valid ip: [red]{len(self.valid_proxy)}")
if len(self.valid_proxy) == 0: if len(self.valid_proxy) == 0:
sys.exit(0) console.log("[red]No valid ip found. Will use default ip.")
#sys.exit(0)
def get_info(self) -> None: def get_info(self) -> None:
""" """
@ -193,7 +194,7 @@ class M3U8_Segments:
start_time = time.time() start_time = time.time()
# Make request to get content # Make request to get content
if THERE_IS_PROXY_LIST: if THERE_IS_PROXY_LIST and len(self.valid_proxy) > 0:
proxy = self.valid_proxy[index % len(self.valid_proxy)] proxy = self.valid_proxy[index % len(self.valid_proxy)]
logging.info(f"Use proxy: {proxy}") logging.info(f"Use proxy: {proxy}")
@ -282,11 +283,11 @@ class M3U8_Segments:
# Ff proxy avaiable set max_workers to number of proxy # Ff proxy avaiable set max_workers to number of proxy
# else set max_workers to TQDM_MAX_WORKER # else set max_workers to TQDM_MAX_WORKER
max_workers = len(self.valid_proxy) if THERE_IS_PROXY_LIST else TQDM_MAX_WORKER max_workers = len(self.valid_proxy) if THERE_IS_PROXY_LIST and len(self.valid_proxy) > 0 else TQDM_MAX_WORKER
# if proxy avaiable set timeout to variable time # if proxy avaiable set timeout to variable time
# else set timeout to TDQM_DELAY_WORKER # else set timeout to TDQM_DELAY_WORKER
if THERE_IS_PROXY_LIST: if THERE_IS_PROXY_LIST and len(self.valid_proxy) > 0:
num_proxies = len(self.valid_proxy) num_proxies = len(self.valid_proxy)
self.working_proxy_list = self.valid_proxy self.working_proxy_list = self.valid_proxy

View File

@ -5,3 +5,4 @@ tqdm
m3u8 m3u8
unidecode unidecode
fake-useragent fake-useragent
urllib3