Try fix _tmp on linux

This commit is contained in:
Lovi 2025-02-08 17:16:56 +01:00
parent 54567a8711
commit 335d97ec2d
4 changed files with 26 additions and 21 deletions

View File

@ -384,7 +384,6 @@ class M3U8_Segments:
return (
f"{Colors.YELLOW}Proc{Colors.WHITE}: "
f"{Colors.RED}{{percentage:.2f}}% "
f"{Colors.WHITE}| "
f"{Colors.CYAN}{{remaining}}{{postfix}} {Colors.WHITE}]"
)

View File

@ -127,16 +127,16 @@ class M3U8_Ts_Estimator:
retry_count = self.segments_instance.active_retries if self.segments_instance else 0
progress_str = (
#f"{Colors.WHITE}[ {Colors.GREEN}{number_file_downloaded} {Colors.WHITE}< "
f"{Colors.GREEN}{number_file_total_size} {Colors.RED}{units_file_total_size} "
f"{Colors.WHITE}| {Colors.CYAN}{average_internet_speed} {Colors.RED}{average_internet_unit} "
f"{Colors.WHITE}| {Colors.GREEN}CRR {Colors.RED}{retry_count}"
f"{Colors.GREEN}{number_file_total_size} {Colors.RED}{units_file_total_size}"
f"{Colors.WHITE} {Colors.CYAN}{average_internet_speed} {Colors.RED}{average_internet_unit}"
f"{Colors.WHITE} {Colors.GREEN}CRR {Colors.RED}{retry_count} "
)
else:
retry_count = self.segments_instance.active_retries if self.segments_instance else 0
progress_str = (
#f"{Colors.WHITE}[ {Colors.GREEN}{number_file_downloaded} {Colors.WHITE}< "
f"{Colors.GREEN}{number_file_total_size} {Colors.RED}{units_file_total_size} "
f"{Colors.WHITE}| {Colors.GREEN}CRR {Colors.RED}{retry_count}"
f"{Colors.GREEN}{number_file_total_size} {Colors.RED}{units_file_total_size}"
f"{Colors.WHITE} {Colors.GREEN}CRR {Colors.RED}{retry_count} "
)
progress_counter.set_postfix_str(progress_str)

View File

@ -202,20 +202,26 @@ class OsManager:
"""
try:
# List all files in the folder
files_in_folder = os.listdir(folder_path)
# Iterate over each file in the folder
for file_name in files_in_folder:
file_path = os.path.join(folder_path, file_name)
# Check if the file is not the one to keep and is a regular file
if file_name != keep_file and os.path.isfile(file_path):
os.remove(file_path) # Delete the file
# First, try to make all files writable
for root, dirs, files in os.walk(self.temp_dir):
for dir_name in dirs:
dir_path = os.path.join(root, dir_name)
os.chmod(dir_path, 0o755) # rwxr-xr-x
for file_name in files:
file_path = os.path.join(root, file_name)
os.chmod(file_path, 0o644) # rw-r--r--
# Then remove the directory tree
shutil.rmtree(self.temp_dir, ignore_errors=True)
# If directory still exists after rmtree, try force remove
if os.path.exists(self.temp_dir):
import subprocess
subprocess.run(['rm', '-rf', self.temp_dir], check=True)
except Exception as e:
logging.error(f"An error occurred: {e}")
raise
logging.error(f"Failed to cleanup temporary directory: {str(e)}")
pass
def check_file(self, file_path: str) -> bool:
"""

View File

@ -22,7 +22,7 @@
"telegram_bot": false
},
"REQUESTS": {
"timeout": 20,
"timeout": 25,
"max_retry": 8,
"proxy_start_min": 0.1,
"proxy_start_max": 0.5
@ -31,7 +31,7 @@
"tqdm_delay": 0.01,
"default_video_workser": 12,
"default_audio_workser": 12,
"segment_timeout": 7,
"segment_timeout": 8,
"download_audio": true,
"merge_audio": true,
"specific_list_audio": [