Skip to content

Commit a89938d

Browse files
authored
Merge pull request #27 from DoobyDouglas/develop
3.24
2 parents 9dd22fb + a9d4e59 commit a89938d

7 files changed

Lines changed: 107 additions & 52 deletions

File tree

ReaperScript.exe

-6.56 KB
Binary file not shown.

ReaperScript.py

Lines changed: 68 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
buttons_active,
3535
is_reaper_run,
3636
show_help_window,
37+
set_geometry,
3738
)
3839
from help_texts import HELP_DICT
3940
from tkinter import ttk
@@ -83,7 +84,7 @@ def reaper_main(
8384
BUTTONS: List
8485
) -> None:
8586
"""Основная функция"""
86-
save_options(checkboxes)
87+
save_options(master, checkboxes)
8788
project_path = load_path('project_path')
8889
if not project_path:
8990
path_choice('project_path')
@@ -116,7 +117,7 @@ def reaper_main(
116117
if get_option('split'):
117118
split(project)
118119
project.save(False)
119-
if get_option('normalize'):
120+
if get_option('normalize_dubbers') and get_option('normalize_video'):
120121
normalize(project, 'all')
121122
if get_option('normalize_dubbers'):
122123
normalize(project, 'dubbers')
@@ -135,8 +136,15 @@ def reaper_main(
135136
master.focus_force()
136137

137138

138-
def on_start_click(checkboxes: Dict, master: tkinter.Tk, BUTTONS: List):
139-
thread = Thread(target=reaper_main, args=(checkboxes, master, BUTTONS))
139+
def on_start_click(
140+
checkboxes: Dict,
141+
master: tkinter.Tk,
142+
BUTTONS: List
143+
):
144+
thread = Thread(
145+
target=reaper_main,
146+
args=(checkboxes, master, BUTTONS)
147+
)
140148
thread.start()
141149

142150

@@ -146,42 +154,35 @@ def on_fix_check_click(master: tkinter.Tk, BUTTONS: List):
146154

147155

148156
master = tkinter.Tk(className='REAPERSCRIPT.main')
149-
width = 380
150-
height = 440
151-
s_width = master.winfo_screenwidth()
152-
s_height = master.winfo_screenheight()
153-
upper = s_height // 8
154-
x = (s_width - width) // 2
155-
y = (s_height - height) // 2
156-
master.geometry(f'{width}x{height}+{x}+{y - upper}')
157-
master.resizable(width=False, height=False)
158-
master.title('REAPERSCRIPT v3.22')
157+
master.geometry(set_geometry(master))
158+
master.resizable(False, False)
159+
master.title('REAPERSCRIPT v3.24')
159160
master.iconbitmap(default=resource_path('ico.ico'))
160-
img = Image.open(resource_path('background.png'))
161-
tk_img = ImageTk.PhotoImage(img)
162-
background_label = tkinter.Label(master, image=tk_img)
163-
background_label.place(x=0, y=0, relwidth=1, relheight=1)
164161
master.protocol('WM_DELETE_WINDOW', on_closing)
162+
style = ttk.Style()
163+
style.configure('TCheckbutton', background='#ffc0cb')
164+
style.configure('TButton', background='#ffc0cb')
165+
style.configure('TLabel', background='#ffc0cb')
166+
style.configure('TButton', width=13)
167+
raw_img = Image.open(resource_path('background.png'))
168+
image = ImageTk.PhotoImage(raw_img)
169+
background = tkinter.Label(master, image=image)
170+
background.place(x=0, y=0, relwidth=1, relheight=1)
171+
config = get_config()
172+
checkboxes = {}
165173
OPTIONS = [
166174
'noise_reduction',
167175
'volume_up_dubbers',
168176
'subs_cleaner',
169177
'sub_region',
170178
'sub_item',
171179
'split',
172-
'normalize',
173180
'normalize_dubbers',
174181
'normalize_video',
175182
'fix_check',
176183
'render_audio',
177184
'render_video',
178185
]
179-
config = get_config()
180-
checkboxes = {}
181-
checkbox_style = ttk.Style()
182-
checkbox_style.configure('TCheckbutton', background='#ffc0cb')
183-
button_style = ttk.Style()
184-
button_style.configure('TButton', background='#ffc0cb')
185186
for i, option in enumerate(OPTIONS):
186187
var = tkinter.BooleanVar()
187188
if option in config['OPTIONS']:
@@ -192,10 +193,10 @@ def on_fix_check_click(master: tkinter.Tk, BUTTONS: List):
192193
master,
193194
text=option,
194195
variable=var,
195-
padding=7,
196+
padding=6,
196197
)
197198
checkbox.grid(
198-
row=i,
199+
row=i + 1,
199200
column=0,
200201
sticky=tkinter.W
201202
)
@@ -231,44 +232,68 @@ def on_fix_check_click(master: tkinter.Tk, BUTTONS: List):
231232
pady=3
232233
)
233234
ToolTip(template_btn, HELP_DICT['template'], 1)
234-
rfxchains_btn = ttk.Button(
235+
nr_template_btn = ttk.Button(
235236
master,
236-
text='RFXCHAINS',
237-
name='rfx',
238-
command=lambda: path_choice('fx_chains_folder')
237+
text='NR TEMPLATE',
238+
name='nrtemplate',
239+
command=lambda: path_choice('nrtemplate')
239240
)
240-
rfxchains_btn.grid(
241+
nr_template_btn.grid(
241242
row=(len(OPTIONS) + 3),
242243
column=0,
243244
sticky=tkinter.W,
244245
padx=6,
245246
pady=3
246247
)
248+
ToolTip(nr_template_btn, HELP_DICT['nrtemplate'], 1)
249+
rfxchains_btn = ttk.Button(
250+
master,
251+
text='RFXCHAINS',
252+
name='rfx',
253+
command=lambda: path_choice('fx_chains_folder')
254+
)
255+
rfxchains_btn.place(relx=0.5, rely=1.0, anchor="s", x=140, y=-40)
247256
ToolTip(rfxchains_btn, HELP_DICT['rfx'], 1)
248257
fix_check_btn = ttk.Button(
249258
master,
250-
text='FIXCHECK',
259+
text='FIX CHECK',
251260
name='fixcheck_standalone',
252261
command=lambda: on_fix_check_click(master, BUTTONS)
253262
)
254-
fix_check_btn.place(relx=0.5, rely=1.0, anchor="s", x=145, y=-9)
263+
fix_check_btn.place(relx=0.5, rely=1.0, anchor="s", x=140, y=-9)
255264
ToolTip(fix_check_btn, HELP_DICT['fixcheck_standalone'], 1)
256-
nr_template_btn = ttk.Button(
257-
master,
258-
text='NR TEMP',
259-
name='nrtemplate',
260-
command=lambda: path_choice('nrtemplate')
261-
)
262-
nr_template_btn.place(relx=0.5, rely=1.0, anchor="s", x=145, y=-40)
263-
ToolTip(nr_template_btn, HELP_DICT['nrtemplate'], 1)
264265
help_btn = ttk.Button(
265266
master,
266267
text='HELP',
267268
name='help',
268269
command=lambda: show_help_window(master),
269270
)
270-
help_btn.place(relx=0.5, rely=1.0, anchor="s", x=145, y=-407)
271+
help_btn.place(relx=0.5, rely=1.0, anchor="s", x=140, y=-389)
271272
ToolTip(help_btn, HELP_DICT['help'], 1)
273+
subs_extract = ttk.Label(master, text='Select subtitles to extract:')
274+
subs_extract.grid(row=0, column=0, sticky=tkinter.W, padx=6, pady=6)
275+
SUBS_LANGS_LIST = [
276+
'Russia',
277+
'US',
278+
'Saudi Arabia',
279+
'Germany',
280+
'Latin America',
281+
'France',
282+
'Italy',
283+
'Brasil',
284+
]
285+
menu = ttk.Combobox(
286+
master,
287+
values=SUBS_LANGS_LIST,
288+
name='subs_lang',
289+
state='readonly',
290+
width=13,
291+
)
292+
try:
293+
menu.set(config['SUBS']['subs_lang'])
294+
except KeyError:
295+
menu.set(SUBS_LANGS_LIST[0])
296+
menu.place(relx=0.5, rely=1.0, anchor="s", x=6, y=-391)
272297

273298

274299
if __name__ == '__main__':

background.png

-7.24 KB
Loading

config_works.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import Dict
22
import configparser
3+
import tkinter
34

45

56
def get_config() -> configparser.ConfigParser:
@@ -10,6 +11,8 @@ def get_config() -> configparser.ConfigParser:
1011
config['PATHS'] = {}
1112
if 'OPTIONS' not in config:
1213
config['OPTIONS'] = {}
14+
if 'SUBS' not in config:
15+
config['SUBS'] = {}
1316
return config
1417

1518

@@ -31,11 +34,15 @@ def load_path(name: str) -> str or None:
3134
return path
3235

3336

34-
def save_options(checkboxes: Dict[str, str]) -> None:
37+
def save_options(
38+
master: tkinter.Tk,
39+
checkboxes: Dict[str, str]
40+
) -> None:
3541
"""Функция для сохранения конфигураций"""
3642
config = get_config()
3743
for option, var in checkboxes.items():
3844
config['OPTIONS'][option] = str(var.get())
45+
config['SUBS']['subs_lang'] = master.nametowidget('subs_lang').get()
3946
with open('config.ini', 'w', encoding='utf-8') as config_file:
4047
config.write(config_file)
4148

file_works.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
load_path,
66
save_path,
77
get_option,
8+
get_config,
89
)
910
from help_texts import (
1011
MANY_VIDEO,
@@ -24,6 +25,17 @@
2425
import re
2526
import os
2627

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+
2739

2840
def resource_path(path):
2941
try:
@@ -241,6 +253,7 @@ def file_works(folder: str) -> (
241253
str or None]
242254
):
243255
"""Функция для подготовки файлов к работе"""
256+
config = get_config()
244257
if not folder:
245258
tkinter.messagebox.showerror('Ошибка', NO_FOLDER)
246259
return None, None, None, None, None, None
@@ -275,7 +288,8 @@ def file_works(folder: str) -> (
275288
if get_option('subs_cleaner'):
276289
subs_edit(subs, 'srt')
277290
else:
278-
rus_sub = '0:s:m:language:rus'
291+
lang = SUBS_LANGS_DICT[config['SUBS']['subs_lang']]
292+
try_sub = f'0:s:m:language:{lang}'
279293
eng_sub = '0:s:m:language:eng'
280294
any_sub = '0:s:m:language:?'
281295
ass_subs = glob_path(folder, '*.ass')
@@ -291,7 +305,7 @@ def file_works(folder: str) -> (
291305
ass_sub_convert(folder, ass_subs)
292306
elif not ass_subs and video:
293307
if os.path.splitext(video[0])[-1] == '.mkv':
294-
subs_extract(folder, video, 'ass', rus_sub)
308+
subs_extract(folder, video, 'ass', try_sub)
295309
ass_subs = glob_path(folder, '*.ass')
296310
if not ass_subs:
297311
subs_extract(folder, video, 'ass', eng_sub)

help_texts.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@
7373
NOIZE_REDUCTION = ('Очищает дороги дабберов от шума. '
7474
'Для корректной работы нужно выбрать шаблон в "NR TEMP".')
7575
SPLIT = 'Использует последний пресет Dynamic split items'
76-
NORM = ('Использует SWS/BR: Normalize loudness of selected items to -23 LUFS '
77-
'для всех айтемов проекта')
7876
NORM_D = ('Использует SWS/BR: Normalize loudness of selected items to -23 '
7977
'LUFS для айтемов дабберов')
8078
NORM_V = ('Использует SWS/BR: Normalize loudness of selected items to -23 '
@@ -96,7 +94,6 @@
9694
HELP = 'Помощь'
9795
HELP_DICT = {
9896
'split': SPLIT,
99-
'normalize': NORM,
10097
'normalize_dubbers': NORM_D,
10198
'normalize_video': NORM_V,
10299
'volume_up_dubbers': VOLUME_UP,

window_utils.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,14 @@ def is_reaper_run():
4949

5050
def show_help_window(master: tkinter.Tk):
5151
master.nametowidget('help').config(state='disabled')
52-
master_geometry = master.geometry().split('+')[0].split('x')[0]
52+
master_geometry_x = master.geometry().split('+')[0].split('x')[0]
53+
master_geometry_y = master.geometry().split('+')[0].split('x')[1]
5354
master_position = master.geometry().split('x')[1].split('+')[1:]
54-
x = int(master_position[0]) + int(master_geometry) + 6
55+
x = int(master_position[0]) + int(master_geometry_x) + 6
5556
y = master_position[1]
5657
help_window = tkinter.Toplevel(master)
5758
help_window.title('HOW TO USE')
58-
help_window.geometry(f'615x440+{x}+{y}')
59+
help_window.geometry(f'615x{master_geometry_y}+{x}+{y}')
5960
help_window.resizable(False, False)
6061
help_window.protocol(
6162
'WM_DELETE_WINDOW',
@@ -81,5 +82,16 @@ def show_help_window(master: tkinter.Tk):
8182
help_window.mainloop()
8283

8384

85+
def set_geometry(master: tkinter.Tk):
86+
width = 380
87+
height = 418
88+
s_width = master.winfo_screenwidth()
89+
s_height = master.winfo_screenheight()
90+
upper = s_height // 8
91+
x = (s_width - width) // 2
92+
y = (s_height - height) // 2
93+
return f'{width}x{height}+{x}+{y - upper}'
94+
95+
8496
if __name__ == '__main__':
8597
pass

0 commit comments

Comments
 (0)