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.

fix: handle empty youtube query id

wulien65545308f7a8
diff --git a/internal/pipeline/workdir.go b/internal/pipeline/workdir.go
index deea4179..99f861a7 100644
--- a/internal/pipeline/workdir.go
+++ b/internal/pipeline/workdir.go
@@ -27,8 +27,9 @@ func makeTaskID(input string) string {
if trimmed == "" {
last = "task"
} else if parsed, err := url.Parse(trimmed); err == nil {
- if v := parsed.Query().Get("v"); v != "" {
- last = v
+ query := parsed.Query()
+ if values, ok := query["v"]; ok && len(values) > 0 {
+ last = values[0]
} else if parsed.Path != "" {
parts := strings.Split(strings.Trim(parsed.Path, "/"), "/")
last = parts[len(parts)-1]
diff --git a/internal/pipeline/workdir_test.go b/internal/pipeline/workdir_test.go
index 3adbadfa..ced4fece 100644
--- a/internal/pipeline/workdir_test.go
+++ b/internal/pipeline/workdir_test.go
@@ -56,3 +56,10 @@ func TestMakeTaskIDUsesQueryVWithoutPath(t *testing.T) {
t.Fatalf("makeTaskID(query v) = %q, want abc123_ prefix", got)
}
}
+
+func TestMakeTaskIDUsesEmptyQueryVAsFallback(t *testing.T) {
+ got := makeTaskID("https://example.com/watch?v=")
+ if !strings.HasPrefix(got, "task_") {
+ t.Fatalf("makeTaskID(empty query v) = %q, want task_ prefix", got)
+ }
+}