Skip to content

Commit a181332

Browse files
authored
Add KR support (#42)
1 parent fdbe26e commit a181332

File tree

10 files changed

+33
-15
lines changed

10 files changed

+33
-15
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# BDO-REST-API
2-
Scraper for Black Desert Online community data with a built-in API server. It currently supports EU, NA, and SA regions (KR support is in development).
2+
Scraper for Black Desert Online community data with a built-in API server. It currently supports EU, NA, SA and KR regions.
33

44
## Projects using this API
55
- BDO Leaderboards ([Website](https://bdo.hemlo.cc/leaderboards), [sources](https://github.com/man90es/BDO-Leaderboards)): web-based leaderboards for Black Desert Online.
66
- Ikusa ([Website](https://ikusa.site), [sources](https://github.com/sch-28/ikusa_api)): powerful tool that allows you to analyze your game logs and gain valuable insights into your combat performance.
77
- GuildYapper ([Discord server](https://discord.gg/x2nKYuu2Z2)): Discord bot with various features for BDO guilds such as guild and player history logging, and automatic trial Discord management (more features TBA).
88
- BDO Guild Bosses - Alliance [EU] ([Discord server](https://discord.gg/735bYrQWKr)): Discord bot for organising events in a guild bosses alliance.
9-
- Cute Papus! ([Website](https://cutepap.us/)): A collection of various BDO-related tools in a single web app.
9+
- Cute Papus! ([Website](https://cutepap.us/)): A collection of various BDO-related tools in a single web app.
1010

1111
## How to start using it
1212
There are two ways to use this scraper for your needs:

docs/openapi.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
"region": {
1818
"name": "region",
1919
"in": "query",
20-
"description": "Only Eropean, North American and South American servers are supported. If you omit this parameter, it's assumed that you want to search on the European server.",
2120
"schema": {
2221
"type": "string",
2322
"enum": [
2423
"EU",
24+
"KR",
2525
"NA",
2626
"SA"
2727
],
@@ -69,7 +69,9 @@
6969
"lastDetectedMaintenance": {
7070
"type": "object",
7171
"example": {
72-
"EUNA": "0001-01-01T00:00:00Z",
72+
"EU": "0001-01-01T00:00:00Z",
73+
"KR": "0001-01-01T00:00:00Z",
74+
"NA": "0001-01-01T00:00:00Z",
7375
"SA": "0001-01-01T00:00:00Z"
7476
}
7577
},
@@ -163,11 +165,12 @@
163165
{
164166
"name": "region",
165167
"in": "query",
166-
"description": "Player's region. Can be omitted for EU or NA.",
168+
"description": "Can be omitted for EU or NA. Providing NA as the value can return EU profiles and vice versa.",
167169
"schema": {
168170
"type": "string",
169171
"enum": [
170172
"EU",
173+
"KR",
171174
"NA",
172175
"SA"
173176
],
@@ -199,6 +202,7 @@
199202
"type": "string",
200203
"enum": [
201204
"EU",
205+
"KR",
202206
"NA",
203207
"SA"
204208
]
@@ -542,6 +546,7 @@
542546
"type": "string",
543547
"enum": [
544548
"EU",
549+
"KR",
545550
"NA",
546551
"SA"
547552
]
@@ -648,6 +653,7 @@
648653
"type": "string",
649654
"enum": [
650655
"EU",
656+
"KR",
651657
"NA",
652658
"SA"
653659
]
@@ -757,6 +763,7 @@
757763
"type": "string",
758764
"enum": [
759765
"EU",
766+
"KR",
760767
"NA",
761768
"SA"
762769
]
@@ -836,6 +843,7 @@
836843
"type": "string",
837844
"enum": [
838845
"EU",
846+
"KR",
839847
"NA",
840848
"SA"
841849
]
@@ -858,6 +866,7 @@
858866
"type": "string",
859867
"enum": [
860868
"EU",
869+
"KR",
861870
"NA",
862871
"SA"
863872
]
@@ -888,6 +897,7 @@
888897
"type": "string",
889898
"enum": [
890899
"EU",
900+
"KR",
891901
"NA",
892902
"SA"
893903
]
@@ -910,6 +920,7 @@
910920
"type": "string",
911921
"enum": [
912922
"EU",
923+
"KR",
913924
"NA",
914925
"SA"
915926
]

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.4"
15+
var version = "1.11.0"
1616

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

scraper/GetCloseTime.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
var lastCloseTimes = map[string]time.Time{
1010
"EUNA": {},
11+
"KR": {},
1112
"SA": {},
1213
}
1314

@@ -31,5 +32,10 @@ func setCloseTime(region string) {
3132
}
3233

3334
func GetLastCloseTimes() map[string]time.Time {
34-
return lastCloseTimes
35+
return map[string]time.Time{
36+
"EU": lastCloseTimes["EUNA"],
37+
"KR": lastCloseTimes["KR"],
38+
"NA": lastCloseTimes["EUNA"],
39+
"SA": lastCloseTimes["SA"],
40+
}
3541
}

scraper/scrapeAdventurer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func scrapeAdventurer(body *colly.HTMLElement, region, profileTarget string) {
1818
status := http.StatusNotFound
1919
profile := models.Profile{
2020
ProfileTarget: profileTarget,
21-
Region: region,
21+
Region: region, // FIXME: This can potentially be wrong e.g. if client requests a NA profile and gives EU as the region
2222
}
2323

2424
body.ForEachWithBreak(".nick", func(_ int, e *colly.HTMLElement) bool {

scraper/scrapeGuildSearch.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ func scrapeGuildSearch(body *colly.HTMLElement, region, query string) {
2929
CreatedOn: &createdOn,
3030
}
3131

32-
if region != "SA" && region != "KR" {
33-
guildProfile.Region = e.ChildText(".region_info")
34-
}
35-
3632
if membersStr := e.ChildText(".member"); true {
3733
population, _ := strconv.Atoi(membersStr)
3834
guildProfile.Population = uint8(population)

translators/TranslateClassName.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var classNameTranslationMap = map[string]string{
3030
"노바": "Nova",
3131
"닌자": "Ninja",
3232
"다크나이트": "Dark Knight",
33+
"데드아이": "Deadeye",
3334
"도사": "Dosa",
3435
"드라카니아": "Drakania",
3536
"란": "Lahn",

translators/TranslateSpecLevel.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ var specLevelTranslationMap = map[string]string{
1111
"Profissional": "Professional",
1212
"견습": "Apprentice",
1313
"숙련": "Skilled",
14+
"장인": "Artisan",
15+
"전문": "Professional",
1416
"초급": "Beginner",
17+
"명장": "Master",
18+
"도인": "Guru",
1519
}
1620

1721
func TranslateSpecLevel(specLevel *string) {

validators/ValidateRegionQueryParam.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func ValidateRegionQueryParam(query []string) (region string, ok bool, errorMess
1414
region = strings.ToUpper(query[0])
1515

1616
// TODO: Add KR region once the translations are ready
17-
if !slices.Contains([]string{"EU", "NA", "SA"}, region) {
17+
if !slices.Contains([]string{"EU", "NA", "SA", "KR"}, region) {
1818
return region, false, fmt.Sprintf("Region %v is not supported", region)
1919
}
2020

validators/ValidateRegionQueryParam_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ func TestValidateRegionQueryParameter(t *testing.T) {
1616
{input: []string{"na"}, expectedRegion: "NA", expectedOk: true, expectedMessage: ""},
1717
{input: []string{"SA"}, expectedRegion: "SA", expectedOk: true, expectedMessage: ""},
1818
{input: []string{"EU"}, expectedRegion: "EU", expectedOk: true, expectedMessage: ""},
19-
{input: []string{"KR"}, expectedRegion: "KR", expectedOk: false, expectedMessage: "Region KR is not supported"},
20-
{input: []string{"NA", "SA"}, expectedRegion: "NA", expectedOk: true, expectedMessage: ""}, // Takes the first region in case of multiple regions
19+
{input: []string{"ABC"}, expectedRegion: "ABC", expectedOk: false, expectedMessage: "Region ABC is not supported"},
20+
{input: []string{"KR", "SA"}, expectedRegion: "KR", expectedOk: true, expectedMessage: ""}, // Takes the first region in case of multiple regions
2121
}
2222

2323
for _, test := range tests {

0 commit comments

Comments
 (0)