11# Команду ниже нужно ввести один раз в консоли с включенным Reaper.
22# python -c "import reapy; reapy.configure_reaper()"
3- # pyinstaller --noconfirm --onefile --noconsole --hidden-import=asstosrt --add-data 'background.png;.' main .py
3+ # pyinstaller --noconfirm --onefile --noconsole --hidden-import=asstosrt --add-data 'background.png;.' ReaperScript .py
44from file_works import (
55 file_works ,
6- reaper_check ,
76 path_choice ,
87 get_fx_chains ,
98 get_path_to_files
2827)
2928import multiprocessing as mp
3029import tkinter .messagebox
31- import subprocess
3230import pysubs2
3331import tkinter
3432import ffmpeg
@@ -298,6 +296,7 @@ def fix_check(project: reapy.Project, subs: List[str]) -> None:
298296 if s not in checked_subs :
299297 project .add_marker (s [0 ], 'FIX' , (255 , 0 , 255 ))
300298 for s in dbbl_sbs :
299+ lenght = dbbl_sbs [s ][1 ] - dbbl_sbs [s ][0 ]
301300 for i in items_list :
302301 middle = i [0 ] + ((i [1 ] - i [0 ]) / 2 )
303302 if i [0 ] >= dbbl_sbs [s ][0 ] and i [1 ] <= dbbl_sbs [s ][1 ]:
@@ -309,19 +308,27 @@ def fix_check(project: reapy.Project, subs: List[str]) -> None:
309308 ):
310309 if dbbl_sbs [s ][0 ] < middle < dbbl_sbs [s ][1 ]:
311310 dbbl_sbs [s ][2 ] += 1
311+ elif i [1 ] - dbbl_sbs [s ][0 ] >= lenght / 3.3 :
312+ dbbl_sbs [s ][2 ] += 1
312313 elif i [0 ] > dbbl_sbs [s ][0 ] and (
313314 i [0 ] < dbbl_sbs [s ][1 ] and i [1 ] > dbbl_sbs [s ][1 ]
314315 ):
315316 if dbbl_sbs [s ][0 ] < middle < dbbl_sbs [s ][1 ]:
316317 dbbl_sbs [s ][2 ] += 1
318+ elif dbbl_sbs [s ][1 ] - i [0 ] >= lenght / 3.3 :
319+ dbbl_sbs [s ][2 ] += 1
317320 for s in dbbl_sbs :
318321 if dbbl_sbs [s ][2 ] < 2 :
319322 project .add_marker (dbbl_sbs [s ][0 ], 'DUBBLE HERE' , (255 , 255 , 0 ))
320323
321324
322- def project_save (folder : str , title : str , number : str ) -> str :
325+ def project_save (
326+ folder : str ,
327+ title : str ,
328+ number : str ,
329+ project_path : str
330+ ) -> str :
323331 """Функция для сохранения проекта"""
324- project_path = load_path ('project_path' )
325332 new_path = f'{ folder } /{ title } { number } .rpp'
326333 copy = ''
327334 while os .path .exists (new_path ):
@@ -402,18 +409,20 @@ def reaper_main(
402409 ) -> None :
403410 """Основная функция"""
404411 save_options (checkboxes )
405- reaper_check ()
412+ project_path = load_path ('project_path' )
413+ if not project_path :
414+ path_choice ('project_path' )
415+ project_path = load_path ('project_path' )
406416 folder = path_choice ('folder' )
407417 if folder :
408418 buttons_freeze (master , BUTTONS )
409419 subs , audio , video , title , number , ext = file_works (folder )
410420 if audio and video :
411421 master .iconify ()
412- new_path = project_save (folder , title , number )
413- reaper_path = load_path ('reaper_path' )
422+ new_path = project_save (folder , title , number , project_path )
414423 hwnd = win32gui .FindWindow ('REAPERwnd' , None )
415424 win32gui .ShowWindow (hwnd , 2 )
416- subprocess . run ([ reaper_path , new_path ] )
425+ reapy . open_project ( new_path , in_new_tab = True )
417426 project = reapy .Project ()
418427 audio_select (audio )
419428 RPR .InsertMedia (video [0 ], 512 | 0 )
@@ -482,9 +491,7 @@ def resource_path(path):
482491master .resizable (width = False , height = False )
483492width = master .winfo_screenwidth ()
484493height = master .winfo_screenheight ()
485- x = (width - 380 ) // 2
486- y = (height - 390 ) // 2
487- master .title ('Выберите нужные опции' )
494+ master .title ('REAPERSCRIPT' )
488495img = Image .open (resource_path ('background.png' ))
489496tk_img = ImageTk .PhotoImage (img )
490497background_label = tkinter .Label (master , image = tk_img )
@@ -498,6 +505,7 @@ def resource_path(path):
498505 'volume_up_dubbers' ,
499506 'sub_item' ,
500507 'sub_region' ,
508+ 'subs_cleaner' ,
501509 'fix_check' ,
502510 'render_audio' ,
503511 'render_video' ,
@@ -527,35 +535,19 @@ def resource_path(path):
527535 checkboxes [option ] = var
528536BUTTONS = [
529537 'start' ,
530- 'reaper_exe' ,
531538 'template' ,
532539 'rfx' ,
533540 'fix_check' ,
534541]
535542start_bttn = tkinter .Button (
536543 master ,
537- text = 'Запуск ' ,
544+ text = 'START ' ,
538545 name = 'start' ,
539546 background = '#9b93b3' ,
540547 activebackground = '#9b93b3' ,
541548 command = lambda : on_save_click (checkboxes , master , BUTTONS )
542549)
543550start_bttn .place (relx = 0.5 , rely = 1.0 , anchor = "s" , y = - 9 )
544- reaper_exe = tkinter .Button (
545- master ,
546- text = 'REAPER' ,
547- name = 'reaper_exe' ,
548- background = '#9b93b3' ,
549- activebackground = '#9b93b3' ,
550- command = lambda : path_choice ('reaper_path' )
551- )
552- reaper_exe .grid (
553- row = (len (OPTIONS ) + 1 ),
554- column = 0 ,
555- sticky = tkinter .W ,
556- padx = 6 ,
557- pady = 3
558- )
559551template = tkinter .Button (
560552 master ,
561553 text = 'TEMPLATE' ,
@@ -597,10 +589,10 @@ def resource_path(path):
597589fix_check_button .place (relx = 0.5 , rely = 1.0 , anchor = "s" , x = 150 , y = - 7 )
598590version = tkinter .Label (
599591 master ,
600- text = 'Версия 3.0 ' ,
592+ text = 'Version 3.04 ' ,
601593 background = '#9b93b3' ,
602594)
603- version .place (relx = 0.5 , rely = 1.0 , anchor = "s" , x = 150 , y = - 378 )
595+ version .place (relx = 0.5 , rely = 1.0 , anchor = "s" , x = 150 , y = - 382 )
604596
605597# Чтобы Reaper API подгрузился, Reaper должен быть включен при запуске скрипта
606598if __name__ == '__main__' :
0 commit comments