feat: add YouTube engine with config file and env support
YouTube Data API v3 engine: - Add YouTubeConfig to EnginesConfig with api_key field - Add YOUTUBE_API_KEY env override - Thread *config.Config through search service to factory - Factory falls back to env vars if config fields are empty - Update config.example.toml with youtube section Also update default local_ported to include google and youtube.
This commit is contained in:
parent
38122385bd
commit
41b80a939a
5 changed files with 47 additions and 12 deletions
|
|
@ -35,6 +35,7 @@ type EnginesConfig struct {
|
|||
LocalPorted []string `toml:"local_ported"`
|
||||
Brave BraveConfig `toml:"brave"`
|
||||
Qwant QwantConfig `toml:"qwant"`
|
||||
YouTube YouTubeConfig `toml:"youtube"`
|
||||
}
|
||||
|
||||
// CacheConfig holds Valkey/Redis cache settings.
|
||||
|
|
@ -85,6 +86,10 @@ type QwantConfig struct {
|
|||
ResultsPerPage int `toml:"results_per_page"`
|
||||
}
|
||||
|
||||
type YouTubeConfig struct {
|
||||
APIKey string `toml:"api_key"`
|
||||
}
|
||||
|
||||
// Load reads configuration from the given TOML file path.
|
||||
// If the file does not exist, it returns defaults (empty values where applicable).
|
||||
// Environment variables are used as fallbacks for any zero-value fields.
|
||||
|
|
@ -109,7 +114,7 @@ func defaultConfig() *Config {
|
|||
},
|
||||
Upstream: UpstreamConfig{},
|
||||
Engines: EnginesConfig{
|
||||
LocalPorted: []string{"wikipedia", "arxiv", "crossref", "braveapi", "qwant", "duckduckgo", "github", "reddit", "bing"},
|
||||
LocalPorted: []string{"wikipedia", "arxiv", "crossref", "braveapi", "qwant", "duckduckgo", "github", "reddit", "bing", "google", "youtube"},
|
||||
Qwant: QwantConfig{
|
||||
Category: "web-lite",
|
||||
ResultsPerPage: 10,
|
||||
|
|
@ -151,6 +156,9 @@ func applyEnvOverrides(cfg *Config) {
|
|||
if v := os.Getenv("BRAVE_ACCESS_TOKEN"); v != "" {
|
||||
cfg.Engines.Brave.AccessToken = v
|
||||
}
|
||||
if v := os.Getenv("YOUTUBE_API_KEY"); v != "" {
|
||||
cfg.Engines.YouTube.APIKey = v
|
||||
}
|
||||
if v := os.Getenv("VALKEY_ADDRESS"); v != "" {
|
||||
cfg.Cache.Address = v
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue