diff --git a/ReaperScript.exe b/ReaperScript.exe index 582a975..8fe4fc3 100644 Binary files a/ReaperScript.exe and b/ReaperScript.exe differ diff --git a/ReaperScript.py b/ReaperScript.py index c185702..816a882 100644 --- a/ReaperScript.py +++ b/ReaperScript.py @@ -19,7 +19,7 @@ from reaper_works import ( audio_select, split, - hidden_normalize, + normalize, import_subs, fix_check, project_save, @@ -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) @@ -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) diff --git a/file_works.py b/file_works.py index 2316a4a..d37e6c4 100644 --- a/file_works.py +++ b/file_works.py @@ -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') @@ -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 diff --git a/reaper_works.py b/reaper_works.py index 965c6bd..c34dc02 100644 --- a/reaper_works.py +++ b/reaper_works.py @@ -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: @@ -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( @@ -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) @@ -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 ) ) @@ -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(