Skip to content

Commit adcc295

Browse files
committed
3.22
1 parent 81c9ff7 commit adcc295

4 files changed

Lines changed: 36 additions & 59 deletions

File tree

ReaperScript.exe

-128 Bytes
Binary file not shown.

ReaperScript.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from reaper_works import (
2020
audio_select,
2121
split,
22-
hidden_normalize,
22+
normalize,
2323
import_subs,
2424
fix_check,
2525
project_save,
@@ -116,22 +116,18 @@ def reaper_main(
116116
if get_option('split'):
117117
split(project)
118118
project.save(False)
119-
hidden_normalize(project)
119+
if get_option('normalize'):
120+
normalize(project, 'all')
121+
if get_option('normalize_dubbers'):
122+
normalize(project, 'dubbers')
123+
if get_option('normalize_video'):
124+
normalize(project, 'video')
120125
back_up(project, new_path)
121126
if get_option('fix_check'):
122127
fix_check(project, subs)
123128
project.save(False)
124129
if get_option('render_audio'):
125130
output_file = render(folder, 'main')
126-
time.sleep(2)
127-
old_file_size = os.path.getsize(output_file)
128-
time.sleep(3)
129-
new_file_size = os.path.getsize(output_file)
130-
while old_file_size < new_file_size:
131-
old_file_size = os.path.getsize(output_file)
132-
time.sleep(3)
133-
new_file_size = os.path.getsize(output_file)
134-
time.sleep(2)
135131
if get_option('render_video'):
136132
make_episode(video, folder, title, number, ext, output_file)
137133
buttons_active(master, BUTTONS)
@@ -159,7 +155,7 @@ def on_fix_check_click(master: tkinter.Tk, BUTTONS: List):
159155
y = (s_height - height) // 2
160156
master.geometry(f'{width}x{height}+{x}+{y - upper}')
161157
master.resizable(width=False, height=False)
162-
master.title('REAPERSCRIPT v3.21')
158+
master.title('REAPERSCRIPT v3.22')
163159
master.iconbitmap(default=resource_path('ico.ico'))
164160
img = Image.open(resource_path('background.png'))
165161
tk_img = ImageTk.PhotoImage(img)

file_works.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ def file_works(folder: str) -> (
289289
if get_option('subs_cleaner'):
290290
subs_edit(ass_subs, 'ass')
291291
ass_sub_convert(folder, ass_subs)
292-
elif not ass_subs:
292+
elif not ass_subs and video:
293293
if os.path.splitext(video[0])[-1] == '.mkv':
294294
subs_extract(folder, video, 'ass', rus_sub)
295295
ass_subs = glob_path(folder, '*.ass')
@@ -318,6 +318,8 @@ def file_works(folder: str) -> (
318318
subs_edit(subs, 'srt')
319319
except IndexError:
320320
pass
321+
except TypeError:
322+
pass
321323
return subs, audio, video, title, number, ext
322324

323325

reaper_works.py

Lines changed: 25 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,12 @@ def split(project: reapy.Project) -> None:
6464
win32gui.SendMessage(hwnd, win32con.WM_COMMAND, 1, 0)
6565

6666

67-
def normalize(command: int, project: reapy.Project, flag: str) -> None:
68-
"""Функция для нормализации всего по громкости"""
67+
def normalize_loudness(
68+
command: int,
69+
project: reapy.Project,
70+
flag: str
71+
) -> None:
72+
"""Функция для нормализации громкости"""
6973
if flag == 'all' or flag == 'dubbers':
7074
select_all = True
7175
else:
@@ -80,50 +84,23 @@ def normalize(command: int, project: reapy.Project, flag: str) -> None:
8084
reapy.perform_action(command)
8185

8286

83-
def hidden_normalize(project: reapy.Project) -> None:
87+
def normalize(project: reapy.Project, flag: str) -> None:
8488
command = RPR.NamedCommandLookup(
8589
'_BR_NORMALIZE_LOUDNESS_ITEMS23'
8690
)
8791
clsname, title = '#32770', 'SWS/BR - Normalizing loudness...'
88-
if get_option('normalize'):
89-
norm = mp.Process(
90-
target=normalize,
91-
args=(command, project, 'all')
92-
)
93-
hide = mp.Process(
94-
target=hide_window,
95-
args=(clsname, title, 'normalize')
96-
)
97-
norm.start()
98-
hide.start()
99-
norm.join()
100-
hide.join()
101-
if get_option('normalize_dubbers'):
102-
norm = mp.Process(
103-
target=normalize,
104-
args=(command, project, 'dubbers')
105-
)
106-
hide = mp.Process(
107-
target=hide_window,
108-
args=(clsname, title, 'normalize')
109-
)
110-
norm.start()
111-
hide.start()
112-
norm.join()
113-
hide.join()
114-
if get_option('normalize_video'):
115-
norm = mp.Process(
116-
target=normalize,
117-
args=(command, project, 'video')
118-
)
119-
hide = mp.Process(
120-
target=hide_window,
121-
args=(clsname, title, 'normalize')
122-
)
123-
norm.start()
124-
hide.start()
125-
norm.join()
126-
hide.join()
92+
norm = mp.Process(
93+
target=normalize_loudness,
94+
args=(command, project, flag)
95+
)
96+
hide = mp.Process(
97+
target=hide_window,
98+
args=(clsname, title, 'normalize')
99+
)
100+
norm.start()
101+
hide.start()
102+
norm.join()
103+
hide.join()
127104

128105

129106
def subs_generator(
@@ -142,8 +119,7 @@ def subs_generator(
142119
start, end, sbttls[i].text, (147, 112, 219)
143120
)
144121
# RPR.NF_SetSWSMarkerRegionSub(sbttls[i].text, region.index)
145-
# Странно себя ведёт в потоке,
146-
# потому что сразу много регионов создаётся и путаются ID
122+
# Странно себя ведёт в потоке
147123
elif flag == 'item':
148124
item = project.tracks[1].add_item(start, end)
149125
RPR.ULT_SetMediaItemNote(item.id, sbttls[i].text)
@@ -166,7 +142,10 @@ def import_subs(
166142
mp.Process(
167143
target=subs_generator,
168144
args=(
169-
project, sbttls, strt_idx, end_idx,
145+
project,
146+
sbttls,
147+
strt_idx,
148+
end_idx,
170149
flag
171150
)
172151
)
@@ -183,7 +162,7 @@ def list_generator(
183162
list: List[List[float]],
184163
queue: mp.Queue
185164
) -> None:
186-
"""Функция для создания списка айтемов/субтитров"""
165+
"""Функция для создания списка айтемов"""
187166
for i in range(strt_idx, end_idx):
188167
item = RPR.GetMediaItem(0, i)
189168
start = RPR.GetMediaItemInfo_Value(

0 commit comments

Comments
 (0)