Skip to content

Commit

Permalink
Fix scrapes, better error logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
Distortions81 committed Mar 27, 2024
1 parent 14403a5 commit c6e5a06
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions update.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ func fetchBanLists() {

data, err := fetchFile(server.BanListURL)
if err != nil {
log.Println("Error updating ban list: " + err.Error())
log.Printf("Error updating ban list: %v: %v: %v\n", server.CommunityName, server.BanListURL, err.Error())
continue
}
if len(data) > 0 {

var names []string
if strings.EqualFold(server.CommunityName, "RedMew") {
if server.UseRedScrape {
count := 0
var redMewNames []string
if server.UseRedScrape {
if serverConfig.ServerPrefs.VerboseLogging {
log.Println("Scraping RedMew.")
}
redMewNames = GetRedMew(server.BanListURL)
redMewNames = GetRedMew(data)
}

if redMewNames != nil {
Expand All @@ -53,29 +53,30 @@ func fetchBanLists() {
if serverConfig.ServerPrefs.VerboseLogging {
log.Printf("Redmew: %v names scraped.\n", count)
}
} else if strings.EqualFold(server.CommunityName, "Comfy") {
count := 0
var comfyNames []string
if server.UseComfyScrape {
if serverConfig.ServerPrefs.VerboseLogging {
log.Println("Scraping Comfy.")
}
comfyNames = GetComfy(server.BanListURL)
}
} else if server.UseComfyScrape {
count := 0
var comfyNames []string
if server.UseComfyScrape {
if serverConfig.ServerPrefs.VerboseLogging {
log.Println("Scraping Comfy.")
}
comfyNames = GetComfy(data)
}

if comfyNames != nil {
for _, comfy := range comfyNames {
rLen := len(comfy)
if rLen > 0 && rLen < 128 {
names = append(names, strings.ToLower(comfy))
count++
}
}
if serverConfig.ServerPrefs.VerboseLogging {
log.Printf("Comfy: %v names scraped.\n", count)
if comfyNames != nil {
for _, comfy := range comfyNames {
rLen := len(comfy)
if rLen > 0 && rLen < 128 {
names = append(names, strings.ToLower(comfy))
count++
}
}
if serverConfig.ServerPrefs.VerboseLogging {
log.Printf("Comfy: %v names scraped.\n", count)
}
}

} else {
err = json.Unmarshal(data, &names)
}
Expand Down

0 comments on commit c6e5a06

Please sign in to comment.