From cd45f841932052435a28f669405b23f313d9cf62 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 6 Apr 2026 11:28:48 +0300 Subject: 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// 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// layout Co-Authored-By: Claude Sonnet 4.6 --- internal/cli/video_runner.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'internal/cli/video_runner.go') 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) -- cgit v1.2.3