Skip to content

Commit 5286d1e

Browse files
committed
Parse and mark main character
1 parent 1015db2 commit 5286d1e

File tree

6 files changed

+44
-35
lines changed

6 files changed

+44
-35
lines changed

doc/api/openapi.json

+4
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@
206206
"type": "string",
207207
"example": "Ninja"
208208
},
209+
"main": {
210+
"type": "boolean",
211+
"example": true
212+
},
209213
"level": {
210214
"type": "number",
211215
"example": 56

entity/Character.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package entity
22

33
type Character struct {
4-
Name string `json:"name"`
5-
Class string `json:"class"`
6-
Level int8 `json:"level,omitempty"`
7-
SpecLevels *Specs `json:"specLevels,omitempty"`
4+
Name string `json:"name"`
5+
Class string `json:"class"`
6+
Main bool `json:"main,omitempty"`
7+
Level int8 `json:"level,omitempty"`
8+
SpecLevels *Specs `json:"specLevels,omitempty"`
89
}

entity/GuildProfile.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ package entity
33
import "time"
44

55
type GuildProfile struct {
6-
Name string `json:"name"`
7-
Region string `json:"region"`
8-
Kind string `json:"kind,omitempty"`
9-
CreatedOn *time.Time `json:"createdOn,omitempty"`
10-
GuildMaster *Profile `json:"guildMaster,omitempty"`
11-
Population int16 `json:"population,omitempty"`
12-
Occupying string `json:"occupying,omitempty"`
13-
Members []Profile `json:"members,omitempty"`
6+
Name string `json:"name"`
7+
Region string `json:"region"`
8+
Kind string `json:"kind,omitempty"`
9+
CreatedOn *time.Time `json:"createdOn,omitempty"`
10+
GuildMaster *Profile `json:"guildMaster,omitempty"`
11+
Population int16 `json:"population,omitempty"`
12+
Occupying string `json:"occupying,omitempty"`
13+
Members []Profile `json:"members,omitempty"`
1414
}

entity/Profile.go

+12-12
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ package entity
33
import "time"
44

55
const (
6-
PrivateLevel = 1
7-
PrivateGuild = 2
8-
PrivateContrib = 4
9-
PrivateSpecs = 8
6+
PrivateLevel = 1
7+
PrivateGuild = 2
8+
PrivateContrib = 4
9+
PrivateSpecs = 8
1010
)
1111

1212
type Profile struct {
13-
FamilyName string `json:"familyName"`
14-
ProfileTarget string `json:"profileTarget"`
15-
Region string `json:"region"`
16-
Guild *GuildProfile `json:"guild,omitempty"`
17-
ContributionPoints int16 `json:"contributionPoints,omitempty"`
18-
CreatedOn *time.Time `json:"createdOn,omitempty"`
19-
Characters []Character `json:"characters,omitempty"`
20-
Privacy int8 `json:"privacy,omitempty"`
13+
FamilyName string `json:"familyName"`
14+
ProfileTarget string `json:"profileTarget"`
15+
Region string `json:"region"`
16+
Guild *GuildProfile `json:"guild,omitempty"`
17+
ContributionPoints int16 `json:"contributionPoints,omitempty"`
18+
CreatedOn *time.Time `json:"createdOn,omitempty"`
19+
Characters []Character `json:"characters,omitempty"`
20+
Privacy int8 `json:"privacy,omitempty"`
2121
}

entity/Specs.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package entity
22

33
type Specs struct {
4-
Gathering string `json:"gathering"`
5-
Fishing string `json:"fishing"`
6-
Hunting string `json:"hunting"`
7-
Cooking string `json:"cooking"`
8-
Alchemy string `json:"alchemy"`
9-
Processing string `json:"processing"`
10-
Training string `json:"training"`
11-
Trading string `json:"trading"`
12-
Farming string `json:"farming"`
13-
Sailing string `json:"sailing"`
14-
Barter string `json:"barter"`
4+
Gathering string `json:"gathering"`
5+
Fishing string `json:"fishing"`
6+
Hunting string `json:"hunting"`
7+
Cooking string `json:"cooking"`
8+
Alchemy string `json:"alchemy"`
9+
Processing string `json:"processing"`
10+
Training string `json:"training"`
11+
Trading string `json:"trading"`
12+
Farming string `json:"farming"`
13+
Sailing string `json:"sailing"`
14+
Barter string `json:"barter"`
1515
}

scraper/ScrapeProfile.go

+4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ func ScrapeProfile(profileTarget string) (profile entity.Profile, err error) {
6666
Class: e.ChildText(".character_info .character_symbol em:last-child"),
6767
}
6868

69+
e.ForEach(`.selected_label`, func(ind int, el *colly.HTMLElement) {
70+
character.Main = true
71+
})
72+
6973
if levelStr := e.ChildText(".character_info span:nth-child(2) em"); levelStr != "Private" {
7074
level, _ := strconv.Atoi(levelStr)
7175
character.Level = int8(level)

0 commit comments

Comments
 (0)