Skip to content

Commit c8336be

Browse files
authored
Apply fix for 24 Apr 2025 website update (#40)
1 parent 43aa089 commit c8336be

File tree

3 files changed

+19
-22
lines changed

3 files changed

+19
-22
lines changed

handlers/getStatus.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
var initTime = time.Now()
15-
var version = "1.10.3"
15+
var version = "1.10.4"
1616

1717
func getStatus(w http.ResponseWriter, r *http.Request) {
1818
json.NewEncoder(w).Encode(map[string]interface{}{

models/Profile.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@ package models
22

33
import "time"
44

5-
const (
6-
PrivateLevel = 1
7-
PrivateGuild = 2
8-
PrivateContrib = 4
9-
PrivateSpecs = 8
10-
)
11-
125
type Profile struct {
136
Characters []Character `json:"characters,omitempty"`
147
CombatFame uint32 `json:"combatFame,omitempty"`

scraper/scrapeAdventurer.go

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,49 +34,51 @@ func scrapeAdventurer(body *colly.HTMLElement, region, profileTarget string) {
3434
return false
3535
})
3636

37-
body.ForEachWithBreak(".line_list li:nth-child(1) .desc span", func(_ int, e *colly.HTMLElement) bool {
37+
body.ForEachWithBreak(".line_list li:nth-child(2) .desc span", func(_ int, e *colly.HTMLElement) bool {
3838
guildStatus := e.Text
3939

4040
if region != "EU" && region != "NA" {
4141
translators.TranslateMisc(&guildStatus)
4242
}
4343

4444
if guildStatus == "Private" {
45-
profile.Privacy = profile.Privacy | models.PrivateGuild
45+
// FIXME: This is a remains of times when privacy had granularity
46+
profile.Privacy = 15
4647
}
4748

4849
return false
4950
})
5051

51-
body.ForEachWithBreak(".line_list li:nth-child(2) .desc", func(_ int, e *colly.HTMLElement) bool {
52+
body.ForEachWithBreak(".line_list li:nth-child(1) .desc", func(_ int, e *colly.HTMLElement) bool {
5253
createdOn := utils.ParseDate(e.Text)
5354
profile.CreatedOn = &createdOn
5455
return false
5556
})
5657

57-
body.ForEachWithBreak(".line_list li:nth-child(3) .desc", func(_ int, e *colly.HTMLElement) bool {
58+
body.ForEachWithBreak(".line_list li:nth-child(5) .desc", func(_ int, e *colly.HTMLElement) bool {
5859
if contributionPoints, err := strconv.Atoi(e.Text); err == nil {
5960
profile.ContributionPoints = uint16(contributionPoints)
6061
} else {
61-
profile.Privacy = profile.Privacy | models.PrivateContrib
62+
// FIXME: This is a remains of times when privacy had granularity
63+
profile.Privacy = 15
6264
}
6365

6466
return false
6567
})
6668

67-
body.ForEachWithBreak(".character_spec:not(.lock)", func(_ int, e *colly.HTMLElement) bool {
69+
body.ForEachWithBreak(".character_spec", func(_ int, e *colly.HTMLElement) bool {
6870
specLevels := [11]string{}
6971

7072
e.ForEach(".spec_level", func(ind int, el *colly.HTMLElement) {
7173
// "Beginner1" → "Beginner 1"
72-
i := regexp.MustCompile(`[0-9]`).FindStringIndex(el.Text)[0]
73-
wordLevel := el.Text[:i]
74+
lvIndex := regexp.MustCompile("Lv ").FindStringIndex(el.Text)[0]
75+
wordLevel := el.Text[:lvIndex]
7476

7577
if region != "EU" && region != "NA" {
7678
translators.TranslateSpecLevel(&wordLevel)
7779
}
7880

79-
specLevels[ind] = wordLevel + " " + el.Text[i:]
81+
specLevels[ind] = wordLevel + el.Text[lvIndex+2:]
8082
})
8183

8284
if len(specLevels[0]) > 0 {
@@ -113,10 +115,11 @@ func scrapeAdventurer(body *colly.HTMLElement, region, profileTarget string) {
113115
return false
114116
})
115117

116-
if level, err := strconv.Atoi(e.ChildText(".character_info span:nth-child(2) em")); err == nil {
118+
if level, err := strconv.Atoi(e.ChildText(".character_info span:nth-child(2) em:not(.lock)")); err == nil {
117119
character.Level = uint8(level)
118120
} else {
119-
profile.Privacy = profile.Privacy | models.PrivateLevel
121+
// FIXME: This is a remains of times when privacy had granularity
122+
profile.Privacy = 15
120123
}
121124

122125
if name := e.ChildText(".character_name"); true {
@@ -132,12 +135,13 @@ func scrapeAdventurer(body *colly.HTMLElement, region, profileTarget string) {
132135
profile.Characters = append(profile.Characters, character)
133136
})
134137

135-
body.ForEachWithBreak(".character_spec.lock", func(_ int, _ *colly.HTMLElement) bool {
136-
profile.Privacy = profile.Privacy | models.PrivateSpecs
138+
body.ForEachWithBreak(".character_info .lock", func(_ int, _ *colly.HTMLElement) bool {
139+
// FIXME: This is a remains of times when privacy had granularity
140+
profile.Privacy = 15
137141
return false
138142
})
139143

140-
if profile.Privacy&models.PrivateLevel == 0 {
144+
if profile.Privacy == 0 {
141145
profile.CombatFame = utils.CalculateCombatFame(profile.Characters)
142146
}
143147

0 commit comments

Comments
 (0)