Skip to content

Commit 78aa94e

Browse files
authored
Merge pull request #31 from DoobyDouglas/develop
Develop
2 parents a206948 + 91ee197 commit 78aa94e

10 files changed

Lines changed: 73 additions & 43 deletions

.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.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+

ReaperScript.exe

12.9 KB
Binary file not shown.

ReaperScript.py

Lines changed: 19 additions & 22 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
@@ -98,8 +99,8 @@ def reaper_main(
9899
if audio and video and load_path('project_path'):
99100
master.iconify()
100101
new_path = project_save(folder, project_path, 'main', title, number)
101-
hwnd = win32gui.FindWindow('REAPERwnd', None)
102-
win32gui.ShowWindow(hwnd, 2)
102+
if get_option('hide_reaper'):
103+
win32gui.ShowWindow(win32gui.FindWindow('REAPERwnd', None), 2)
103104
if get_option('noise_reduction') and load_path('nrtemplate'):
104105
audio = de_noizer(folder, audio)
105106
project = create_project(new_path)
@@ -113,6 +114,8 @@ def reaper_main(
113114
if get_option('sub_region'):
114115
import_subs(sbttls, project, step, 'region', strt_idx, end_idx)
115116
if get_option('sub_item'):
117+
if get_option('add_track_for_subs'):
118+
project.add_track(1, 'SUBTITLES')
116119
import_subs(sbttls, project, step, 'item', strt_idx, end_idx)
117120
if get_option('split'):
118121
split(project)
@@ -156,7 +159,7 @@ def on_fix_check_click(master: tkinter.Tk, BUTTONS: List):
156159
master = tkinter.Tk(className='REAPERSCRIPT.main')
157160
master.geometry(set_geometry(master))
158161
master.resizable(False, False)
159-
master.title('REAPERSCRIPT v3.28')
162+
master.title('REAPERSCRIPT v3.33')
160163
master.iconbitmap(default=resource_path('ico.ico'))
161164
master.protocol('WM_DELETE_WINDOW', on_closing)
162165
style = ttk.Style()
@@ -173,7 +176,6 @@ def on_fix_check_click(master: tkinter.Tk, BUTTONS: List):
173176
OPTIONS = [
174177
'noise_reduction',
175178
'volume_up_dubbers',
176-
'subs_cleaner',
177179
'sub_region',
178180
'sub_item',
179181
'split',
@@ -182,6 +184,9 @@ def on_fix_check_click(master: tkinter.Tk, BUTTONS: List):
182184
'fix_check',
183185
'render_audio',
184186
'render_video',
187+
'hide_reaper',
188+
'subs_cleaner',
189+
'add_track_for_subs',
185190
]
186191
for i, option in enumerate(OPTIONS):
187192
var = tkinter.BooleanVar()
@@ -193,12 +198,13 @@ def on_fix_check_click(master: tkinter.Tk, BUTTONS: List):
193198
master,
194199
text=option,
195200
variable=var,
196-
padding=6,
197201
)
198202
checkbox.grid(
199203
row=i + 1,
200204
column=0,
201-
sticky=tkinter.W
205+
sticky=tkinter.W,
206+
pady=3,
207+
padx=6,
202208
)
203209
ToolTip(checkbox, HELP_DICT[option], 1)
204210
checkboxes[option] = var
@@ -216,7 +222,7 @@ def on_fix_check_click(master: tkinter.Tk, BUTTONS: List):
216222
name='start',
217223
command=lambda: on_start_click(checkboxes, master, BUTTONS)
218224
)
219-
start_bttn.place(relx=0.5, rely=1.0, anchor="s", y=-9)
225+
start_bttn.place(relx=0.5, rely=1.0, anchor="s", y=-6)
220226
ToolTip(start_bttn, HELP_DICT['start'], 1)
221227
template_btn = ttk.Button(
222228
master,
@@ -252,36 +258,27 @@ def on_fix_check_click(master: tkinter.Tk, BUTTONS: List):
252258
name='rfx',
253259
command=lambda: path_choice('fx_chains_folder')
254260
)
255-
rfxchains_btn.place(relx=0.5, rely=1.0, anchor="s", x=140, y=-40)
261+
rfxchains_btn.place(relx=0.5, rely=1.0, anchor="s", x=140, y=-37)
256262
ToolTip(rfxchains_btn, HELP_DICT['rfx'], 1)
257263
fix_check_btn = ttk.Button(
258264
master,
259265
text='FIX CHECK',
260266
name='fixcheck_standalone',
261267
command=lambda: on_fix_check_click(master, BUTTONS)
262268
)
263-
fix_check_btn.place(relx=0.5, rely=1.0, anchor="s", x=140, y=-9)
269+
fix_check_btn.place(relx=0.5, rely=1.0, anchor="s", x=140, y=-6)
264270
ToolTip(fix_check_btn, HELP_DICT['fixcheck_standalone'], 1)
265271
help_btn = ttk.Button(
266272
master,
267273
text='HELP',
268274
name='help',
269275
command=lambda: show_help_window(master),
270276
)
271-
help_btn.place(relx=0.5, rely=1.0, anchor="s", x=140, y=-389)
277+
help_btn.place(relx=0.5, rely=1.0, anchor="s", x=140, y=-422)
272278
ToolTip(help_btn, HELP_DICT['help'], 1)
273279
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-
]
280+
subs_extract.grid(row=0, column=0, sticky=tkinter.W, padx=6, pady=9)
281+
SUBS_LANGS_LIST = list(get_subs_langs().keys())
285282
menu = ttk.Combobox(
286283
master,
287284
values=SUBS_LANGS_LIST,
@@ -293,7 +290,7 @@ def on_fix_check_click(master: tkinter.Tk, BUTTONS: List):
293290
menu.set(config['SUBS']['subs_lang'])
294291
except KeyError:
295292
menu.set(SUBS_LANGS_LIST[0])
296-
menu.place(relx=0.5, rely=1.0, anchor="s", x=9, y=-391)
293+
menu.place(relx=0.5, rely=1.0, anchor="s", x=9, y=-424)
297294
ToolTip(menu, HELP_DICT['subs_lang'], 1)
298295

299296
if __name__ == '__main__':

background.png

12.5 KB
Loading

config_works.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
def get_config() -> configparser.ConfigParser:
77
"""Функция для создания/получения файла конфигураций"""
88
config = configparser.ConfigParser()
9-
config.read('config.ini', encoding='utf-8')
9+
config.read('REAPERSCRIPT.ini', encoding='utf-8')
1010
if 'PATHS' not in config:
1111
config['PATHS'] = {}
1212
if 'OPTIONS' not in config:
@@ -20,7 +20,7 @@ def save_path(name: str, path: str) -> None:
2020
"""Функция для сохранения пути в файл конфигурации"""
2121
config = get_config()
2222
config['PATHS'][name] = path
23-
with open('config.ini', 'w', encoding='utf-8') as config_file:
23+
with open('REAPERSCRIPT.ini', 'w', encoding='utf-8') as config_file:
2424
config.write(config_file)
2525

2626

@@ -43,7 +43,7 @@ def save_options(
4343
for option, var in checkboxes.items():
4444
config['OPTIONS'][option] = str(var.get())
4545
config['SUBS']['subs_lang'] = master.nametowidget('subs_lang').get()
46-
with open('config.ini', 'w', encoding='utf-8') as config_file:
46+
with open('REAPERSCRIPT.ini', 'w', encoding='utf-8') as config_file:
4747
config.write(config_file)
4848

4949

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: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
'С помощью кнопки "TEMPLATE" выберите этот шаблон.\n'
2323
'\n'
2424
'Нажав на кнопку "RFXCHAINS" можно выбрать папку с цепями эффектов.\n'
25-
'Имена цепей должны соответствовать названиям дорог, без учёта регистра.\n'
25+
'Имена цепей должны находиться в названиях дорог,\n'
26+
'без учёта регистра и пробелов.\n'
2627
'Например:\n'
27-
'Если файл называется "что-то_там_озвучил ЧеловЕк_ПАук и_вот.wave",\n'
28-
'то на эту дорогу добавится цепь с именем "ЧеЛОвек_ПауК.RfxChain".\n'
28+
'Если файл называется "что-то_там озвучил_ЧеловЕк_ПАук и_вот.wave",\n'
29+
'то на эту дорогу добавится цепь с именем "ЧеЛОвек ПауК.RfxChain".\n'
30+
'На дорогу с названием "озвучил ЧелОвЕк ПАук и вот.flac" - тоже.\n'
2931
'\n'
3032
'Теперь REAPERSCRIPT запомнил пути к шаблону и цепям эффектов,\n'
3133
'при повторном запуске, нажимать на соответствующие кнопки,\n'
@@ -71,6 +73,10 @@
7173
'"Select subtitles to extract:",\n'
7274
'если их нет - то английские.\n'
7375
'В случае, когда нет ни того, ни другого - извлекаются первые доступные.\n'
76+
'После запуска, рядом с "ReaperScript.exe" появится '
77+
'"subs_langs.json".\n'
78+
'В него можно добавить нужные языки для извлечения,\n'
79+
'в формате "КЛЮЧ": "ЗНАЧЕНИЕ".\n'
7480
'Для работы этой функции в системе должен быть ffmpeg.\n'
7581
'\n'
7682
'Для работы функции "render_video" в системе должен быть ffmpeg.\n'
@@ -80,7 +86,8 @@
8086
'Подробности об отдельных функциях можно узнать во всплывающем тексте.'
8187
)
8288
NOIZE_REDUCTION = ('Очищает дороги дабберов от шума. '
83-
'Для корректной работы нужно выбрать шаблон в "NR TEMP".')
89+
'Для корректной работы '
90+
'нужно выбрать шаблон в "NR TEMPLATE"')
8491
SPLIT = 'Использует последний пресет Dynamic split items'
8592
NORM_D = ('Использует SWS/BR: Normalize loudness of selected items to -23 '
8693
'LUFS для айтемов дабберов')
@@ -101,6 +108,8 @@
101108
FIXCHECK_SRANDALONE = 'Проверить на фиксы активный проект'
102109
NR_TEMP = 'Выбрать шаблон проекта REAPER для удаления шума'
103110
SUBS_LANG = 'Язык субтитров'
111+
ADD_TRACK_FOR_SUBS = 'Добавляет отдельный трек для субтитров'
112+
HIDE_REAPER = 'Сворачивает основное окно REAPER после начала работы'
104113
HELP = 'Помощь'
105114
HELP_DICT = {
106115
'split': SPLIT,
@@ -121,6 +130,8 @@
121130
'noise_reduction': NOIZE_REDUCTION,
122131
'nrtemplate': NR_TEMP,
123132
'subs_lang': SUBS_LANG,
133+
'add_track_for_subs': ADD_TRACK_FOR_SUBS,
134+
'hide_reaper': HIDE_REAPER,
124135
}
125136
MANY_VIDEO = 'Оставьте в рабочей папке только нужный видеофайл'
126137
MANY_SUBS = 'Оставьте в рабочей папке только нужный файл субтитров'

