@@ -132,6 +132,25 @@ def generate_custom_filename(base: str, episode_tag: str, ext: str = ".mp4") ->
132132 safe_base = re .sub (r'[\\/*?:"<>|]' , "_" , base )
133133 return f"{ safe_base } _{ episode_tag } { ext } "
134134
135+ def prompt_partial_file_cleanup ():
136+ """Prompt user to keep or delete partial download files."""
137+ print ("\n [?] What would you like to do with partial downloads?" )
138+ print (" [K]eep - Keep .part files to resume later" )
139+ print (" [D]elete - Remove all .part files and start fresh next time" )
140+
141+ try :
142+ choice = input ("Your choice (K/D): " ).strip ().upper ()
143+ if choice == 'D' :
144+ print ("[*] Cleaning up temporary files..." )
145+ delpartfiles ()
146+ print ("[*] All .part files removed." )
147+ elif choice == 'K' :
148+ print ("[*] Keeping .part files for resume." )
149+ else :
150+ print ("[*] Invalid choice, keeping .part files by default." )
151+ except (EOFError , KeyboardInterrupt ):
152+ print ("\n [*] Keeping .part files by default." )
153+
135154def parse_arguments ():
136155 parser = argparse .ArgumentParser (
137156 description = "Multi-threaded downloader for video sources with advanced detection methods." ,
@@ -175,22 +194,7 @@ def main():
175194 sys .stderr .flush ()
176195
177196 # Ask user what to do with partial downloads
178- print ("\n [?] What would you like to do with partial downloads?" )
179- print (" [K]eep - Keep .part files to resume later" )
180- print (" [D]elete - Remove all .part files and start fresh next time" )
181-
182- try :
183- choice = input ("Your choice (K/D): " ).strip ().upper ()
184- if choice == 'D' :
185- print ("[*] Cleaning up temporary files..." )
186- delpartfiles ()
187- print ("[*] All .part files removed." )
188- elif choice == 'K' :
189- print ("[*] Keeping .part files for resume." )
190- else :
191- print ("[*] Invalid choice, keeping .part files by default." )
192- except (EOFError , KeyboardInterrupt ):
193- print ("\n [*] Keeping .part files by default." )
197+ prompt_partial_file_cleanup ()
194198 else :
195199 # Normal completion - clean up
196200 print ("[*] Cleaning up temporary files..." )
@@ -311,22 +315,7 @@ def list_dl(doc, args):
311315 sys .stderr .flush ()
312316
313317 # Ask user what to do with partial downloads
314- print ("\n [?] What would you like to do with partial downloads?" )
315- print (" [K]eep - Keep .part files to resume later" )
316- print (" [D]elete - Remove all .part files and start fresh next time" )
317-
318- try :
319- choice = input ("Your choice (K/D): " ).strip ().upper ()
320- if choice == 'D' :
321- print ("[*] Cleaning up temporary files..." )
322- delpartfiles ()
323- print ("[*] All .part files removed." )
324- elif choice == 'K' :
325- print ("[*] Keeping .part files for resume." )
326- else :
327- print ("[*] Invalid choice, keeping .part files by default." )
328- except (EOFError , KeyboardInterrupt ):
329- print ("\n [*] Keeping .part files by default." )
318+ prompt_partial_file_cleanup ()
330319 else :
331320 # Normal shutdown - wait for completion
332321 executor .shutdown (wait = True )
0 commit comments