added config values to configure enabled meta-search engines
This commit is contained in:
parent
dc4a3a4bec
commit
5e6fc73038
7 changed files with 184 additions and 88 deletions
33
files.go
33
files.go
|
@ -30,11 +30,25 @@ var (
|
|||
|
||||
var fileResultsChan = make(chan []TorrentResult)
|
||||
|
||||
func init() {
|
||||
torrentGalaxy = NewTorrentGalaxy()
|
||||
// nyaa = NewNyaa()
|
||||
thePirateBay = NewThePirateBay()
|
||||
// rutor = NewRutor()
|
||||
func initFileEngines() {
|
||||
|
||||
torrentGalaxy = nil
|
||||
thePirateBay = nil
|
||||
// nyaa = nil
|
||||
// rutor = nil
|
||||
|
||||
for _, engineName := range config.MetaSearch.Files {
|
||||
switch engineName {
|
||||
case "TorrentGalaxy":
|
||||
torrentGalaxy = NewTorrentGalaxy()
|
||||
case "ThePirateBay":
|
||||
thePirateBay = NewThePirateBay()
|
||||
// case "Nyaa":
|
||||
// nyaa = NewNyaa()
|
||||
// case "Rutor":
|
||||
// rutor = NewRutor()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func handleFileSearch(w http.ResponseWriter, settings UserSettings, query string, page int) {
|
||||
|
@ -123,7 +137,7 @@ func fetchFileResults(query, safe, lang string, page int) []TorrentResult {
|
|||
}
|
||||
|
||||
sites := []TorrentSite{torrentGalaxy, nyaa, thePirateBay, rutor}
|
||||
results := []TorrentResult{}
|
||||
var results []TorrentResult
|
||||
|
||||
for _, site := range sites {
|
||||
if site == nil {
|
||||
|
@ -140,9 +154,12 @@ func fetchFileResults(query, safe, lang string, page int) []TorrentResult {
|
|||
}
|
||||
}
|
||||
|
||||
// If no results, try from other nodes
|
||||
if len(results) == 0 {
|
||||
printWarn("No file results found for query: %s, trying other nodes", query)
|
||||
results = tryOtherNodesForFileSearch(query, safe, lang, page, []string{hostID})
|
||||
if config.NodesEnabled {
|
||||
printWarn("No file results found for query: %s, trying other nodes", query)
|
||||
results = tryOtherNodesForFileSearch(query, safe, lang, page, []string{hostID})
|
||||
}
|
||||
}
|
||||
|
||||
return results
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue