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.
TypeScript agent-skillscodex-clideskop-appdubbingimage-generationlocalizationskillsttsvideo-editingvideo-generationvideo-transcriptionvideo-translation
feat: add proxy in ytdlp
沈浩6658ea341722
diff --git a/internal/service/get_video_info.go b/internal/service/get_video_info.goindex 742260e7..dd44fad9 100644--- a/internal/service/get_video_info.go+++ b/internal/service/get_video_info.go@@ -4,6 +4,7 @@ import ("context""fmt""go.uber.org/zap"+ "krillin-ai/config""krillin-ai/internal/storage""krillin-ai/internal/types""krillin-ai/log"@@ -23,6 +24,10 @@ func (s Service) getVideoInfo(ctx context.Context, stepParam *types.SubtitleTaskdescriptionCmdArgs := []string{"--skip-download", "--encoding", "utf-8", "--get-description", stepParam.Link}titleCmdArgs = append(titleCmdArgs, "--cookies", "./cookies.txt")descriptionCmdArgs = append(descriptionCmdArgs, "--cookies", "./cookies.txt")+ if config.Conf.App.Proxy != "" {+ titleCmdArgs = append(titleCmdArgs, "--proxy", config.Conf.App.Proxy)+ descriptionCmdArgs = append(descriptionCmdArgs, "--proxy", config.Conf.App.Proxy)+ }if storage.FfmpegPath != "ffmpeg" {titleCmdArgs = append(titleCmdArgs, "--ffmpeg-location", storage.FfmpegPath)descriptionCmdArgs = append(descriptionCmdArgs, "--ffmpeg-location", storage.FfmpegPath)diff --git a/internal/service/link2file.go b/internal/service/link2file.goindex 2134f795..1cf6b588 100644--- a/internal/service/link2file.go+++ b/internal/service/link2file.go@@ -5,6 +5,7 @@ import ("errors""fmt""go.uber.org/zap"+ "krillin-ai/config""krillin-ai/internal/storage""krillin-ai/internal/types""krillin-ai/log"@@ -41,7 +42,9 @@ func (s Service) linkToFile(ctx context.Context, stepParam *types.SubtitleTaskSt}stepParam.Link = "https://www.youtube.com/watch?v=" + videoIdcmdArgs := []string{"-f", "bestaudio", "--extract-audio", "--audio-format", "mp3", "--audio-quality", "192K", "-o", audioPath, stepParam.Link}-+ if config.Conf.App.Proxy != "" {+ cmdArgs = append(cmdArgs, "--proxy", config.Conf.App.Proxy)+ }cmdArgs = append(cmdArgs, "--cookies", "./cookies.txt")if storage.FfmpegPath != "ffmpeg" {cmdArgs = append(cmdArgs, "--ffmpeg-location", storage.FfmpegPath)@@ -59,6 +62,9 @@ func (s Service) linkToFile(ctx context.Context, stepParam *types.SubtitleTaskSt}stepParam.Link = "https://www.bilibili.com/video/" + videoIdcmdArgs := []string{"-f", "bestaudio[ext=m4a]", "-x", "--audio-format", "mp3", "-o", audioPath, stepParam.Link}+ if config.Conf.App.Proxy != "" {+ cmdArgs = append(cmdArgs, "--proxy", config.Conf.App.Proxy)+ }if storage.FfmpegPath != "ffmpeg" {cmdArgs = append(cmdArgs, "--ffmpeg-location", storage.FfmpegPath)}@@ -77,7 +83,11 @@ func (s Service) linkToFile(ctx context.Context, stepParam *types.SubtitleTaskStif !strings.HasPrefix(link, "local:") && stepParam.EmbedSubtitleVideoType != "none" {// 需要下载原视频- cmd := exec.Command(storage.YtdlpPath, "-f", "bestvideo[height<=1080][ext=mp4]+bestaudio[ext=m4a]/bestvideo[height<=720][ext=mp4]+bestaudio[ext=m4a]/bestvideo[height<=480][ext=mp4]+bestaudio[ext=m4a]", "-o", videoPath, stepParam.Link)+ cmdArgs := []string{"-f", "bestvideo[height<=1080][ext=mp4]+bestaudio[ext=m4a]/bestvideo[height<=720][ext=mp4]+bestaudio[ext=m4a]/bestvideo[height<=480][ext=mp4]+bestaudio[ext=m4a]", "-o", videoPath, stepParam.Link}+ if config.Conf.App.Proxy != "" {+ cmdArgs = append(cmdArgs, "--proxy", config.Conf.App.Proxy)+ }+ cmd := exec.Command(storage.YtdlpPath, cmdArgs...)output, err = cmd.CombinedOutput()if err != nil {log.GetLogger().Error("linkToFile download video yt-dlp error", zap.Any("step param", stepParam), zap.String("output", string(output)), zap.Error(err))diff --git a/static/index.html b/static/index.htmlindex 17e30717..d1aa09dc 100644--- a/static/index.html+++ b/static/index.html@@ -331,6 +331,7 @@<option value="ja">日文</option><option value="tr">土耳其语</option><option value="de">德语</option>+ <option value="ko">韩语</option></select></div>