-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.py
35 lines (30 loc) · 1.38 KB
/
cli.py
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
import info
import subtitles
import subprocess
import sys
def placeholder():
print('This temporary placeholder function does nothing.')
def main():
options = {
1: ('Print video info', info.print_video_info_for_all),
2: ('Merge subtitles', subtitles.encode_subtitles_into_all_media_files),
3: ('Shift subtitles', lambda: subtitles.encode_subtitles_into_all_media_files(shift = True)),
4: ('Merge subtitles from other video files', subtitles.encode_subtitles_from_others_into_all_media_files),
5: ('Merge subtitles from other video files in multiple folders (Experimental)', subtitles.encode_subtitles_from_others_into_all_media_files_in_multiple_directories)
}
print()
for k, v in options.items():
print(k, ') ', v[0], sep = '')
try:
subprocess.run(['ffmpeg', '-version'], stdout = subprocess.DEVNULL, stderr = subprocess.DEVNULL, check = True)
subprocess.run(['mediainfo', '--Version'], stdout = subprocess.DEVNULL, stderr = subprocess.DEVNULL, check = True)
optionSelected = int(input('\nChoose an option: '))
print()
options.get(optionSelected, ('Exit gracefully', lambda: 0))[1]()
except KeyboardInterrupt:
print('\nInterrupted! Exiting gracefully.')
except Exception as error:
print(error)
return 1
if __name__ == '__main__':
sys.exit(main())