-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
37 lines (32 loc) · 1.54 KB
/
cli.py
File metadata and controls
37 lines (32 loc) · 1.54 KB
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
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: ('Extract subtitles', subtitles.extract_subtitles_from_all_media_files),
3: ('Merge subtitles', subtitles.encode_subtitles_into_all_media_files),
4: ('Auto sync subtitles', subtitles.sync_subtitles_with_all_media_files),
5: ('Shift subtitles', lambda: subtitles.encode_subtitles_into_all_media_files(shift = True)),
6: ('Merge subtitles from other video files', subtitles.encode_subtitles_from_others_into_all_media_files),
7: ('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())