|
63 | 63 | from Logger import Logger # For logging output to both terminal and file |
64 | 64 | from pathlib import Path # For handling file paths |
65 | 65 | from shutil import copyfile # For copying files |
| 66 | +from tqdm import tqdm # For progress bars |
66 | 67 |
|
67 | 68 | # Macros: |
68 | 69 | class BackgroundColors: # Colors for the terminal |
@@ -332,17 +333,19 @@ def main(): |
332 | 333 | print(f"No .srt files found in directory: {INPUT_DIR}") # Output message |
333 | 334 | return # Exit the program |
334 | 335 |
|
335 | | - for srt_file in srt_files: # Iterate through each SRT file |
336 | | - print(f"{BackgroundColors.GREEN}Processing file: {BackgroundColors.CYAN}{srt_file}{Style.RESET_ALL}") |
| 336 | + for srt_file in tqdm(srt_files, desc=f"{BackgroundColors.GREEN}Translating SRT files{Style.RESET_ALL}", unit="file"): # Iterate through each SRT file with progress bar |
| 337 | + tqdm.write(f"{BackgroundColors.GREEN}Processing file: {BackgroundColors.CYAN}{srt_file}{Style.RESET_ALL}") # Show current file |
| 338 | + |
337 | 339 | srt_lines = read_srt(srt_file) # Read SRT |
| 340 | + |
338 | 341 | translated_lines = translate_srt_lines(srt_lines) # Translate |
339 | | - |
| 342 | + |
340 | 343 | relative_path = srt_file.relative_to(INPUT_DIR).parent # Get relative path |
341 | 344 | output_subdir = OUTPUT_DIR / relative_path # Create output subdirectory path |
342 | | - output_subdir.mkdir(parents=True, exist_ok=True) # Create output subdirectory if it doesn't exist |
343 | | - |
| 345 | + output_subdir.mkdir(parents=True, exist_ok=True) # Ensure output subdir exists |
| 346 | + |
344 | 347 | output_file = output_subdir / f"{srt_file.stem}_ptBR.srt" # Build output file path |
345 | | - save_srt(translated_lines, output_file) # Save translated SRT |
| 348 | + save_srt(translated_lines, output_file) # Save translated SRT |
346 | 349 |
|
347 | 350 | finish_time = datetime.datetime.now() # Get the finish time of the program |
348 | 351 | print(f"{BackgroundColors.GREEN}Start time: {BackgroundColors.CYAN}{start_time.strftime('%d/%m/%Y - %H:%M:%S')}\n{BackgroundColors.GREEN}Finish time: {BackgroundColors.CYAN}{finish_time.strftime('%d/%m/%Y - %H:%M:%S')}\n{BackgroundColors.GREEN}Execution time: {BackgroundColors.CYAN}{calculate_execution_time(start_time, finish_time)}{Style.RESET_ALL}") # Output start, finish, and execution times |
|
0 commit comments