-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoptions.go
More file actions
69 lines (59 loc) · 1.87 KB
/
Copy pathoptions.go
File metadata and controls
69 lines (59 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package grabber
// defaultOptions returns a default configuration
func defaultOptions() *Options {
return &Options{
BaseDir: "media/",
MaxFileSize: "49M",
Format: "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best",
RestrictFilenames: true,
NoPlaylist: true,
WriteThumbnail: true,
RecodeVideo: "",
OutputTemplate: "media.%(ext)s",
}
}
// WithOptions creates a new Grabber instance with the provided options
func (g *Grabber) WithOptions(options *Options) *Grabber {
g.options = options
return g
}
// Only set base directory for the grabber
func (g *Grabber) WithBaseDir(baseDir string) *Grabber {
g.options.BaseDir = baseDir
return g
}
// WithMaxFileSize sets the maximum file size to download
func (g *Grabber) WithMaxFileSize(size string) *Grabber {
g.options.MaxFileSize = size
return g
}
// WithFormat sets the format preference for yt-dlp
func (g *Grabber) WithFormat(format string) *Grabber {
g.options.Format = format
return g
}
// WithRestrictFilenames enables or disables filename sanitization
func (g *Grabber) WithRestrictFilenames(restrict bool) *Grabber {
g.options.RestrictFilenames = restrict
return g
}
// WithNoPlaylist sets whether to download only a single video/image if the URL is part of a playlist
func (g *Grabber) WithNoPlaylist(noPlaylist bool) *Grabber {
g.options.NoPlaylist = noPlaylist
return g
}
// WithWriteThumbnail enables or disables thumbnail downloading
func (g *Grabber) WithWriteThumbnail(write bool) *Grabber {
g.options.WriteThumbnail = write
return g
}
// WithRecodeVideo sets the video recoding format
func (g *Grabber) WithRecodeVideo(format string) *Grabber {
g.options.RecodeVideo = format
return g
}
// WithOutputTemplate sets the output filename template
func (g *Grabber) WithOutputTemplate(template string) *Grabber {
g.options.OutputTemplate = template
return g
}