reaper_works.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import shutil
1111
import reapy
1212
import time
13+
import re
1314
import os
1415
from threading import Thread
1516

@@ -30,11 +31,13 @@ def audio_select(audio: List[str], flag: str) -> None:
3031
for file in audio:
3132
RPR.InsertMedia(file, 1)
3233
track = reapy.get_last_touched_track()
34+
filename = os.path.splitext(file.split('\\')[-1])[0].replace(' ', '_')
3335
if get_option('volume_up_dubbers') and flag == 'main':
3436
track.items[0].set_info_value('D_VOL', 1.5)
3537
if fx_chains_dict:
3638
for name in fx_chains_dict:
37-
if name in file.split('\\')[-1].lower():
39+
search_name = name.replace(' ', '_')
40+
if re.findall(rf'_{search_name}_', f'_{filename.lower()}_'):
3841
if flag == 'main':
3942
track.add_fx(fx_chains_dict[name])
4043
track.set_info_string('P_NAME', name.upper())

window_utils.py

Lines changed: 27 additions & 1 deletion
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():
@@ -84,7 +98,7 @@ def show_help_window(master: tkinter.Tk):
8498

8599
def set_geometry(master: tkinter.Tk):
86100
width = 380
87-
height = 418
101+
height = 453
88102
s_width = master.winfo_screenwidth()
89103
s_height = master.winfo_screenheight()
90104
upper = s_height // 8
@@ -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)