From 0846732ece76c585977a41b7df35fd64802c04ec Mon Sep 17 00:00:00 2001 From: Gamers_indo1223 <76719536+gamersindo1223@users.noreply.github.com> Date: Sun, 7 Jul 2024 12:20:23 +0000 Subject: [PATCH 1/3] Add force IPV4 support --- goutubedl.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/goutubedl.go b/goutubedl.go index 8f10792..fe80bba 100644 --- a/goutubedl.go +++ b/goutubedl.go @@ -225,6 +225,7 @@ type Options struct { DownloadSubtitles bool DownloadSections string // --download-sections ProxyUrl string // --proxy URL http://host:port or socks5://host:port + UseIPV4 bool CookiesFromBrowser string // --cookies-from-browser BROWSER[:FOLDER] DebugLog Printer StderrFn func(cmd *exec.Cmd) io.Writer // if not nil, function to get Writer for stderr @@ -321,6 +322,10 @@ func infoFromURL( cmd.Args = append(cmd.Args, "--proxy", options.ProxyUrl) } + if options.UseIPV4 { + cmd.Args = append(cmd.Args, "-4") + } + if options.Downloader != "" { cmd.Args = append(cmd.Args, "--downloader", options.Downloader) } @@ -328,7 +333,7 @@ func infoFromURL( if options.CookiesFromBrowser != "" { cmd.Args = append(cmd.Args, "--cookies-from-browser", options.CookiesFromBrowser) } - + switch options.Type { case TypePlaylist, TypeChannel: cmd.Args = append(cmd.Args, "--yes-playlist") From 7993835dad77ca62e2fd2b34b99db4da621cc050 Mon Sep 17 00:00:00 2001 From: Gamers_indo1223 <76719536+gamersindo1223@users.noreply.github.com> Date: Sun, 7 Jul 2024 22:45:24 +0000 Subject: [PATCH 2/3] Add some changes (DownloadOptions, Add comments) --- goutubedl.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/goutubedl.go b/goutubedl.go index fe80bba..f3adb26 100644 --- a/goutubedl.go +++ b/goutubedl.go @@ -225,7 +225,7 @@ type Options struct { DownloadSubtitles bool DownloadSections string // --download-sections ProxyUrl string // --proxy URL http://host:port or socks5://host:port - UseIPV4 bool + UseIPV4 bool // -4 Make all connections via IPv4 CookiesFromBrowser string // --cookies-from-browser BROWSER[:FOLDER] DebugLog Printer StderrFn func(cmd *exec.Cmd) io.Writer // if not nil, function to get Writer for stderr @@ -528,6 +528,9 @@ type DownloadOptions struct { // The index of the entry to download from the playlist that would be // passed to youtube-dl via --playlist-items. The index value starts at 1 PlaylistIndex int + + // -4 Make all connections via IPv4 + UseIPV4 bool } func (result Result) DownloadWithOptions( @@ -609,7 +612,10 @@ func (result Result) DownloadWithOptions( } else { cmd.Args = append(cmd.Args, "--load-info", jsonTempPath) } - + //Force IPV4 Usage + if options.UseIPV4 { + cmd.Args = append(cmd.Args, "-4") + } // don't need to specify if direct as there is only one // also seems to be issues when using filter with generic extractor if !result.Info.Direct && options.Filter != "" { From 4b359ddd61d3f16a8fc0e9da1ddad20f5d4b6b42 Mon Sep 17 00:00:00 2001 From: Gamers_indo1223 <76719536+gamersindo1223@users.noreply.github.com> Date: Mon, 8 Jul 2024 10:06:40 +0000 Subject: [PATCH 3/3] Use existing Force IPV4 Config --- goutubedl.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/goutubedl.go b/goutubedl.go index f3adb26..2c3fb7e 100644 --- a/goutubedl.go +++ b/goutubedl.go @@ -527,10 +527,7 @@ type DownloadOptions struct { Filter string // The index of the entry to download from the playlist that would be // passed to youtube-dl via --playlist-items. The index value starts at 1 - PlaylistIndex int - - // -4 Make all connections via IPv4 - UseIPV4 bool + PlaylistIndex int } func (result Result) DownloadWithOptions( @@ -613,7 +610,7 @@ func (result Result) DownloadWithOptions( cmd.Args = append(cmd.Args, "--load-info", jsonTempPath) } //Force IPV4 Usage - if options.UseIPV4 { + if result.Options.UseIPV4 { cmd.Args = append(cmd.Args, "-4") } // don't need to specify if direct as there is only one