mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 12:05:35 +00:00
add start delay
This commit is contained in:
parent
48f39042ae
commit
8835eeff2e
@ -44,6 +44,7 @@ TQDM_MAX_WORKER = config_manager.get_int('M3U8_DOWNLOAD', 'tdqm_workers')
|
|||||||
TQDM_USE_LARGE_BAR = config_manager.get_int('M3U8_DOWNLOAD', 'tqdm_use_large_bar')
|
TQDM_USE_LARGE_BAR = config_manager.get_int('M3U8_DOWNLOAD', 'tqdm_use_large_bar')
|
||||||
REQUEST_TIMEOUT = config_manager.get_float('REQUESTS', 'timeout')
|
REQUEST_TIMEOUT = config_manager.get_float('REQUESTS', 'timeout')
|
||||||
PROXY_LIST = config_manager.get_list('REQUESTS', 'proxy')
|
PROXY_LIST = config_manager.get_list('REQUESTS', 'proxy')
|
||||||
|
START_THREAD_DELAY = 0.05
|
||||||
|
|
||||||
|
|
||||||
# Variable
|
# Variable
|
||||||
@ -210,6 +211,8 @@ class M3U8_Segments:
|
|||||||
- index (int): The index of the segment.
|
- index (int): The index of the segment.
|
||||||
- progress_bar (tqdm): Progress counter for tracking download progress.
|
- progress_bar (tqdm): Progress counter for tracking download progress.
|
||||||
"""
|
"""
|
||||||
|
global START_THREAD_DELAY
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
# Generate headers
|
# Generate headers
|
||||||
@ -283,6 +286,8 @@ class M3U8_Segments:
|
|||||||
Args:
|
Args:
|
||||||
- add_desc (str): Additional description for the progress bar.
|
- add_desc (str): Additional description for the progress bar.
|
||||||
"""
|
"""
|
||||||
|
global START_THREAD_DELAY
|
||||||
|
|
||||||
if TQDM_USE_LARGE_BAR:
|
if TQDM_USE_LARGE_BAR:
|
||||||
bar_format=f"{Colors.YELLOW}Downloading {Colors.WHITE}({add_desc}{Colors.WHITE}): {Colors.RED}{{percentage:.2f}}% {Colors.MAGENTA}{{bar}} {Colors.WHITE}[ {Colors.YELLOW}{{n_fmt}}{Colors.WHITE} / {Colors.RED}{{total_fmt}} {Colors.WHITE}] {Colors.YELLOW}{{elapsed}} {Colors.WHITE}< {Colors.CYAN}{{remaining}}{{postfix}} {Colors.WHITE}]"
|
bar_format=f"{Colors.YELLOW}Downloading {Colors.WHITE}({add_desc}{Colors.WHITE}): {Colors.RED}{{percentage:.2f}}% {Colors.MAGENTA}{{bar}} {Colors.WHITE}[ {Colors.YELLOW}{{n_fmt}}{Colors.WHITE} / {Colors.RED}{{total_fmt}} {Colors.WHITE}] {Colors.YELLOW}{{elapsed}} {Colors.WHITE}< {Colors.CYAN}{{remaining}}{{postfix}} {Colors.WHITE}]"
|
||||||
else:
|
else:
|
||||||
@ -303,6 +308,7 @@ class M3U8_Segments:
|
|||||||
# Start all workers
|
# Start all workers
|
||||||
with ThreadPoolExecutor(max_workers=TQDM_MAX_WORKER) as executor:
|
with ThreadPoolExecutor(max_workers=TQDM_MAX_WORKER) as executor:
|
||||||
for index, segment_url in enumerate(self.segments):
|
for index, segment_url in enumerate(self.segments):
|
||||||
|
time.sleep(START_THREAD_DELAY)
|
||||||
executor.submit(self.make_requests_stream, segment_url, index, progress_bar)
|
executor.submit(self.make_requests_stream, segment_url, index, progress_bar)
|
||||||
|
|
||||||
# Wait for all tasks to complete
|
# Wait for all tasks to complete
|
||||||
|
Loading…
x
Reference in New Issue
Block a user