updated 'config.ini'
This commit is contained in:
parent
28f71271d7
commit
be4f86580e
13 changed files with 635 additions and 208 deletions
19
forums.go
19
forums.go
|
@ -11,6 +11,11 @@ import (
|
|||
)
|
||||
|
||||
func PerformRedditSearch(query string, safe string, page int) ([]ForumSearchResult, error) {
|
||||
if !config.CrawlerEnabled {
|
||||
printDebug("Crawler is disabled; skipping forum search.")
|
||||
return []ForumSearchResult{}, nil
|
||||
}
|
||||
|
||||
const (
|
||||
pageSize = 25
|
||||
baseURL = "https://www.reddit.com"
|
||||
|
@ -101,8 +106,18 @@ func handleForumsSearch(w http.ResponseWriter, settings UserSettings, query stri
|
|||
// Start measuring the time for fetching results
|
||||
startTime := time.Now()
|
||||
|
||||
// Perform the forum search
|
||||
results, err := PerformRedditSearch(query, settings.SafeSearch, page)
|
||||
var results []ForumSearchResult
|
||||
var err error
|
||||
|
||||
// Check if CrawlerEnabled is true before performing Reddit search
|
||||
if config.CrawlerEnabled {
|
||||
results, err = PerformRedditSearch(query, settings.SafeSearch, page)
|
||||
} else {
|
||||
printDebug("Crawler is disabled; skipping Reddit search.")
|
||||
results = []ForumSearchResult{}
|
||||
}
|
||||
|
||||
// Use fallback (other nodes) if no results or an error occurred
|
||||
if err != nil || len(results) == 0 {
|
||||
log.Printf("No results from primary search, trying other nodes")
|
||||
results = tryOtherNodesForForumSearch(query, settings.SafeSearch, settings.SearchLanguage, page)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue