slidemovie 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- slidemovie/__init__.py +3 -0
- slidemovie/cli.py +171 -0
- slidemovie/core.py +1438 -0
- slidemovie-0.1.0.dist-info/METADATA +110 -0
- slidemovie-0.1.0.dist-info/RECORD +9 -0
- slidemovie-0.1.0.dist-info/WHEEL +5 -0
- slidemovie-0.1.0.dist-info/entry_points.txt +2 -0
- slidemovie-0.1.0.dist-info/licenses/LICENSE +21 -0
- slidemovie-0.1.0.dist-info/top_level.txt +1 -0
slidemovie/__init__.py
ADDED
slidemovie/cli.py
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# -*- coding: utf-8 -*-
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
import sys
|
|
6
|
+
import logging
|
|
7
|
+
import slidemovie
|
|
8
|
+
|
|
9
|
+
# Logging configuration
|
|
10
|
+
logging.basicConfig(
|
|
11
|
+
level=logging.INFO,
|
|
12
|
+
format='%(asctime)s [%(levelname)s] %(message)s',
|
|
13
|
+
datefmt='%Y-%m-%d %H:%M:%S'
|
|
14
|
+
)
|
|
15
|
+
logger = logging.getLogger(__name__)
|
|
16
|
+
|
|
17
|
+
def main():
|
|
18
|
+
"""
|
|
19
|
+
Entry point for the slidemovie command-line tool.
|
|
20
|
+
|
|
21
|
+
This function parses command-line arguments to control the `slidemovie.Movie` class,
|
|
22
|
+
which generates narration videos from Markdown and PowerPoint files.
|
|
23
|
+
|
|
24
|
+
Workflow:
|
|
25
|
+
1. Parse arguments (project name, modes, options).
|
|
26
|
+
2. Initialize the `Movie` class (loads default/config settings).
|
|
27
|
+
3. Override settings based on CLI arguments (TTS options, debug mode).
|
|
28
|
+
4. Configure project paths based on structure (flat or subproject).
|
|
29
|
+
5. Execute the requested action:
|
|
30
|
+
- `--pptx`: Generates a draft PowerPoint from Markdown.
|
|
31
|
+
- `--video`: Generates the full narration video (TTS, images, stitching).
|
|
32
|
+
|
|
33
|
+
Usage:
|
|
34
|
+
slidemovie PROJECT_NAME [--pptx] [--video] [options...]
|
|
35
|
+
"""
|
|
36
|
+
parser = argparse.ArgumentParser(
|
|
37
|
+
description="Automated tool to generate narration videos from Markdown and PowerPoint."
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
# --- Positional Arguments ---
|
|
41
|
+
parser.add_argument(
|
|
42
|
+
"project_name",
|
|
43
|
+
help="Project Name (ID). If in subproject mode (--sub), this is the parent project name."
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
# --- Action Control Options ---
|
|
47
|
+
parser.add_argument(
|
|
48
|
+
"-p", "--pptx",
|
|
49
|
+
action="store_true",
|
|
50
|
+
help="Generate PPTX from Markdown (Drafting mode)."
|
|
51
|
+
)
|
|
52
|
+
parser.add_argument(
|
|
53
|
+
"-v", "--video",
|
|
54
|
+
action="store_true",
|
|
55
|
+
help="Generate all video assets from Markdown and PPTX (Build mode)."
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
# --- Path & Project Structure Options ---
|
|
59
|
+
parser.add_argument(
|
|
60
|
+
"-s", "--source-dir",
|
|
61
|
+
default=".",
|
|
62
|
+
help="Directory containing source files (md, pptx). Default is current directory."
|
|
63
|
+
)
|
|
64
|
+
parser.add_argument(
|
|
65
|
+
"--sub",
|
|
66
|
+
metavar="SUB_NAME",
|
|
67
|
+
help="Subproject name (Child folder name). If specified, runs in hierarchical mode."
|
|
68
|
+
)
|
|
69
|
+
parser.add_argument(
|
|
70
|
+
"-o", "--output-root",
|
|
71
|
+
help="Root directory for video output. If not specified, determined automatically."
|
|
72
|
+
)
|
|
73
|
+
parser.add_argument(
|
|
74
|
+
"-f", "--filename",
|
|
75
|
+
help="Output video filename (without extension). Defaults to project ID."
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
# --- TTS Settings Options (CLI Overrides) ---
|
|
79
|
+
parser.add_argument("--tts-provider", help="TTS Provider (e.g., google, openai)")
|
|
80
|
+
parser.add_argument("--tts-model", help="TTS Model name")
|
|
81
|
+
parser.add_argument("--tts-voice", help="TTS Voice/Speaker setting")
|
|
82
|
+
parser.add_argument("--prompt", help="Override TTS system prompt")
|
|
83
|
+
|
|
84
|
+
# --- Other Options ---
|
|
85
|
+
parser.add_argument(
|
|
86
|
+
"--debug",
|
|
87
|
+
action="store_true",
|
|
88
|
+
help="Enable debug mode (Verbose logging, etc)."
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
args = parser.parse_args()
|
|
92
|
+
|
|
93
|
+
# Exit if no action is specified
|
|
94
|
+
if not args.pptx and not args.video:
|
|
95
|
+
parser.print_help()
|
|
96
|
+
sys.exit(1)
|
|
97
|
+
|
|
98
|
+
# 1. Initialize Movie instance (Load configuration files)
|
|
99
|
+
try:
|
|
100
|
+
movie = slidemovie.Movie()
|
|
101
|
+
except NameError:
|
|
102
|
+
logger.error("Movie class is not defined. Make sure to import it correctly.")
|
|
103
|
+
sys.exit(1)
|
|
104
|
+
except Exception as e:
|
|
105
|
+
logger.error(f"Failed to initialize Movie class: {e}")
|
|
106
|
+
sys.exit(1)
|
|
107
|
+
|
|
108
|
+
# 2. Override settings with CLI options
|
|
109
|
+
if args.tts_provider:
|
|
110
|
+
movie.tts_provider = args.tts_provider
|
|
111
|
+
if args.tts_model:
|
|
112
|
+
movie.tts_model = args.tts_model
|
|
113
|
+
if args.tts_voice:
|
|
114
|
+
movie.tts_voice = args.tts_voice
|
|
115
|
+
if args.prompt:
|
|
116
|
+
movie.prompt = args.prompt
|
|
117
|
+
|
|
118
|
+
if args.debug:
|
|
119
|
+
movie.ffmpeg_loglevel = 'info'
|
|
120
|
+
movie.show_skip = True
|
|
121
|
+
logger.setLevel(logging.DEBUG)
|
|
122
|
+
logger.info("Debug mode enabled.")
|
|
123
|
+
|
|
124
|
+
# 3. Configure Path Settings
|
|
125
|
+
try:
|
|
126
|
+
if args.sub:
|
|
127
|
+
# Hierarchical Mode (Parent/Child)
|
|
128
|
+
logger.info(f"Configuring subproject paths: {args.project_name}/{args.sub}")
|
|
129
|
+
movie.configure_subproject_paths(
|
|
130
|
+
parent_project_name=args.project_name,
|
|
131
|
+
subproject_name=args.sub,
|
|
132
|
+
source_parent_dir=args.source_dir,
|
|
133
|
+
output_root_dir=args.output_root,
|
|
134
|
+
output_filename=args.filename
|
|
135
|
+
)
|
|
136
|
+
else:
|
|
137
|
+
# Standard Mode (Flat)
|
|
138
|
+
logger.info(f"Configuring project paths: {args.project_name}")
|
|
139
|
+
movie.configure_project_paths(
|
|
140
|
+
project_name=args.project_name,
|
|
141
|
+
source_dir=args.source_dir,
|
|
142
|
+
output_root_dir=args.output_root,
|
|
143
|
+
output_filename=args.filename
|
|
144
|
+
)
|
|
145
|
+
except Exception as e:
|
|
146
|
+
logger.error(f"Failed to configure paths: {e}")
|
|
147
|
+
sys.exit(1)
|
|
148
|
+
|
|
149
|
+
# 4. Execute Actions
|
|
150
|
+
|
|
151
|
+
# Generate PPTX (--pptx)
|
|
152
|
+
if args.pptx:
|
|
153
|
+
logger.info("=" * 60)
|
|
154
|
+
logger.info("MODE: Build Slide PPTX")
|
|
155
|
+
logger.info("=" * 60)
|
|
156
|
+
movie.build_slide_pptx()
|
|
157
|
+
logger.info("PPTX generation process finished.")
|
|
158
|
+
if not args.video:
|
|
159
|
+
logger.info("Please edit the generated PPTX file and run with --video to create the movie.")
|
|
160
|
+
|
|
161
|
+
# Generate Video (--video)
|
|
162
|
+
if args.video:
|
|
163
|
+
logger.info("=" * 60)
|
|
164
|
+
logger.info("MODE: Build All Video Assets")
|
|
165
|
+
logger.info("=" * 60)
|
|
166
|
+
movie.build_all()
|
|
167
|
+
|
|
168
|
+
logger.info("All video processes finished.")
|
|
169
|
+
|
|
170
|
+
if __name__ == "__main__":
|
|
171
|
+
main()
|