askrobots / dbbasic-video
Public
Video analysis: download, keyframes, transcripts, thumbnail grids and AI summaries of what's on screen.
cli.py · 2.1 KB · 70 lines
| 1 | #!/usr/bin/env python3 |
| 2 | """ |
| 3 | Main CLI entry point for dbbasic-video |
| 4 | """ |
| 5 | |
| 6 | import sys |
| 7 | import argparse |
| 8 | |
| 9 | |
| 10 | def main(): |
| 11 | parser = argparse.ArgumentParser( |
| 12 | description="DBBasic Video - AI-powered video analysis toolkit", |
| 13 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 14 | epilog=""" |
| 15 | Available commands: |
| 16 | download Download video from YouTube |
| 17 | extract Extract keyframes from video using scene detection |
| 18 | transcript Download video transcript |
| 19 | grid Create thumbnail grid from keyframes |
| 20 | analyze Analyze visuals with AI |
| 21 | summarize Create comprehensive summary |
| 22 | find-thumbnail Find best thumbnail candidates |
| 23 | pipeline Run complete analysis pipeline |
| 24 | |
| 25 | Use 'dbbasic-video <command> --help' for more information on a command. |
| 26 | """ |
| 27 | ) |
| 28 | |
| 29 | parser.add_argument( |
| 30 | 'command', |
| 31 | nargs='?', |
| 32 | help='Command to run' |
| 33 | ) |
| 34 | |
| 35 | # Parse just the command |
| 36 | args, remaining = parser.parse_known_args() |
| 37 | |
| 38 | if not args.command: |
| 39 | parser.print_help() |
| 40 | return 1 |
| 41 | |
| 42 | # Route to appropriate module |
| 43 | if args.command == 'download': |
| 44 | from .download_video import main as cmd_main |
| 45 | elif args.command == 'extract': |
| 46 | from .extract_keyframes import main as cmd_main |
| 47 | elif args.command == 'transcript': |
| 48 | from .get_transcript import main as cmd_main |
| 49 | elif args.command == 'grid': |
| 50 | from .make_grid import main as cmd_main |
| 51 | elif args.command == 'analyze': |
| 52 | from .analyze_visuals import main as cmd_main |
| 53 | elif args.command == 'summarize': |
| 54 | from .summarize import main as cmd_main |
| 55 | elif args.command == 'find-thumbnail': |
| 56 | from .find_thumbnail import main as cmd_main |
| 57 | elif args.command == 'pipeline': |
| 58 | from .pipeline import main as cmd_main |
| 59 | else: |
| 60 | print(f"Unknown command: {args.command}", file=sys.stderr) |
| 61 | parser.print_help() |
| 62 | return 1 |
| 63 | |
| 64 | # Replace argv with remaining args and run command |
| 65 | sys.argv = [f'dbbasic-video {args.command}'] + remaining |
| 66 | return cmd_main() |
| 67 | |
| 68 | |
| 69 | if __name__ == "__main__": |
| 70 | sys.exit(main()) |