@@ -76,6 +76,7 @@ def MP4_downloader(url: str, path: str, referer: str = None, headers_: dict = No
7676 - Single Ctrl+C: Completes download gracefully
7777 - Triple Ctrl+C: Saves partial download and exits
7878 """
79+ url = url .strip ()
7980 if TELEGRAM_BOT :
8081 bot = get_bot_instance ()
8182 console .log ("####" )
@@ -134,20 +135,23 @@ def MP4_downloader(url: str, path: str, referer: str = None, headers_: dict = No
134135
135136 # Create progress bar with percentage instead of n_fmt/total_fmt
136137 console .print ("[cyan]You can safely stop the download with [bold]Ctrl+c[bold] [cyan]" )
138+
137139 progress_bar = tqdm (
138140 total = total ,
139141 ascii = '░▒█' ,
140142 bar_format = f"{ Colors .YELLOW } MP4{ Colors .CYAN } Downloading{ Colors .WHITE } : "
141- f"{ Colors .RED } {{percentage:.1f}}% { Colors .MAGENTA } {{bar:40}} { Colors .WHITE } "
142- f"{ Colors .DARK_GRAY } [{ Colors .YELLOW } {{elapsed}}{ Colors .WHITE } < { Colors .CYAN } {{remaining}}{ Colors .DARK_GRAY } ] "
143- f"{ Colors .LIGHT_CYAN } {{rate_fmt}}" ,
143+ f"{ Colors .MAGENTA } {{bar:40}} "
144+ f"{ Colors .LIGHT_GREEN } {{n_fmt}}{ Colors .WHITE } /{ Colors .CYAN } {{total_fmt}}"
145+ f" { Colors .DARK_GRAY } [{ Colors .YELLOW } {{elapsed}}{ Colors .WHITE } < { Colors .CYAN } {{remaining}}{ Colors .DARK_GRAY } ]"
146+ f"{ Colors .WHITE } {{postfix}} " ,
144147 unit = 'B' ,
145148 unit_scale = True ,
146149 unit_divisor = 1024 ,
147150 mininterval = 0.05 ,
148151 file = sys .stdout
149152 )
150-
153+
154+ start_time = time .time ()
151155 downloaded = 0
152156 with open (temp_path , 'wb' ) as file , progress_bar as bar :
153157 try :
@@ -160,6 +164,14 @@ def MP4_downloader(url: str, path: str, referer: str = None, headers_: dict = No
160164 size = file .write (chunk )
161165 downloaded += size
162166 bar .update (size )
167+
168+ # Update postfix with speed and final size
169+ elapsed = time .time () - start_time
170+ if elapsed > 0 :
171+ speed = downloaded / elapsed
172+ speed_str = internet_manager .format_transfer_speed (speed )
173+ postfix_str = f"{ Colors .LIGHT_MAGENTA } @ { Colors .LIGHT_CYAN } { speed_str } "
174+ bar .set_postfix_str (postfix_str )
163175
164176 except KeyboardInterrupt :
165177 if not interrupt_handler .force_quit :
0 commit comments