diff --git a/docs/openapi.json b/docs/openapi.json index eaa161d..1a302ce 100644 --- a/docs/openapi.json +++ b/docs/openapi.json @@ -422,14 +422,17 @@ "type": "object", "properties": { "familyName": { + "nullable": false, "type": "string", "example": "Apple" }, "profileTarget": { + "nullable": false, "type": "string", "example": "XXX" }, "region": { + "nullable": false, "type": "string", "enum": [ "EU", @@ -438,31 +441,38 @@ ] }, "guild": { + "nullable": true, "properties": { "name": { + "nullable": false, "type": "string", "example": "TumblrGirls" } } }, "characters": { + "nullable": true, "type": "array", "items": { "type": "object", "properties": { "name": { + "nullable": false, "type": "string", "example": "Blue" }, "class": { + "nullable": false, "type": "string", "example": "Ninja" }, "main": { + "nullable": true, "type": "boolean", "example": true }, "level": { + "nullable": false, "type": "number", "example": 56 } diff --git a/handlers/GetStatus.go b/handlers/GetStatus.go index b431704..e3dec41 100644 --- a/handlers/GetStatus.go +++ b/handlers/GetStatus.go @@ -28,6 +28,6 @@ func GetStatus(w http.ResponseWriter, r *http.Request) { }, "proxies": len(config.GetProxyList()), "uptime": time.Since(initTime).Round(time.Second).String(), - "version": "1.8.0", + "version": "1.8.1", }) } diff --git a/scrapers/ScrapeAdventurerSearch.go b/scrapers/ScrapeAdventurerSearch.go index 03533c0..964a709 100644 --- a/scrapers/ScrapeAdventurerSearch.go +++ b/scrapers/ScrapeAdventurerSearch.go @@ -22,7 +22,6 @@ func ScrapeAdventurerSearch(region string, query string, searchType uint8, page Region: region, FamilyName: e.ChildText(".title a"), ProfileTarget: extractProfileTarget(e.ChildAttr(".title a", "href")), - Characters: make([]models.Character, 1), } if region != "SA" && region != "KR" { @@ -35,21 +34,27 @@ func ScrapeAdventurerSearch(region string, query string, searchType uint8, page } } - profile.Characters[0].Class = e.ChildText(".name") - profile.Characters[0].Name = e.ChildText(".text") + // Sometimes site displays text "You have not set your main character." + // instead of a character + if len(e.ChildText(".name")) > 0 { + profile.Characters = make([]models.Character, 1) - // Site displays the main character when searching by family name - // And the searched character when searching by character name - if searchType == 2 { - profile.Characters[0].Main = true - } + profile.Characters[0].Class = e.ChildText(".name") + profile.Characters[0].Name = e.ChildText(".text") - if region != "EU" && region != "NA" { - translators.TranslateClassName(&profile.Characters[0].Class) - } + // Site displays the main character when searching by family name + // And the searched character when searching by character name + if searchType == 2 { + profile.Characters[0].Main = true + } - if level, err := strconv.Atoi(e.ChildText(".level")[3:]); err == nil { - profile.Characters[0].Level = uint8(level) + if region != "EU" && region != "NA" { + translators.TranslateClassName(&profile.Characters[0].Class) + } + + if level, err := strconv.Atoi(e.ChildText(".level")[3:]); err == nil { + profile.Characters[0].Level = uint8(level) + } } profiles = append(profiles, profile)