Skip to content

Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.

feat: add pipeline planner

wulienc224ff7f2827
diff --git a/internal/pipeline/pipeline.go b/internal/pipeline/pipeline.go
new file mode 100644
index 00000000..3be3a417
--- /dev/null
+++ b/internal/pipeline/pipeline.go
@@ -0,0 +1,37 @@
+package pipeline
+
+import (
+ "fmt"
+ "strings"
+)
+
+type PipelineRequest struct {
+ Subtitle SubtitleRequest
+ TTS TTSRequest
+ Outputs string
+ Async bool
+}
+
+func PlanOutputs(outputs string) ([]Stage, error) {
+ parts := strings.Split(outputs, ",")
+ stages := make([]Stage, 0, len(parts))
+ for _, part := range parts {
+ output := strings.TrimSpace(part)
+ switch output {
+ case "subtitle":
+ stages = append(stages, StageSubtitle)
+ case "tts":
+ stages = append(stages, StageTTS)
+ case "horizontal-bilingual", "horizontal-dubbed":
+ stages = append(stages, StageRenderHorizontal)
+ case "vertical-bilingual", "vertical-dubbed":
+ stages = append(stages, StageRenderVertical)
+ case "cover":
+ stages = append(stages, StageCover)
+ case "":
+ default:
+ return nil, fmt.Errorf("unsupported output: %s", part)
+ }
+ }
+ return stages, nil
+}
diff --git a/internal/pipeline/pipeline_test.go b/internal/pipeline/pipeline_test.go
new file mode 100644
index 00000000..65a282b6
--- /dev/null
+++ b/internal/pipeline/pipeline_test.go
@@ -0,0 +1,33 @@
+package pipeline
+
+import "testing"
+
+func TestPlanOutputsMapsToStages(t *testing.T) {
+ got, err := PlanOutputs("subtitle,tts,horizontal-bilingual,horizontal-dubbed,vertical-bilingual,vertical-dubbed")
+ if err != nil {
+ t.Fatalf("PlanOutputs() error = %v", err)
+ }
+ want := []Stage{
+ StageSubtitle,
+ StageTTS,
+ StageRenderHorizontal,
+ StageRenderHorizontal,
+ StageRenderVertical,
+ StageRenderVertical,
+ }
+ if len(got) != len(want) {
+ t.Fatalf("len = %d, want %d", len(got), len(want))
+ }
+ for i := range want {
+ if got[i] != want[i] {
+ t.Fatalf("stage[%d] = %s, want %s", i, got[i], want[i])
+ }
+ }
+}
+
+func TestPlanOutputsRejectsUnsupportedOutput(t *testing.T) {
+ _, err := PlanOutputs("subtitle,unknown")
+ if err == nil {
+ t.Fatalf("PlanOutputs() error = nil, want error")
+ }
+}