Skip to content
Merged

3.22 #26

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified ReaperScript.exe
Binary file not shown.
20 changes: 8 additions & 12 deletions ReaperScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from reaper_works import (
audio_select,
split,
hidden_normalize,
normalize,
import_subs,
fix_check,
project_save,
Expand Down Expand Up @@ -116,22 +116,18 @@ def reaper_main(
if get_option('split'):
split(project)
project.save(False)
hidden_normalize(project)
if get_option('normalize'):
normalize(project, 'all')
if get_option('normalize_dubbers'):
normalize(project, 'dubbers')
if get_option('normalize_video'):
normalize(project, 'video')
back_up(project, new_path)
if get_option('fix_check'):
fix_check(project, subs)
project.save(False)
if get_option('render_audio'):
output_file = render(folder, 'main')
time.sleep(2)
old_file_size = os.path.getsize(output_file)
time.sleep(3)
new_file_size = os.path.getsize(output_file)
while old_file_size < new_file_size:
old_file_size = os.path.getsize(output_file)
time.sleep(3)
new_file_size = os.path.getsize(output_file)
time.sleep(2)
if get_option('render_video'):
make_episode(video, folder, title, number, ext, output_file)
buttons_active(master, BUTTONS)
Expand Down Expand Up @@ -159,7 +155,7 @@ def on_fix_check_click(master: tkinter.Tk, BUTTONS: List):
y = (s_height - height) // 2
master.geometry(f'{width}x{height}+{x}+{y - upper}')
master.resizable(width=False, height=False)
master.title('REAPERSCRIPT v3.21')
master.title('REAPERSCRIPT v3.22')
master.iconbitmap(default=resource_path('ico.ico'))
img = Image.open(resource_path('background.png'))
tk_img = ImageTk.PhotoImage(img)
Expand Down
4 changes: 3 additions & 1 deletion file_works.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def file_works(folder: str) -> (
if get_option('subs_cleaner'):
subs_edit(ass_subs, 'ass')
ass_sub_convert(folder, ass_subs)
elif not ass_subs:
elif not ass_subs and video:
if os.path.splitext(video[0])[-1] == '.mkv':
subs_extract(folder, video, 'ass', rus_sub)
ass_subs = glob_path(folder, '*.ass')
Expand Down Expand Up @@ -318,6 +318,8 @@ def file_works(folder: str) -> (
subs_edit(subs, 'srt')
except IndexError:
pass
except TypeError:
pass
return subs, audio, video, title, number, ext


Expand Down
71 changes: 25 additions & 46 deletions reaper_works.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,12 @@ def split(project: reapy.Project) -> None:
win32gui.SendMessage(hwnd, win32con.WM_COMMAND, 1, 0)


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


def hidden_normalize(project: reapy.Project) -> None:
def normalize(project: reapy.Project, flag: str) -> None:
command = RPR.NamedCommandLookup(
'_BR_NORMALIZE_LOUDNESS_ITEMS23'
)
clsname, title = '#32770', 'SWS/BR - Normalizing loudness...'
if get_option('normalize'):
norm = mp.Process(
target=normalize,
args=(command, project, 'all')
)
hide = mp.Process(
target=hide_window,
args=(clsname, title, 'normalize')
)
norm.start()
hide.start()
norm.join()
hide.join()
if get_option('normalize_dubbers'):
norm = mp.Process(
target=normalize,
args=(command, project, 'dubbers')
)
hide = mp.Process(
target=hide_window,
args=(clsname, title, 'normalize')
)
norm.start()
hide.start()
norm.join()
hide.join()
if get_option('normalize_video'):
norm = mp.Process(
target=normalize,
args=(command, project, 'video')
)
hide = mp.Process(
target=hide_window,
args=(clsname, title, 'normalize')
)
norm.start()
hide.start()
norm.join()
hide.join()
norm = mp.Process(
target=normalize_loudness,
args=(command, project, flag)
)
hide = mp.Process(
target=hide_window,
args=(clsname, title, 'normalize')
)
norm.start()
hide.start()
norm.join()
hide.join()


def subs_generator(
Expand All @@ -142,8 +119,7 @@ def subs_generator(
start, end, sbttls[i].text, (147, 112, 219)
)
# RPR.NF_SetSWSMarkerRegionSub(sbttls[i].text, region.index)
# Странно себя ведёт в потоке,
# потому что сразу много регионов создаётся и путаются ID
# Странно себя ведёт в потоке
elif flag == 'item':
item = project.tracks[1].add_item(start, end)
RPR.ULT_SetMediaItemNote(item.id, sbttls[i].text)
Expand All @@ -166,7 +142,10 @@ def import_subs(
mp.Process(
target=subs_generator,
args=(
project, sbttls, strt_idx, end_idx,
project,
sbttls,
strt_idx,
end_idx,
flag
)
)
Expand All @@ -183,7 +162,7 @@ def list_generator(
list: List[List[float]],
queue: mp.Queue
) -> None:
"""Функция для создания списка айтемов/субтитров"""
"""Функция для создания списка айтемов"""
for i in range(strt_idx, end_idx):
item = RPR.GetMediaItem(0, i)
start = RPR.GetMediaItemInfo_Value(
Expand Down