Skip to content

Commit 91ee197

Browse files
committed
3.33
1 parent ec77102 commit 91ee197

6 files changed

Lines changed: 36 additions & 23 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ normalize.py
1717
new_ff_subs.py
1818
some_files/
1919
ffmpeg.exe
20+
subs_langs.json
2021
script.spec
2122
build/
2223
develop-eggs/

ReaperScript.exe

305 Bytes
Binary file not shown.

ReaperScript.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
is_reaper_run,
3636
show_help_window,
3737
set_geometry,
38+
get_subs_langs,
3839
)
3940
from help_texts import HELP_DICT
4041
from tkinter import ttk
@@ -158,7 +159,7 @@ def on_fix_check_click(master: tkinter.Tk, BUTTONS: List):
158159
master = tkinter.Tk(className='REAPERSCRIPT.main')
159160
master.geometry(set_geometry(master))
160161
master.resizable(False, False)
161-
master.title('REAPERSCRIPT v3.32')
162+
master.title('REAPERSCRIPT v3.33')
162163
master.iconbitmap(default=resource_path('ico.ico'))
163164
master.protocol('WM_DELETE_WINDOW', on_closing)
164165
style = ttk.Style()
@@ -277,16 +278,7 @@ def on_fix_check_click(master: tkinter.Tk, BUTTONS: List):
277278
ToolTip(help_btn, HELP_DICT['help'], 1)
278279
subs_extract = ttk.Label(master, text='Select subtitles to extract:')
279280
subs_extract.grid(row=0, column=0, sticky=tkinter.W, padx=6, pady=9)
280-
SUBS_LANGS_LIST = [
281-
'Russia',
282-
'US',
283-
'Saudi Arabia',
284-
'Germany',
285-
'Latin America',
286-
'France',
287-
'Italy',
288-
'Brasil',
289-
]
281+
SUBS_LANGS_LIST = list(get_subs_langs().keys())
290282
menu = ttk.Combobox(
291283
master,
292284
values=SUBS_LANGS_LIST,

file_works.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
NO_FOLDER,
1616
IN_USE,
1717
)
18+
from window_utils import get_subs_langs
1819
import tkinter.messagebox
1920
import asstosrt
2021
import pysubs2
@@ -25,17 +26,6 @@
2526
import re
2627
import os
2728

28-
SUBS_LANGS_DICT = {
29-
'Russia': 'rus',
30-
'US': 'eng',
31-
'Saudi Arabia': 'ara',
32-
'Germany': 'ger',
33-
'Latin America': 'spa',
34-
'France': 'fre',
35-
'Italy': 'ita',
36-
'Brasil': 'por'
37-
}
38-
3929

4030
def resource_path(path):
4131
try:
@@ -288,7 +278,7 @@ def file_works(folder: str) -> (
288278
if get_option('subs_cleaner'):
289279
subs_edit(subs, 'srt')
290280
else:
291-
lang = SUBS_LANGS_DICT[config['SUBS']['subs_lang']]
281+
lang = get_subs_langs()[config['SUBS']['subs_lang']]
292282
try_sub = f'0:s:m:language:{lang}'
293283
eng_sub = '0:s:m:language:eng'
294284
any_sub = '0:s:m:language:?'

help_texts.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@
7373
'"Select subtitles to extract:",\n'
7474
'если их нет - то английские.\n'
7575
'В случае, когда нет ни того, ни другого - извлекаются первые доступные.\n'
76+
'После запуска, рядом с "ReaperScript.exe" появится '
77+
'"subs_langs.json".\n'
78+
'В него можно добавить нужные языки для извлечения,\n'
79+
'в формате "КЛЮЧ": "ЗНАЧЕНИЕ".\n'
7680
'Для работы этой функции в системе должен быть ffmpeg.\n'
7781
'\n'
7882
'Для работы функции "render_video" в системе должен быть ffmpeg.\n'

window_utils.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@
33
from typing import List
44
import tkinter
55
import win32gui
6+
import os
7+
import json
8+
9+
10+
SUBS_LANGS_DICT = {
11+
'Russia': 'rus',
12+
'US': 'eng',
13+
'Saudi Arabia': 'ara',
14+
'Germany': 'ger',
15+
'Latin America': 'spa',
16+
'France': 'fre',
17+
'Italy': 'ita',
18+
'Brasil': 'por'
19+
}
620

721

822
def wait():
@@ -93,5 +107,17 @@ def set_geometry(master: tkinter.Tk):
93107
return f'{width}x{height}+{x}+{y - upper}'
94108

95109

110+
def get_subs_langs():
111+
if not os.path.exists('subs_langs.json'):
112+
with open('subs_langs.json', 'w+') as json_file:
113+
data = {}
114+
for key, value in SUBS_LANGS_DICT.items():
115+
data[key] = value
116+
json.dump(data, json_file)
117+
with open('subs_langs.json', 'r') as json_file:
118+
data = json.load(json_file)
119+
return data
120+
121+
96122
if __name__ == '__main__':
97123
pass

0 commit comments

Comments
 (0)