Skip to content

Commit e363a1a

Browse files
committed
Add language code to subtitle file name
Fixes #75
1 parent d183bc5 commit e363a1a

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

VideOCR.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# Windows-specific metadata for the executable
1313
# nuitka-project-if: {OS} == "Windows":
1414
# nuitka-project: --file-description="VideOCR"
15-
# nuitka-project: --file-version="1.3.2"
15+
# nuitka-project: --file-version="1.3.3"
1616
# nuitka-project: --product-name="VideOCR-GUI"
17-
# nuitka-project: --product-version="1.3.2"
17+
# nuitka-project: --product-version="1.3.3"
1818
# nuitka-project: --copyright="timminator"
1919
# nuitka-project: --windows-icon-from-ico=Installer/VideOCR.ico
2020

@@ -166,7 +166,7 @@ def find_videocr_program():
166166

167167

168168
# --- Configuration ---
169-
PROGRAM_VERSION = "1.3.2"
169+
PROGRAM_VERSION = "1.3.3"
170170
APP_DIR = os.path.dirname(os.path.abspath(__file__))
171171
LANGUAGES_DIR = os.path.join(APP_DIR, 'languages')
172172
VIDEOCR_PATH = find_videocr_program()
@@ -773,7 +773,7 @@ def load_settings(window):
773773

774774

775775
def generate_output_path(video_path, values, default_dir=DEFAULT_DOCUMENTS_DIR):
776-
"""Generates a unique output file path for the SRT file based on video path and settings."""
776+
"""Generates a unique output file path for the SRT file based on video path, settings and language."""
777777
video_file_path = pathlib.Path(video_path)
778778
video_filename_stem = video_file_path.stem
779779

@@ -787,11 +787,14 @@ def generate_output_path(video_path, values, default_dir=DEFAULT_DOCUMENTS_DIR):
787787
else:
788788
output_dir = pathlib.Path(output_dir_str)
789789

790-
base_output_path = output_dir / f"{video_filename_stem}.srt"
790+
selected_lang_name = values.get('-LANG_COMBO-', default_display_language)
791+
lang_code = language_abbr_lookup.get(selected_lang_name, 'en')
792+
793+
base_output_path = output_dir / f"{video_filename_stem}.{lang_code}.srt"
791794
output_path = base_output_path
792795
counter = 1
793796
while output_path.exists():
794-
output_path = output_dir / f"{video_filename_stem}({counter}).srt"
797+
output_path = output_dir / f"{video_filename_stem}({counter}).{lang_code}.srt"
795798
counter += 1
796799

797800
return output_path
@@ -1419,7 +1422,7 @@ def on_releases_leave(event):
14191422
save_settings(window, values)
14201423

14211424
# --- Handle possible output path change ---
1422-
if event == '--save_in_video_dir':
1425+
if event == '--save_in_video_dir' or event == '-LANG_COMBO-':
14231426
if (values.get('--save_in_video_dir', True)):
14241427
window['-BTN-FOLDER_BROWSE-'].update(disabled=True)
14251428
else:

0 commit comments

Comments
 (0)