@@ -548,79 +548,51 @@ def main_menu():
548548 console .print ("[dim italic]Built with ❤️ by [link=https://hariharen.site]Hariharen[/link][/dim italic]" )
549549 break
550550
551- # --- VIDEO ---
552- elif "Edit (Trim" in choice :
553- video_edit_menu ()
554- elif "Convert (Format, Compress, Resolution, FPS" in choice :
555- video_convert_menu ()
556- elif "Effects (Speed" in choice :
557- video_effects_menu ()
558-
559- # --- IMAGE ---
560- elif "Transform (Resize" in choice :
561- image_transform_menu ()
562- elif "Adjust (Colors" in choice :
563- image_adjust_menu ()
564- elif "Add (Border" in choice :
565- image_add_menu ()
566- elif "Convert (Format, Compress)" in choice :
567- image_convert_menu ()
568-
569- # --- AUDIO ---
570- elif "Edit (Extract" in choice :
571- audio_edit_menu ()
572- elif "Adjust (Volume" in choice :
573- audio_adjust_menu ()
574- elif "Convert (Format)" in choice :
575- audio_convert_menu ()
576- elif "Visualizer" in choice :
577- file_path = select_media_file ()
578- if file_path :
579- audio_visualizer (file_path )
580-
581- # --- AI ---
582- elif "Subtitles (Whisper)" in choice :
583- file_path = select_media_file (filter_type = "video" )
584- if file_path :
585- generate_subtitles (file_path )
586- elif "Brainrot" in choice :
587- file_path = select_media_file (filter_type = "video" )
588- if file_path :
589- brainrot_captions (file_path )
590- elif "Auto-Dubbing" in choice :
591- file_path = select_media_file (filter_type = "video" )
592- if file_path :
593- auto_dub (file_path )
594- elif "Separate Music Stems" in choice :
595- file_path = select_media_file ()
596- if file_path :
597- separate_stems (file_path )
598- elif "Background Removal" in choice :
599- file_path = select_media_file ()
600- if file_path :
601- remove_background (file_path )
602- elif "Blur Faces" in choice :
603- file_path = select_media_file (filter_type = "video" )
604- if file_path :
605- auto_blur_faces (file_path )
606- elif "Upscaling" in choice :
607- file_path = select_media_file (filter_type = "video" )
608- if file_path :
609- upscale_video (file_path )
610-
611- # --- OTHER ---
612- elif "Slideshow" in choice :
613- create_slideshow ()
614- elif "Metadata" in choice :
615- file_path = select_media_file ()
616- if file_path :
617- metadata_editor (file_path )
618- elif "Batch" in choice :
619- batch_convert ()
620- elif "Inspect" in choice :
621- inspect_menu ()
622- elif "Settings" in choice :
623- settings_menu ()
551+ # Dispatch table: (substring_key, handler, file_filter)
552+ # file_filter=None → call handler() directly (submenus, no-arg actions)
553+ # file_filter="video"/"image" → select file with filter, call handler(file_path)
554+ # file_filter="any" → select file without filter, call handler(file_path)
555+ dispatch = [
556+ # VIDEO
557+ ("Edit (Trim" , video_edit_menu , None ),
558+ ("Convert (Format, Compress, Resolution, FPS" , video_convert_menu , None ),
559+ ("Effects (Speed" , video_effects_menu , None ),
560+ # IMAGE
561+ ("Transform (Resize" , image_transform_menu , None ),
562+ ("Adjust (Colors" , image_adjust_menu , None ),
563+ ("Add (Border" , image_add_menu , None ),
564+ ("Convert (Format, Compress)" , image_convert_menu , None ),
565+ # AUDIO
566+ ("Edit (Extract" , audio_edit_menu , None ),
567+ ("Adjust (Volume" , audio_adjust_menu , None ),
568+ ("Convert (Format)" , audio_convert_menu , None ),
569+ ("Visualizer" , audio_visualizer , "any" ),
570+ # AI
571+ ("Subtitles (Whisper)" , generate_subtitles , "video" ),
572+ ("Brainrot" , brainrot_captions , "video" ),
573+ ("Auto-Dubbing" , auto_dub , "video" ),
574+ ("Separate Music Stems" , separate_stems , "any" ),
575+ ("Background Removal" , remove_background , "any" ),
576+ ("Blur Faces" , auto_blur_faces , "video" ),
577+ ("Upscaling" , upscale_video , "video" ),
578+ # OTHER
579+ ("Slideshow" , create_slideshow , None ),
580+ ("Metadata" , metadata_editor , "any" ),
581+ ("Batch" , batch_convert , None ),
582+ ("Inspect" , inspect_menu , None ),
583+ ("Settings" , settings_menu , None ),
584+ ]
585+
586+ for key , handler , file_filter in dispatch :
587+ if key in choice :
588+ if file_filter is None :
589+ handler ()
590+ else :
591+ kw = {"filter_type" : file_filter } if file_filter != "any" else {}
592+ file_path = select_media_file (** kw )
593+ if file_path :
594+ handler (file_path )
595+ break
624596
625597
626598import argparse
0 commit comments