()
| 2159 | |
| 2160 | |
| 2161 | def main() -> None: |
| 2162 | import time |
| 2163 | parser = build_argument_parser() |
| 2164 | args = parser.parse_args() |
| 2165 | start_time = time.time() |
| 2166 | logging.basicConfig( |
| 2167 | level=getattr(logging, args.log_level.upper(), logging.INFO), |
| 2168 | format="[%(asctime)s][%(levelname)5s] %(message)s", |
| 2169 | ) |
| 2170 | |
| 2171 | ensure_dependencies() |
| 2172 | |
| 2173 | # Apply model default configuration |
| 2174 | if args.model in MODEL_DEFAULT_CONFIG: |
| 2175 | model_config = MODEL_DEFAULT_CONFIG[args.model] |
| 2176 | # If user hasn't explicitly specified, use model default configuration |
| 2177 | if args.seconds is None: |
| 2178 | args.seconds = model_config["seconds"] |
| 2179 | LOGGER.info(f"Using {args.model} model default duration: {args.seconds} seconds") |
| 2180 | if args.size is None: |
| 2181 | args.size = model_config["size"] |
| 2182 | LOGGER.info(f"Using {args.model} model default resolution: {args.size}") |
| 2183 | else: |
| 2184 | # For models not in MODEL_DEFAULT_CONFIG, use general default values |
| 2185 | if args.seconds is None: |
| 2186 | args.seconds = 12 |
| 2187 | if args.size is None: |
| 2188 | args.size = "1792x1024" |
| 2189 | |
| 2190 | # ✅ Separate parameter checks for batch mode and single script mode |
| 2191 | if args.enable_batch: |
| 2192 | # Batch mode: only needs batch_jsonl, doesn't need script/script_path |
| 2193 | if not args.batch_jsonl: |
| 2194 | raise ValueError("Batch mode requires specifying --batch_jsonl file path.") |
| 2195 | LOGGER.info("Batch mode: Will read scripts from JSONL file") |
| 2196 | else: |
| 2197 | # Single script mode: needs script or script_path |
| 2198 | if not args.script and not args.script_path: |
| 2199 | raise ValueError("Single script mode requires providing either --script or --script_path.") |
| 2200 | |
| 2201 | script_text = args.script |
| 2202 | if not script_text and args.script_path: |
| 2203 | with open(args.script_path, "r", encoding="utf-8") as file: |
| 2204 | script_text = file.read() |
| 2205 | |
| 2206 | if not script_text: |
| 2207 | raise ValueError("Read script text is empty.") |
| 2208 | |
| 2209 | components = extract_story_components(script_text) |
| 2210 | if not components.nodes: |
| 2211 | raise ValueError("Failed to parse valid nodes, please check if script text format is 'number. content'.") |
| 2212 | |
| 2213 | if args.resume and not args.resume_node_dir: |
| 2214 | raise ValueError("When enabling --resume, must specify --resume_node_dir") |
| 2215 | |
| 2216 | if args.resume and args.resume_node_dir: |
| 2217 | if not os.path.exists(args.resume_node_dir): |
| 2218 | raise FileNotFoundError(f"Specified node directory does not exist: {args.resume_node_dir}") |
no test coverage detected