-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (30 loc) · 964 Bytes
/
main.py
File metadata and controls
38 lines (30 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import sys
import os
import delay
def print_output(output):
if output == 0:
print(f'Subtitles delayed successfully.')
else:
print('Error in delaying subtitles.')
def main():
if len(sys.argv) != 3:
print('Usage: python main.py <srt file> <delay (in sec)>')
quit()
file_name = sys.argv[1]
delay_time = sys.argv[2]
if file_name == '.':
for each_file in sorted(os.listdir()):
if each_file.endswith('.srt'):
output = delay.subs_delay(each_file, delay_time)
print_output(output)
break
elif file_name == '*':
for each_file in sorted(os.listdir()):
if each_file.endswith('.srt'):
output = delay.subs_delay(each_file, delay_time)
print_output(output)
else:
output = delay.subs_delay(file_name, delay_time)
print_output(output)
if __name__ == '__main__':
main()