config

package
v0.13.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigFileName = "config.yml"
	AppDirName     = "vget"
)
View Source
const SitesFileName = "sites.yml"

Variables

This section is empty.

Functions

func ConfigDir

func ConfigDir() (string, error)

ConfigDir returns the standard config directory for vget. Windows: %APPDATA%\vget\ macOS/Linux: ~/.config/vget/

func ConfigPath

func ConfigPath() (string, error)

ConfigPath returns the path to the config file. e.g., ~/.config/vget/config.yml

func DefaultDownloadDir

func DefaultDownloadDir() string

DefaultDownloadDir returns the default download directory Windows: ~/Downloads/vget macOS: ~/Downloads/vget Linux: ~/downloads

func Exists

func Exists() bool

Exists checks if config file exists

func Init

func Init() error

Init creates a new config.yml with default values

func IsRunningInDocker

func IsRunningInDocker() bool

IsRunningInDocker detects if we're running inside a Docker container

func Save

func Save(cfg *Config) error

Save writes the config to ~/.config/vget/config.yml

func SavePath

func SavePath() string

SavePath returns the path where config will be saved

func SaveSites

func SaveSites(cfg *SitesConfig) error

SaveSites writes sites.yml to the current directory

func SitesExist

func SitesExist() bool

SitesExist checks if sites.yml exists in current directory

Types

type BilibiliConfig added in v0.11.0

type BilibiliConfig struct {
	// Cookie is the full cookie string (SESSDATA, bili_jct, DedeUserID)
	Cookie string `yaml:"cookie,omitempty"`
}

BilibiliConfig holds Bilibili authentication settings

type Config

type Config struct {
	// Language for metadata (e.g., "en", "zh", "ja")
	Language string `yaml:"language,omitempty"`

	// Default output directory
	OutputDir string `yaml:"output_dir,omitempty"`

	// Preferred format (e.g., "mp4", "webm", "best")
	Format string `yaml:"format,omitempty"`

	// Default quality preference (e.g., "1080p", "720p", "best")
	Quality string `yaml:"quality,omitempty"`

	// WebDAV servers configuration
	WebDAVServers map[string]WebDAVServer `yaml:"webdavServers,omitempty"`

	// Twitter/X configuration
	Twitter TwitterConfig `yaml:"twitter,omitempty"`

	// Server configuration for `vget serve`
	Server ServerConfig `yaml:"server,omitempty"`

	// Express tracking providers configuration
	// Each provider has its own config structure stored as map[string]string
	// Example YAML:
	//   express:
	//     kuaidi100:
	//       key: "xxx"
	//       customer: "yyy"
	//     fedex:
	//       api_key: "zzz"
	Express map[string]map[string]string `yaml:"express,omitempty"`

	// Torrent client configuration for dispatching magnet links
	Torrent TorrentConfig `yaml:"torrent,omitempty"`

	// Bilibili configuration
	Bilibili BilibiliConfig `yaml:"bilibili,omitempty"`

	// Telegram configuration
	Telegram TelegramConfig `yaml:"telegram,omitempty"`
}

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a config with sensible defaults

func Load

func Load() (*Config, error)

Load reads the config from ~/.config/vget/config.yml

func LoadOrDefault

func LoadOrDefault() *Config

LoadOrDefault loads config if it exists, otherwise returns defaults. It also applies defaults for any empty fields in the loaded config.

func RunInitWizard

func RunInitWizard() (*Config, error)

RunInitWizard runs an interactive TUI wizard to configure vget

func (*Config) DeleteExpressConfig

func (c *Config) DeleteExpressConfig(provider, key string)

DeleteExpressConfig removes a config value for an express provider

func (*Config) DeleteWebDAVServer

func (c *Config) DeleteWebDAVServer(name string)

DeleteWebDAVServer removes a WebDAV server by name

func (*Config) GetExpressConfig

func (c *Config) GetExpressConfig(provider string) map[string]string

GetExpressConfig returns the config for a specific express provider

func (*Config) GetWebDAVServer

func (c *Config) GetWebDAVServer(name string) *WebDAVServer

GetWebDAVServer returns a WebDAV server by name, or nil if not found

func (*Config) SetExpressConfig

func (c *Config) SetExpressConfig(provider, key, value string)

SetExpressConfig sets a config value for an express provider

func (*Config) SetWebDAVServer

func (c *Config) SetWebDAVServer(name string, server WebDAVServer)

SetWebDAVServer adds or updates a WebDAV server

type ServerConfig

type ServerConfig struct {
	// Port is the HTTP listen port (default: 8080)
	Port int `yaml:"port,omitempty"`

	// MaxConcurrent is the max number of concurrent downloads (default: 10)
	MaxConcurrent int `yaml:"max_concurrent,omitempty"`

	// APIKey for authentication (optional, if set all requests must include X-API-Key header)
	APIKey string `yaml:"api_key,omitempty"`
}

ServerConfig holds HTTP server settings for `vget serve`

type Site

type Site struct {
	// Match is a substring to match against the URL (e.g., "kanav.ad")
	Match string `yaml:"match"`

	// Type is the media type to extract (e.g., "m3u8", "mp4")
	Type string `yaml:"type"`
}

Site represents a site configuration for browser-based extraction

type SitesConfig

type SitesConfig struct {
	Sites []Site `yaml:"sites"`
}

SitesConfig holds the sites configuration

func LoadSites

func LoadSites() (*SitesConfig, error)

LoadSites reads sites.yml from the current directory

func (*SitesConfig) AddSite

func (c *SitesConfig) AddSite(match, mediaType string)

AddSite adds a new site configuration

func (*SitesConfig) MatchSite

func (c *SitesConfig) MatchSite(url string) *Site

MatchSite finds a matching site for the given URL

func (*SitesConfig) RemoveSite

func (c *SitesConfig) RemoveSite(match string) bool

RemoveSite removes a site by match string

type TelegramConfig added in v0.13.3

type TelegramConfig struct {
	// TDataPath is the custom path to Telegram Desktop tdata directory
	TDataPath string `yaml:"tdata_path,omitempty"`
}

TelegramConfig holds Telegram authentication settings

type TorrentConfig added in v0.10.0

type TorrentConfig struct {
	// Enabled determines if torrent dispatch feature is active
	Enabled bool `yaml:"enabled,omitempty"`

	// Client type: "transmission", "qbittorrent", "synology"
	Client string `yaml:"client,omitempty"`

	// Host is the torrent client address (e.g., "192.168.1.100:9091")
	Host string `yaml:"host,omitempty"`

	// Username for authentication
	Username string `yaml:"username,omitempty"`

	// Password for authentication
	Password string `yaml:"password,omitempty"`

	// UseHTTPS enables HTTPS connection to torrent client
	UseHTTPS bool `yaml:"use_https,omitempty"`

	// DefaultSavePath overrides the client's default download directory
	DefaultSavePath string `yaml:"default_save_path,omitempty"`
}

TorrentConfig holds configuration for remote torrent client integration

type TwitterConfig

type TwitterConfig struct {
	// AuthToken is the auth_token cookie value from browser (for NSFW content)
	AuthToken string `yaml:"auth_token,omitempty"`
}

TwitterConfig holds Twitter/X authentication settings

type WebDAVServer

type WebDAVServer struct {
	// URL is the WebDAV server URL (e.g., "https://pikpak.com/dav")
	URL string `yaml:"url"`

	// Username for authentication
	Username string `yaml:"username,omitempty"`

	// Password for authentication
	Password string `yaml:"password,omitempty"`
}

WebDAVServer represents a WebDAV server configuration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL