Uses the official YouTube Data API v3. Requires YOUTUBE_API_KEY environment variable (free from Google Cloud Console). Returns video results with title, description, channel, publish date, and thumbnail URL. Falls back gracefully if no API key.
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package engines
|
|
|
|
import (
|
|
"net/http"
|
|
"os"
|
|
"time"
|
|
)
|
|
|
|
// NewDefaultPortedEngines returns the starter set of Go-native engines.
|
|
// The service can swap/extend this registry later as more engines are ported.
|
|
func NewDefaultPortedEngines(client *http.Client) map[string]Engine {
|
|
if client == nil {
|
|
client = &http.Client{Timeout: 10 * time.Second}
|
|
}
|
|
|
|
return map[string]Engine{
|
|
"wikipedia": &WikipediaEngine{client: client},
|
|
"arxiv": &ArxivEngine{client: client},
|
|
"crossref": &CrossrefEngine{client: client},
|
|
"braveapi": &BraveEngine{
|
|
client: client,
|
|
apiKey: os.Getenv("BRAVE_API_KEY"),
|
|
accessGateToken: os.Getenv("BRAVE_ACCESS_TOKEN"),
|
|
resultsPerPage: 20,
|
|
},
|
|
"qwant": &QwantEngine{
|
|
client: client,
|
|
category: "web-lite",
|
|
resultsPerPage: 10,
|
|
},
|
|
"duckduckgo": &DuckDuckGoEngine{client: client},
|
|
"github": &GitHubEngine{client: client},
|
|
"reddit": &RedditEngine{client: client},
|
|
"bing": &BingEngine{client: client},
|
|
"google": &GoogleEngine{client: client},
|
|
"youtube": &YouTubeEngine{
|
|
client: client,
|
|
baseURL: "https://www.googleapis.com",
|
|
},
|
|
}
|
|
}
|