MCPcopy
hub / github.com/nikopueringer/CorridorKey / organize_clips

Function organize_clips

clip_manager.py:1066–1106  ·  view source on GitHub ↗

Legacy wrapper for backward compatibility with 'ClipsForInference' folder. Organizes all subfolders in the given directory using the new logic.

(clips_dir: str)

Source from the content-addressed store, hash-verified

1064
1065
1066def organize_clips(clips_dir: str) -> None:
1067 """
1068 Legacy wrapper for backward compatibility with 'ClipsForInference' folder.
1069 Organizes all subfolders in the given directory using the new logic.
1070 """
1071 if not os.path.exists(clips_dir):
1072 logger.warning(f"Clips directory not found: {clips_dir}")
1073 return
1074
1075 logger.info(f"Organizing Clips Directory: {clips_dir}")
1076
1077 # Check for loose videos in root
1078 loose_videos = [f for f in os.listdir(clips_dir) if is_video_file(f) and os.path.isfile(os.path.join(clips_dir, f))]
1079
1080 # Organize loose videos first
1081 for v in loose_videos:
1082 clip_name = os.path.splitext(v)[0]
1083 ext = os.path.splitext(v)[1]
1084 target_folder = os.path.join(clips_dir, clip_name)
1085
1086 if os.path.exists(target_folder):
1087 logger.warning(f"Skipping loose video '{v}': Target folder '{clip_name}' already exists.")
1088 continue
1089
1090 try:
1091 os.makedirs(target_folder)
1092 target_file = os.path.join(target_folder, f"Input{ext}")
1093 shutil.move(os.path.join(clips_dir, v), target_file)
1094 logger.info(f"Organized: Moved '{v}' to '{clip_name}/Input{ext}'")
1095
1096 # Also initialize hints immediately
1097 for hint in ["AlphaHint", "VideoMamaMaskHint"]:
1098 os.makedirs(os.path.join(target_folder, hint), exist_ok=True)
1099 except Exception as e:
1100 logger.error(f"Failed to organize video '{v}': {e}")
1101
1102 # Now iterate all subdirectories and run organize_target
1103 for entry in os.listdir(clips_dir):
1104 full_path = os.path.join(clips_dir, entry)
1105 if os.path.isdir(full_path) and entry not in ["IgnoredClips", "Output"]:
1106 organize_target(full_path)
1107
1108
1109def scan_clips() -> list[ClipEntry]:

Calls 2

organize_targetFunction · 0.85
is_video_fileFunction · 0.70