|
14 | 14 |
|
15 | 15 |
|
16 | 16 |
|
17 |
| -def main(): |
18 |
| - parser = argparse.ArgumentParser(description="fix duplicate lines in srt converted youtube auto generated subtitles") |
19 |
| - parser.add_argument("input", nargs="?", help="Input subtitle file.") |
20 |
| - parser.add_argument("-o", "--output", help="Output subtitle file.") |
21 |
| - parser.add_argument("-idir", "--input-directory", help="Input directory containing subtitle files.") |
22 |
| - parser.add_argument("-odir", "--output-directory", help="Output directory for processed subtitle files.") |
23 |
| - args = parser.parse_args() |
24 |
| - input_directory = args.input_directory |
25 |
| - output_directory = args.output_directory |
26 |
| - |
27 |
| - if input_directory: |
28 |
| - if not os.path.isdir(input_directory): |
29 |
| - print(f"Input directory '{input_directory}' does not exist or is not accessible.") |
30 |
| - return |
31 |
| - |
32 |
| - if not output_directory: |
33 |
| - output_directory = input_directory |
34 |
| - |
35 |
| - if not os.path.exists(output_directory): |
36 |
| - os.makedirs(output_directory) |
37 |
| - |
38 |
| - if not TQDM_INSTALLED: |
39 |
| - filelist = os.listdir(input_directory) |
40 |
| - filecount = len(filelist) |
41 |
| - counter = 1 |
42 |
| - for file in filelist: |
43 |
| - deciles = int(counter / filecount * 20) |
44 |
| - print(f"processing SRT files:|{'█' * deciles}{' ' * (20 - deciles)}| {counter}/{filecount}", end='\r') |
45 |
| - if counter == filecount: |
46 |
| - print("\n", end="\r") |
47 |
| - counter += 1 |
48 |
| - if file.endswith(".srt"): |
49 |
| - file_path = os.path.join(input_directory, file) |
50 |
| - new_file_path = os.path.join(output_directory, file[:-4] + ".fixed.srt") |
51 |
| - process_srt(file_path, new_file_path) |
52 |
| - else: |
53 |
| - for file in tqdm(os.listdir(input_directory), desc="Processing SRT files", unit="file", |
54 |
| - bar_format='{l_bar}{bar:10}{r_bar}{bar:-10b}'): |
55 |
| - if file.endswith(".srt"): |
56 |
| - file_path = os.path.join(input_directory, file) |
57 |
| - new_file_path = os.path.join(output_directory, file[:-4] + ".fixed.srt") |
58 |
| - process_srt(file_path, new_file_path) |
59 |
| - else: |
60 |
| - file_path = args.input |
61 |
| - if not file_path or not os.path.isfile(file_path): |
62 |
| - print(f"Input file '{file_path}' does not exist or is not accessible.") |
63 |
| - return |
64 |
| - |
65 |
| - new_file_path = args.output or file_path[:-4] + ".fixed.srt" |
66 |
| - process_srt(file_path, new_file_path) |
67 |
| - |
68 |
| - |
69 |
| - |
70 |
| - |
71 |
| -if __name__ == "__main__": |
72 |
| - main() |
73 |
| - |
74 |
| - |
75 |
| - |
76 | 17 | import tkinter as tk
|
77 | 18 | from tkinter import ttk, filedialog
|
78 | 19 | import os
|
@@ -137,6 +78,7 @@ def fix_subtitles():
|
137 | 78 | input_folder_path = tk.StringVar()
|
138 | 79 | output_dir_path = tk.StringVar()
|
139 | 80 |
|
| 81 | + |
140 | 82 | input_file_label = ttk.Label(root, text="Input subtitle file:")
|
141 | 83 | input_file_entry = ttk.Entry(root, textvariable=input_file_path)
|
142 | 84 | input_file_button = ttk.Button(root, text="Browse", command=open_input_file)
|
|
0 commit comments