Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ListExtractors ¶
func ListExtractors() []string
ListExtractors returns the names of all registered extractors.
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context implements the Context for internal use.
func NewContext ¶
NewContext creates a new Context with the provided options.
func (*Context) GetProgressCallback ¶
func (c *Context) GetProgressCallback() ProgressCallback
GetProgressCallback returns the progress callback
func (*Context) SetProgressCallback ¶
func (c *Context) SetProgressCallback(callback ProgressCallback)
SetProgressCallback sets the progress callback for the context
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
Downloader manages high-level download logic with support for HTTP range requests, resumable downloads, and multi-threaded downloads.
func NewDownloader ¶
func NewDownloader(ctx *Context) *Downloader
NewDownloader creates a new Downloader instance with the provided context.
func (*Downloader) Download ¶
func (d *Downloader) Download(medias []Media) error
Download downloads all streams from the extracted media for the given URL. If ExtractOnly is set, only prints media info without downloading.
type Media ¶
type Media struct {
Title string // Media title or name
Streams []Stream // All available streams (keyed by quality or id)
Thumbnail string // URL to thumbnail image (optional)
Description string // Description of the media (optional)
Extra map[string]string // Additional info for extensibility
}
Media represents a downloadable media resource with multiple streams.
type Option ¶
type Option struct {
// Output options
OutputPath string // Output directory for downloaded files (--output-dir, -o)
OutputName string // Output filename (--output-filename, -O)
// Quality and format
Quality string // Preferred video quality, e.g. "best", "worst", "720p" (--quality, -q)
Format string // Output format, e.g. "mp4", "mkv", "mp3" (--format, -f)
// Network options
Headers http.Header // Custom HTTP headers (--header, -H)
UserAgent string // Custom user agent (--user-agent, -u)
Proxy string // HTTP proxy URL (--proxy, -x)
RetryCount int // Number of retry attempts (--retry, -r)
Timeout time.Duration // Request timeout (--timeout, -t)
// Rate limit (bytes per second), 0 means unlimited
RateLimit int64 // Download speed limit (--rate-limit)
// Advanced authentication
AuthType string // Authentication type: "", "basic", "bearer", "header" (--auth-type)
AuthUser string // Username for basic auth (--auth-user)
AuthPass string // Password for basic auth (--auth-pass)
AuthToken string // Token for bearer auth (--auth-token)
AuthHeader string // Custom header for auth, e.g. "X-API-Key: ..." (--auth-header)
Cookie string // Cookie file path for authentication (--cookies, -c)
// Download options
Threads int // Number of concurrent download threads (--threads, -n)
ChunkSize int64 // Download chunk size in bytes
NoSkipExisting bool // Do not skip existing files (--no-skip, -S)
// Behavior options
ExtractOnly bool // Only extract media info, do not download (--info, -i)
Playlist bool // Download all videos in playlist (--playlist, -p)
PlaylistStart int // Playlist start index (--playlist-start)
PlaylistEnd int // Playlist end index (--playlist-end)
// Content options
Subtitle bool // Download subtitles (--subtitle)
VideoOnly bool // Download video only, no audio (--video-only)
AudioOnly bool // Download audio only (--audio-only)
IgnoreErrors bool // Continue on errors (--ignore-errors)
// Error handling and logging
Debug bool // Enable debug logging (--debug, -d)
Verbose bool // Enable verbose output (--verbose, -v)
Silent bool // Suppress all output except errors (--silent)
}
Option defines all configurable parameters for downloading and extraction. Each field corresponds to a command-line flag in main.go/setupFlags. Callers should ensure OutputPath exists or is creatable. Threads should be >=1; ChunkSize in bytes.
type PlaylistFilter ¶
PlaylistFilter filters playlist streams by index range.
func (*PlaylistFilter) Filter ¶
func (f *PlaylistFilter) Filter(stream Stream) bool
type ProgressCallback ¶
ProgressCallback defines the callback function for progress updates
type Stream ¶
type Stream struct {
ID string // Unique identifier for this stream
Title string // Title or name of the stream
Type StreamType // Type of the stream (video, audio, etc.)
URL string // Direct URL to this stream
Format string // Format (e.g., "mp4", "webm", "mp3")
Quality string // Quality/bitrate info (e.g., "1080p", "320kbps")
Size int64 // Size in bytes (if known)
Duration time.Duration // Duration of the stream (if applicable)
Header http.Header // Custom headers for this stream (optional)
Extra map[string]string // Extensible fields (e.g., codec info)
SaveAs string // Suggested filename to save this stream
}
Stream represents a single media stream (e.g. one quality/format)
type StreamType ¶
type StreamType string
StreamType defines the type of media resource.
const ( StreamTypeVideo StreamType = "video" StreamTypeAudio StreamType = "audio" StreamTypeImage StreamType = "image" StreamTypeSubtitle StreamType = "subtitle" StreamTypePlaylist StreamType = "playlist" StreamTypeM3u8 StreamType = "m3u8" StreamTypeDocument StreamType = "document" StreamTypeOther StreamType = "other" )