55 "errors"
66 "fmt"
77 "go.uber.org/zap"
8+ "krillin-ai/config"
89 "krillin-ai/internal/storage"
910 "krillin-ai/internal/types"
1011 "krillin-ai/log"
@@ -41,7 +42,9 @@ func (s Service) linkToFile(ctx context.Context, stepParam *types.SubtitleTaskSt
4142 }
4243 stepParam .Link = "https://www.youtube.com/watch?v=" + videoId
4344 cmdArgs := []string {"-f" , "bestaudio" , "--extract-audio" , "--audio-format" , "mp3" , "--audio-quality" , "192K" , "-o" , audioPath , stepParam .Link }
44-
45+ if config .Conf .App .Proxy != "" {
46+ cmdArgs = append (cmdArgs , "--proxy" , config .Conf .App .Proxy )
47+ }
4548 cmdArgs = append (cmdArgs , "--cookies" , "./cookies.txt" )
4649 if storage .FfmpegPath != "ffmpeg" {
4750 cmdArgs = append (cmdArgs , "--ffmpeg-location" , storage .FfmpegPath )
@@ -59,6 +62,9 @@ func (s Service) linkToFile(ctx context.Context, stepParam *types.SubtitleTaskSt
5962 }
6063 stepParam .Link = "https://www.bilibili.com/video/" + videoId
6164 cmdArgs := []string {"-f" , "bestaudio[ext=m4a]" , "-x" , "--audio-format" , "mp3" , "-o" , audioPath , stepParam .Link }
65+ if config .Conf .App .Proxy != "" {
66+ cmdArgs = append (cmdArgs , "--proxy" , config .Conf .App .Proxy )
67+ }
6268 if storage .FfmpegPath != "ffmpeg" {
6369 cmdArgs = append (cmdArgs , "--ffmpeg-location" , storage .FfmpegPath )
6470 }
@@ -77,7 +83,11 @@ func (s Service) linkToFile(ctx context.Context, stepParam *types.SubtitleTaskSt
7783
7884 if ! strings .HasPrefix (link , "local:" ) && stepParam .EmbedSubtitleVideoType != "none" {
7985 // 需要下载原视频
80- 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 )
86+ 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 }
87+ if config .Conf .App .Proxy != "" {
88+ cmdArgs = append (cmdArgs , "--proxy" , config .Conf .App .Proxy )
89+ }
90+ cmd := exec .Command (storage .YtdlpPath , cmdArgs ... )
8191 output , err = cmd .CombinedOutput ()
8292 if err != nil {
8393 log .GetLogger ().Error ("linkToFile download video yt-dlp error" , zap .Any ("step param" , stepParam ), zap .String ("output" , string (output )), zap .Error (err ))
0 commit comments