diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-06 11:28:48 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-06 11:28:48 +0300 |
| commit | cd45f841932052435a28f669405b23f313d9cf62 (patch) | |
| tree | 81a01f7d28176da3de847243ec3c78087301fea3 /internal/cli/video_runner.go | |
| parent | ef1f3d03ac3f117fecd999fc4fa96f557bfa8fe4 (diff) | |
fix: correct video integration after comic generation
PromptForGalleryVideos now returns []string paths (from recursive walk)
instead of []int page numbers, so GenerateSelectedVideos always has the
exact path to each gallery PNG regardless of which comics/<slug>/
subdirectory it lives in.
Previously, GenerateSelectedVideos passed "." as galleryPath and called
loadGalleryImage with a non-recursive filepath.Glob that could not find
PNGs in subdirectories, causing video generation to always fail with
"no gallery image found".
Additional changes:
- Add VeoGenerator.GenerateVideoFromPath that accepts a full image path
and writes the MP4 next to the source PNG
- Make runStoryVideos non-fatal: video errors print a warning and return
nil so comic/PDF/narration outputs are never invalidated by Veo errors
- Add filterPathsByPages helper and tests for the new behaviour
- Add TestFindGalleryPages_Recursive to cover the comics/<slug>/ layout
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/cli/video_runner.go')
| -rw-r--r-- | internal/cli/video_runner.go | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/internal/cli/video_runner.go b/internal/cli/video_runner.go index 2679a26..96cd7cd 100644 --- a/internal/cli/video_runner.go +++ b/internal/cli/video_runner.go @@ -12,15 +12,15 @@ import ( // (Veo generation is slow and API quotas make parallelism impractical). // // apiKey is the Google/Gemini API key passed by the caller. -// selected is the list of gallery page numbers to process (from PromptForGalleryVideos). -// outputDir is both the directory that contains the gallery PNGs and the -// destination for the resulting MP4 files (written next to the PNGs). +// selectedPaths contains the absolute (or relative) paths of the gallery PNGs +// to animate — typically returned by PromptForGalleryVideos. // // Each page prints a "Generating…" line before the API call and a "Video saved:" -// line with the output path on success. The function stops and returns on the -// first error so callers can log it without silently skipping pages. -func GenerateSelectedVideos(apiKey string, selected []int, outputDir string) error { - if len(selected) == 0 { +// line with the output path on success. The MP4 is written next to its source +// PNG so that gallery images and their videos stay in the same directory. +// The function stops and returns on the first error so the caller can log it. +func GenerateSelectedVideos(apiKey string, selectedPaths []string) error { + if len(selectedPaths) == 0 { return nil } @@ -31,12 +31,12 @@ func GenerateSelectedVideos(apiKey string, selected []int, outputDir string) err ctx := context.Background() - for _, pageNum := range selected { - fmt.Printf("Generating video for gallery page %d...\n", pageNum) + for _, imgPath := range selectedPaths { + fmt.Printf("Generating video for: %s\n", imgPath) - mp4Path, err := gen.GenerateVideoFromGallery(ctx, outputDir, outputDir, pageNum) + mp4Path, err := gen.GenerateVideoFromPath(ctx, imgPath) if err != nil { - return fmt.Errorf("cli: generating video for page %d: %w", pageNum, err) + return fmt.Errorf("cli: generating video for %s: %w", imgPath, err) } fmt.Printf("Video saved: %s\n", mp4Path) |
