Compare commits
48 Commits
v2.1.0
...
bump-golan
Author | SHA1 | Date | |
---|---|---|---|
d3f32f5956 | |||
a623bde37b | |||
90467bcf8a | |||
d47fecba92 | |||
65804d5c0f | |||
95037e2caf | |||
346cfb47a0 | |||
5d0a261ec7 | |||
e76467b99a | |||
ccf6ee70f7 | |||
1397992b2e | |||
d5bf934f84 | |||
f62b41e2a6 | |||
4a4a53c745 | |||
242d6af088 | |||
5d7e2d8fc4 | |||
131c95e1dd | |||
3abe5ae66a | |||
0986214517 | |||
a52c8dca32 | |||
f4ee4aff9a | |||
b5b253140e | |||
4b7a642b1f | |||
15628e7770 | |||
4b359ddd61 | |||
7993835dad | |||
0846732ece | |||
3eb676f2fd | |||
dfbb1770e4 | |||
3004939371 | |||
79030f02cf | |||
b861e6f3a2 | |||
cb86a6c681 | |||
0ca6990373 | |||
8cef76d0c0 | |||
cad168222b | |||
8598c9e6bb | |||
5cb220b4d7 | |||
74fbd541cd | |||
4dfa55bcfd | |||
fdbd42f666 | |||
2ac97f392a | |||
aba4746463 | |||
1fdc3448b1 | |||
598fce21e7 | |||
ff8aaa0333 | |||
7b1a15b73a | |||
24fd49fe06 |
6
.github/workflows/push.yml
vendored
6
.github/workflows/push.yml
vendored
@ -1,6 +1,10 @@
|
||||
name: Build on push and PRs
|
||||
|
||||
on: [push,pull_request]
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "master"
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
@ -1,9 +1,9 @@
|
||||
# bump: golang /GOLANG_VERSION=([\d.]+)/ docker:golang|^1
|
||||
# bump: golang link "Release notes" https://golang.org/doc/devel/release.html
|
||||
ARG GOLANG_VERSION=1.22.1
|
||||
ARG GOLANG_VERSION=1.23.1
|
||||
# bump: yt-dlp /YT_DLP=([\d.-]+)/ https://github.com/yt-dlp/yt-dlp.git|/^\d/|sort
|
||||
# bump: yt-dlp link "Release notes" https://github.com/yt-dlp/yt-dlp/releases/tag/$LATEST
|
||||
ARG YT_DLP=2024.03.10
|
||||
ARG YT_DLP=2024.08.06
|
||||
|
||||
FROM golang:$GOLANG_VERSION AS base
|
||||
ARG YT_DLP
|
||||
|
10
README.md
10
README.md
@ -53,6 +53,16 @@ func main() {
|
||||
See [goutubedl cmd tool](cmd/goutubedl/main.go) or [ydls](https://github.com/wader/ydls)
|
||||
for usage examples.
|
||||
|
||||
### Default options and cache
|
||||
|
||||
#### .netrc
|
||||
|
||||
goutubedl by default uses `--netrc` to use `~/.netrc` authentication data.
|
||||
|
||||
#### Cache directory
|
||||
|
||||
yt-dlp stores various extractor session data to speed up things in `${XDG_CACHE_HOME}/yt-dlp` (usually `~/.cache/yt-dlp`). You might want to preverse this directory if your running things in ephemeral conatiners etc.
|
||||
|
||||
### Development
|
||||
|
||||
```sh
|
||||
|
65
goutubedl.go
65
goutubedl.go
@ -217,14 +217,17 @@ var TypeFromString = map[string]Type{
|
||||
|
||||
// Options for New()
|
||||
type Options struct {
|
||||
Type Type
|
||||
PlaylistStart uint // --playlist-start
|
||||
PlaylistEnd uint // --playlist-end
|
||||
Downloader string // --downloader
|
||||
DownloadThumbnail bool
|
||||
DownloadSubtitles bool
|
||||
DownloadSections string // --download-sections
|
||||
Type Type
|
||||
PlaylistStart uint // --playlist-start
|
||||
PlaylistEnd uint // --playlist-end
|
||||
Downloader string // --downloader
|
||||
DownloadThumbnail bool
|
||||
DownloadSubtitles bool
|
||||
DownloadSections string // --download-sections
|
||||
|
||||
ProxyUrl string // --proxy URL http://host:port or socks5://host:port
|
||||
UseIPV4 bool // -4 Make all connections via IPv4
|
||||
Cookies string // --cookies FILE
|
||||
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
|
||||
@ -304,23 +307,35 @@ func infoFromURL(
|
||||
ProbePath(),
|
||||
// see comment below about ignoring errors for playlists
|
||||
"--ignore-errors",
|
||||
// TODO: deprecated in yt-dlp?
|
||||
"--no-call-home",
|
||||
"--no-cache-dir",
|
||||
"--skip-download",
|
||||
// use safer output filenmaes
|
||||
// TODO: needed?
|
||||
"--restrict-filenames",
|
||||
// provide URL via stdin for security, youtube-dl has some run command args
|
||||
// use .netrc authentication data
|
||||
"--netrc",
|
||||
// provide url via stdin for security, youtube-dl has some run command args
|
||||
"--batch-file", "-",
|
||||
"-J",
|
||||
// dump info json
|
||||
"--dump-single-json",
|
||||
)
|
||||
|
||||
if options.ProxyUrl != "" {
|
||||
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)
|
||||
}
|
||||
|
||||
if options.Cookies != "" {
|
||||
cmd.Args = append(cmd.Args, "--cookies", options.Cookies)
|
||||
}
|
||||
|
||||
if options.CookiesFromBrowser != "" {
|
||||
cmd.Args = append(cmd.Args, "--cookies-from-browser", options.CookiesFromBrowser)
|
||||
}
|
||||
@ -513,6 +528,8 @@ func (result Result) Download(ctx context.Context, filter string) (*DownloadResu
|
||||
}
|
||||
|
||||
type DownloadOptions struct {
|
||||
AudioFormats string // --audio-formats Download audio using formats (best, aac, alac, flac, m4a, mp3, opus, vorbis, wav)
|
||||
DownloadAudioOnly bool // -x Download audio only from video
|
||||
// Download format matched by filter (usually a format id or quality designator).
|
||||
// If filter is empty, then youtube-dl will use its default format selector.
|
||||
Filter string
|
||||
@ -559,12 +576,19 @@ func (result Result) DownloadWithOptions(
|
||||
cmd := exec.CommandContext(
|
||||
ctx,
|
||||
ProbePath(),
|
||||
"--no-call-home",
|
||||
"--no-cache-dir",
|
||||
// see comment below about ignoring errors for playlists
|
||||
"--ignore-errors",
|
||||
// TODO: deprecated in yt-dlp?
|
||||
"--no-call-home",
|
||||
// use non-fancy progress bar
|
||||
"--newline",
|
||||
// use safer output filenmaes
|
||||
// TODO: needed?
|
||||
"--restrict-filenames",
|
||||
"-o", "-",
|
||||
// use .netrc authentication data
|
||||
"--netrc",
|
||||
// write to stdout
|
||||
"--output", "-",
|
||||
)
|
||||
|
||||
if result.Options.noInfoDownload {
|
||||
@ -593,7 +617,10 @@ func (result Result) DownloadWithOptions(
|
||||
} else {
|
||||
cmd.Args = append(cmd.Args, "--load-info", jsonTempPath)
|
||||
}
|
||||
|
||||
// force IPV4 Usage
|
||||
if result.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 != "" {
|
||||
@ -604,6 +631,14 @@ func (result Result) DownloadWithOptions(
|
||||
cmd.Args = append(cmd.Args, "--playlist-items", fmt.Sprint(options.PlaylistIndex))
|
||||
}
|
||||
|
||||
if options.DownloadAudioOnly {
|
||||
cmd.Args = append(cmd.Args, "-x")
|
||||
}
|
||||
|
||||
if options.AudioFormats != "" {
|
||||
cmd.Args = append(cmd.Args, "--audio-format", options.AudioFormats)
|
||||
}
|
||||
|
||||
if result.Options.ProxyUrl != "" {
|
||||
cmd.Args = append(cmd.Args, "--proxy", result.Options.ProxyUrl)
|
||||
}
|
||||
|
Reference in New Issue
Block a user