Skip to content

Commit 7b43a31

Browse files
committed
Implemented TibiaData highscores parsing
- Added TibiaData test cases - Added recursive trim function for json parsing
1 parent 8540966 commit 7b43a31

File tree

13 files changed

+252
-76
lines changed

13 files changed

+252
-76
lines changed

tests/resources/highscores/tibiacom_full.txt

Lines changed: 3 additions & 7 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"highscores":{"world":"Adaaf","type":"loyalty","data":{"error":"World does not exist."}},"information":{"api_version":2,"execution_time":0.0347,"last_updated":"2019-01-08 00:29:34","timestamp":"2019-01-08 00:29:34"}}

tests/resources/highscores/tibiadata_experience.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

tests/resources/highscores/tibiadata_full.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"highscores":{"world":"Zunera","type":"loyalty","data":[{"name":"Deackoy","rank":1,"voc":"Master Sorcerer","title":"Guardian of Tibia","points":4379},{"name":"Cassiandra","rank":2,"voc":"Sorcerer","title":"Guardian of Tibia","points":4227},{"name":"Lamb of Satan","rank":3,"voc":"Master Sorcerer","title":"Guardian of Tibia","points":4128},{"name":"Little Poncho","rank":4,"voc":"Master Sorcerer","title":"Keeper of Tibia","points":3842},{"name":"Jeanzitiz ho Pater","rank":5,"voc":"Sorcerer","title":"Keeper of Tibia","points":3620},{"name":"Nimbly Bimbly","rank":6,"voc":"Master Sorcerer","title":"Keeper of Tibia","points":3466},{"name":"Flor Dliz","rank":7,"voc":"Master Sorcerer","title":"Keeper of Tibia","points":3418},{"name":"Sticky Fingerz","rank":8,"voc":"Sorcerer","title":"Keeper of Tibia","points":3211},{"name":"Sath Arco","rank":9,"voc":"Sorcerer","title":"Keeper of Tibia","points":3169},{"name":"Lady Barber","rank":10,"voc":"Master Sorcerer","title":"Keeper of Tibia","points":3144},{"name":"Deylon Weirius","rank":11,"voc":"Sorcerer","title":"Keeper of Tibia","points":3114},{"name":"Drark Alven","rank":12,"voc":"Sorcerer","title":"Keeper of Tibia","points":3100},{"name":"Runup","rank":13,"voc":"Master Sorcerer","title":"Keeper of Tibia","points":3072},{"name":"Vedabro","rank":14,"voc":"Sorcerer","title":"Keeper of Tibia","points":3038},{"name":"Edu Santi","rank":15,"voc":"Master Sorcerer","title":"Keeper of Tibia","points":3010},{"name":"Lordnasa","rank":16,"voc":"Master Sorcerer","title":"Warrior of Tibia","points":2995},{"name":"Onimusha warrior","rank":17,"voc":"Master Sorcerer","title":"Warrior of Tibia","points":2946},{"name":"Caleb Skull","rank":18,"voc":"Master Sorcerer","title":"Warrior of Tibia","points":2934},{"name":"Tholtan","rank":19,"voc":"Master Sorcerer","title":"Warrior of Tibia","points":2892},{"name":"Swiifit Kamikaze","rank":20,"voc":"Sorcerer","title":"Warrior of Tibia","points":2865},{"name":"Hamburlgar","rank":21,"voc":"Sorcerer","title":"Warrior of Tibia","points":2799},{"name":"Straight Posted","rank":22,"voc":"Sorcerer","title":"Warrior of Tibia","points":2791},{"name":"Comandante Zdos","rank":23,"voc":"Sorcerer","title":"Warrior of Tibia","points":2754},{"name":"Phal Baeliah","rank":24,"voc":"Sorcerer","title":"Warrior of Tibia","points":2735},{"name":"Tuth Babarack","rank":25,"voc":"Sorcerer","title":"Warrior of Tibia","points":2710},{"name":"Astian Chaos","rank":26,"voc":"Master Sorcerer","title":"Warrior of Tibia","points":2611},{"name":"Pinder jeet","rank":27,"voc":"Sorcerer","title":"Warrior of Tibia","points":2593},{"name":"Sizzike","rank":28,"voc":"Sorcerer","title":"Warrior of Tibia","points":2561},{"name":"Raawsz","rank":29,"voc":"Sorcerer","title":"Warrior of Tibia","points":2550},{"name":"Kull","rank":30,"voc":"Master Sorcerer","title":"Warrior of Tibia","points":2534},{"name":"Tenebrosso","rank":31,"voc":"Sorcerer","title":"Warrior of Tibia","points":2507},{"name":"Ghaleb","rank":32,"voc":"Master Sorcerer","title":"Warrior of Tibia","points":2478},{"name":"Saint Adrian","rank":33,"voc":"Master Sorcerer","title":"Warrior of Tibia","points":2468},{"name":"Pikeno Thug","rank":34,"voc":"Master Sorcerer","title":"Warrior of Tibia","points":2451},{"name":"Dralkin Juanaki","rank":35,"voc":"Master Sorcerer","title":"Warrior of Tibia","points":2407},{"name":"Captain Johnny","rank":36,"voc":"Master Sorcerer","title":"Warrior of Tibia","points":2360},{"name":"Meliissa","rank":37,"voc":"Master Sorcerer","title":"Warrior of Tibia","points":2340},{"name":"Twoopaac","rank":38,"voc":"Sorcerer","title":"Warrior of Tibia","points":2340},{"name":"Lekko Rushback","rank":39,"voc":"Master Sorcerer","title":"Warrior of Tibia","points":2322},{"name":"Mood Oribin","rank":40,"voc":"Master Sorcerer","title":"Warrior of Tibia","points":2317},{"name":"Arwyn Carigos","rank":41,"voc":"Sorcerer","title":"Warrior of Tibia","points":2310},{"name":"Killer Kael","rank":42,"voc":"Master Sorcerer","title":"Warrior of Tibia","points":2289},{"name":"Famous Dedd","rank":43,"voc":"Sorcerer","title":"Warrior of Tibia","points":2287},{"name":"Wet willies","rank":44,"voc":"Master Sorcerer","title":"Warrior of Tibia","points":2280},{"name":"Nidope","rank":45,"voc":"Sorcerer","title":"Warrior of Tibia","points":2243},{"name":"Flip Nitro","rank":46,"voc":"Master Sorcerer","title":"Warrior of Tibia","points":2229},{"name":"Yurixx","rank":47,"voc":"Sorcerer","title":"Warrior of Tibia","points":2204},{"name":"Ed Hardly","rank":48,"voc":"Sorcerer","title":"Warrior of Tibia","points":2202},{"name":"Texxa","rank":49,"voc":"Master Sorcerer","title":"Warrior of Tibia","points":2191},{"name":"Shine spellcaster","rank":50,"voc":"Sorcerer","title":"Warrior of Tibia","points":2174},{"name":"Vdoviec","rank":51,"voc":"Sorcerer","title":"Warrior of Tibia","points":2168},{"name":"Zethes","rank":52,"voc":"Sorcerer","title":"Warrior of Tibia","points":2130},{"name":"Flaxmaids","rank":53,"voc":"Sorcerer","title":"Warrior of Tibia","points":2129},{"name":"Ashiw Reidelas","rank":54,"voc":"Sorcerer","title":"Warrior of Tibia","points":2123},{"name":"Sweeth Queen","rank":55,"voc":"Sorcerer","title":"Warrior of Tibia","points":2120},{"name":"Durysh Headshot","rank":56,"voc":"Master Sorcerer","title":"Warrior of Tibia","points":2110},{"name":"Chatoh The Ripper","rank":57,"voc":"Master Sorcerer","title":"Warrior of Tibia","points":2085}]},"information":{"api_version":2,"execution_time":0.0023,"last_updated":"2019-01-07 23:53:53","timestamp":"2019-01-07 23:54:18"}}

tests/tests_highscores.py

Lines changed: 87 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1+
import tests.tests_character
12
from tests.tests_tibiapy import TestTibiaPy
2-
from tibiapy import Category, ExpHighscoresEntry, Highscores, HighscoresEntry, LoyaltyHighscoresEntry, Vocation, \
3-
VocationFilter
3+
from tibiapy import Category, ExpHighscoresEntry, Highscores, HighscoresEntry, InvalidContent, LoyaltyHighscoresEntry, \
4+
Vocation, VocationFilter
45

56
FILE_HIGHSCORES_FULL = "highscores/tibiacom_full.txt"
67
FILE_HIGHSCORES_EXPERIENCE = "highscores/tibiacom_experience.txt"
78
FILE_HIGHSCORES_LOYALTY = "highscores/tibiacom_loyalty.txt"
89
FILE_HIGHSCORES_EMPTY = "highscores/tibiacom_empty.txt"
910

11+
FILE_HIGHSCORES_TIBIADATA_FULL = "highscores/tibiadata_full.json"
12+
FILE_HIGHSCORES_TIBIADATA_EXPERIENCE = "highscores/tibiadata_experience.json"
13+
FILE_HIGHSCORES_TIBIADATA_LOYALTY = "highscores/tibiadata_loyalty.json"
14+
FILE_HIGHSCORES_TIBIADATA_EMPTY = "highscores/tibiadata_empty.json"
15+
1016

1117
class TestHighscores(TestTibiaPy):
1218
# region Tibia.com Tests
@@ -18,6 +24,11 @@ def testHighscores(self):
1824
self.assertEqual(highscores.vocation, VocationFilter.KNIGHTS)
1925
self.assertEqual(highscores.category, Category.MAGIC_LEVEL)
2026
self.assertEqual(highscores.results_count, 300)
27+
self.assertEqual(highscores.from_rank, 76)
28+
self.assertEqual(highscores.to_rank, 100)
29+
self.assertEqual(highscores.page, 4)
30+
self.assertEqual(highscores.total_pages, 12)
31+
self.assertIsNotNone(highscores.url)
2132

2233
for entry in highscores.entries:
2334
self.assertIsInstance(entry, HighscoresEntry)
@@ -34,6 +45,7 @@ def testHighscoresExperience(self):
3445
self.assertEqual(highscores.vocation, VocationFilter.PALADINS)
3546
self.assertEqual(highscores.category, Category.EXPERIENCE)
3647
self.assertEqual(highscores.results_count, 300)
48+
self.assertEqual(highscores.total_pages, 12)
3749

3850
for entry in highscores.entries:
3951
self.assertIsInstance(entry, ExpHighscoresEntry)
@@ -51,6 +63,7 @@ def testHighscoresLoyalty(self):
5163
self.assertEqual(highscores.vocation, VocationFilter.PALADINS)
5264
self.assertEqual(highscores.category, Category.LOYALTY_POINTS)
5365
self.assertEqual(highscores.results_count, 65)
66+
self.assertEqual(highscores.total_pages, 3)
5467

5568
for entry in highscores.entries:
5669
self.assertIsInstance(entry, LoyaltyHighscoresEntry)
@@ -66,4 +79,76 @@ def testHighscoresEmpty(self):
6679

6780
self.assertIsNone(highscores)
6881

82+
def testHighscoresTibiaDataListUnrelated(self):
83+
with self.assertRaises(InvalidContent):
84+
Highscores.from_tibiadata(self._load_resource(tests.tests_character.FILE_CHARACTER_TIBIADATA))
85+
86+
def testHighscoresUnrelated(self):
87+
content = self._load_resource(self.FILE_UNRELATED_SECTION)
88+
with self.assertRaises(InvalidContent):
89+
Highscores.from_content(content)
90+
91+
# endregion
92+
93+
# region TibiaData.com Tests
94+
def testHighscoresTibiaData(self):
95+
content = self._load_resource(FILE_HIGHSCORES_TIBIADATA_FULL)
96+
highscores = Highscores.from_tibiadata(content)
97+
98+
self.assertEqual(highscores.world, "Antica")
99+
self.assertEqual(highscores.vocation, VocationFilter.ALL)
100+
self.assertEqual(highscores.category, Category.AXE_FIGHTING)
101+
self.assertEqual(highscores.results_count, 300)
102+
103+
for entry in highscores.entries:
104+
self.assertIsInstance(entry, HighscoresEntry)
105+
self.assertIsInstance(entry.name, str)
106+
self.assertIsInstance(entry.vocation, Vocation)
107+
self.assertIsInstance(entry.rank, int)
108+
self.assertIsInstance(entry.value, int)
109+
110+
def testHighscoresTibiaDataExperience(self):
111+
content = self._load_resource(FILE_HIGHSCORES_TIBIADATA_EXPERIENCE)
112+
highscores = Highscores.from_tibiadata(content)
113+
114+
self.assertEqual(highscores.world, "Luminera")
115+
self.assertEqual(highscores.vocation, VocationFilter.ALL)
116+
self.assertEqual(highscores.category, Category.EXPERIENCE)
117+
self.assertEqual(highscores.results_count, 300)
118+
119+
for entry in highscores.entries:
120+
self.assertIsInstance(entry, ExpHighscoresEntry)
121+
self.assertIsInstance(entry.name, str)
122+
self.assertIsInstance(entry.vocation, Vocation)
123+
self.assertIsInstance(entry.rank, int)
124+
self.assertIsInstance(entry.value, int)
125+
self.assertIsInstance(entry.level, int)
126+
127+
def testHighscoresTibiaDataLoyalty(self):
128+
content = self._load_resource(FILE_HIGHSCORES_TIBIADATA_LOYALTY)
129+
highscores = Highscores.from_tibiadata(content)
130+
131+
self.assertEqual(highscores.world, "Zunera")
132+
self.assertEqual(highscores.vocation, VocationFilter.ALL)
133+
self.assertEqual(highscores.category, Category.LOYALTY_POINTS)
134+
self.assertEqual(highscores.results_count, 57)
135+
136+
for entry in highscores.entries:
137+
self.assertIsInstance(entry, LoyaltyHighscoresEntry)
138+
self.assertIsInstance(entry.name, str)
139+
self.assertIsInstance(entry.vocation, Vocation)
140+
self.assertIsInstance(entry.rank, int)
141+
self.assertIsInstance(entry.value, int)
142+
self.assertIsInstance(entry.title, str)
143+
144+
def testHighscoresTibaDataEmpty(self):
145+
content = self._load_resource(FILE_HIGHSCORES_TIBIADATA_EMPTY)
146+
highscores = Highscores.from_tibiadata(content)
147+
148+
self.assertIsNone(highscores)
149+
150+
def testHighscoresTibiaDataListUnrelated(self):
151+
with self.assertRaises(InvalidContent):
152+
Highscores.from_tibiadata(self._load_resource(tests.tests_character.FILE_CHARACTER_TIBIADATA))
153+
69154
# endregion

tests/tests_house.py

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,8 @@ class TestsHouse(TestTibiaPy):
2626
def setUp(self):
2727
self.guild = {}
2828

29-
@staticmethod
30-
def _get_resource(resource):
31-
return TestTibiaPy._load_resource(resource)
32-
3329
def testHouse(self):
34-
content = self._get_resource(FILE_HOUSE_FULL)
30+
content = self._load_resource(FILE_HOUSE_FULL)
3531
house = House.from_content(content)
3632

3733
self.assertIsInstance(house, House)
@@ -53,7 +49,7 @@ def testHouse(self):
5349

5450
def testHouseStatusTransferred(self):
5551
house = House("Name")
56-
content = self._get_resource(FILE_HOUSE_STATUS_TRANSFER)
52+
content = self._load_resource(FILE_HOUSE_STATUS_TRANSFER)
5753
house._parse_status(content)
5854
self.assertEqual(house.status, HouseStatus.RENTED)
5955
self.assertEqual(house.owner, "Xenaris mag")
@@ -64,15 +60,15 @@ def testHouseStatusTransferred(self):
6460

6561
def testHouseStatusRented(self):
6662
house = House("Name")
67-
content = self._get_resource(FILE_HOUSE_STATUS_RENTED)
63+
content = self._load_resource(FILE_HOUSE_STATUS_RENTED)
6864
house._parse_status(content)
6965
self.assertEqual(house.status, HouseStatus.RENTED)
7066
self.assertEqual(house.owner, "Thorcen")
7167
self.assertIsInstance(house.paid_until, datetime.datetime)
7268

7369
def testHouseStatusWithBids(self):
7470
house = House("Name")
75-
content = self._get_resource(FILE_HOUSE_STATUS_WITH_BIDS)
71+
content = self._load_resource(FILE_HOUSE_STATUS_WITH_BIDS)
7672
house._parse_status(content)
7773
self.assertEqual(house.status, HouseStatus.AUCTIONED)
7874
self.assertIsNone(house.owner)
@@ -82,24 +78,24 @@ def testHouseStatusWithBids(self):
8278

8379
def testHouseStatusWithoutBids(self):
8480
house = House("Name")
85-
content = self._get_resource(FILE_HOUSE_STATUS_NO_BIDS)
81+
content = self._load_resource(FILE_HOUSE_STATUS_NO_BIDS)
8682
house._parse_status(content)
8783
self.assertEqual(house.status, HouseStatus.AUCTIONED)
8884
self.assertIsNone(house.auction_end)
8985

9086
def testHouseNotFound(self):
91-
content = self._get_resource(FILE_HOUSE_NOT_FOUND)
87+
content = self._load_resource(FILE_HOUSE_NOT_FOUND)
9288
house = House.from_content(content)
9389

9490
self.assertIsNone(house)
9591

9692
def testHouseUnrelated(self):
97-
content = self._get_resource(self.FILE_UNRELATED_SECTION)
93+
content = self._load_resource(self.FILE_UNRELATED_SECTION)
9894
with self.assertRaises(InvalidContent):
9995
House.from_content(content)
10096

10197
def testHouseList(self):
102-
content = self._get_resource(FILE_HOUSE_LIST)
98+
content = self._load_resource(FILE_HOUSE_LIST)
10399
houses = ListedHouse.list_from_content(content)
104100

105101
self.assertIsInstance(houses, list)
@@ -115,24 +111,24 @@ def testHouseList(self):
115111
self.assertEqual(houses[25].highest_bid, 7500000)
116112

117113
def testHouseListEmpty(self):
118-
content = self._get_resource(FILE_HOUSE_LIST_EMPTY)
114+
content = self._load_resource(FILE_HOUSE_LIST_EMPTY)
119115
houses = ListedHouse.list_from_content(content)
120116

121117
self.assertEqual(len(houses), 0)
122118

123119
def testHouseListNotFound(self):
124-
content = self._get_resource(FILE_HOUSE_NOT_FOUND)
120+
content = self._load_resource(FILE_HOUSE_NOT_FOUND)
125121
houses = ListedHouse.list_from_content(content)
126122

127123
self.assertIsNone(houses)
128124

129125
def testHouseListUnrelated(self):
130-
content = self._get_resource(self.FILE_UNRELATED_SECTION)
126+
content = self._load_resource(self.FILE_UNRELATED_SECTION)
131127
with self.assertRaises(InvalidContent):
132128
ListedHouse.list_from_content(content)
133129

134130
def testHouseTibiaData(self):
135-
content = self._get_resource(FILE_HOUSE_TIBIADATA)
131+
content = self._load_resource(FILE_HOUSE_TIBIADATA)
136132
house = House.from_tibiadata(content)
137133

138134
self.assertIsInstance(house, House)
@@ -144,7 +140,7 @@ def testHouseTibiaData(self):
144140
self.assertIsNone(house.owner)
145141

146142
def testHouseTibiaDataNotFound(self):
147-
content = self._get_resource(FILE_HOUSE_TIBIADATA_NOT_FOUND)
143+
content = self._load_resource(FILE_HOUSE_TIBIADATA_NOT_FOUND)
148144
house = House.from_tibiadata(content)
149145

150146
self.assertIsNone(house)
@@ -154,12 +150,12 @@ def testHouseTibiaDataInvalid(self):
154150
House.from_tibiadata("<p>Not json</p>")
155151

156152
def testGuildTibiaDataUnrelated(self):
157-
content = self._get_resource(tests.tests_character.FILE_CHARACTER_TIBIADATA)
153+
content = self._load_resource(tests.tests_character.FILE_CHARACTER_TIBIADATA)
158154
with self.assertRaises(InvalidContent):
159155
House.from_tibiadata(content)
160156

161157
def testHouseTibiaDataList(self):
162-
content = self._get_resource(FILE_HOUSE_TIBIADATA_LIST)
158+
content = self._load_resource(FILE_HOUSE_TIBIADATA_LIST)
163159
houses = ListedHouse.list_from_tibiadata(content)
164160

165161
self.assertIsInstance(houses, list)
@@ -172,7 +168,7 @@ def testHouseTibiaDataList(self):
172168
self.assertIsNotNone(ListedHouse.get_list_url_tibiadata(houses[0].world, houses[0].town))
173169

174170
def testHouseTibiaDataListNotFound(self):
175-
content = self._get_resource(FILE_HOUSE_TIBIADATA_LIST_NOT_FOUND)
171+
content = self._load_resource(FILE_HOUSE_TIBIADATA_LIST_NOT_FOUND)
176172
houses = ListedHouse.list_from_tibiadata(content)
177173

178174
self.assertIsInstance(houses, list)
@@ -184,4 +180,4 @@ def testHouseTibiaDataListInvalidJson(self):
184180

185181
def testHouseTibiaDataListUnrelated(self):
186182
with self.assertRaises(InvalidContent):
187-
ListedHouse.list_from_tibiadata(self._get_resource(tests.tests_character.FILE_CHARACTER_TIBIADATA))
183+
ListedHouse.list_from_tibiadata(self._load_resource(tests.tests_character.FILE_CHARACTER_TIBIADATA))

tibiapy/character.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import datetime
2-
import json
32
import re
43
import urllib.parse
54
from collections import OrderedDict
@@ -12,8 +11,8 @@
1211
from tibiapy.errors import InvalidContent
1312
from tibiapy.guild import Guild
1413
from tibiapy.house import CharacterHouse
15-
from tibiapy.utils import parse_tibia_date, parse_tibia_datetime, parse_tibiacom_content, parse_tibiadata_date, \
16-
parse_tibiadata_datetime, try_datetime, try_enum
14+
from tibiapy.utils import parse_json, parse_tibia_date, parse_tibia_datetime, parse_tibiacom_content, \
15+
parse_tibiadata_date, parse_tibiadata_datetime, try_datetime, try_enum
1716

1817
deleted_regexp = re.compile(r'([^,]+), will be deleted at (.*)')
1918
# Extracts the death's level and killers.
@@ -238,10 +237,7 @@ def from_tibiadata(cls, content):
238237
------
239238
InvalidContent
240239
If content is not a JSON string of the Character response."""
241-
try:
242-
json_content = json.loads(content)
243-
except json.JSONDecodeError:
244-
raise InvalidContent("content is not a valid json string.")
240+
json_content = parse_json(content)
245241
char = cls()
246242
try:
247243
character = json_content["characters"]

tibiapy/guild.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import datetime
2-
import json
32
import re
43
import urllib.parse
54
from collections import OrderedDict
@@ -11,8 +10,8 @@
1110
from tibiapy.enums import Vocation
1211
from tibiapy.errors import InvalidContent
1312
from tibiapy.house import GuildHouse
14-
from tibiapy.utils import parse_tibia_date, parse_tibiacom_content, parse_tibiadata_date, try_date, try_datetime, \
15-
try_enum
13+
from tibiapy.utils import parse_json, parse_tibia_date, parse_tibiacom_content, parse_tibiadata_date, try_date, \
14+
try_datetime, try_enum
1615

1716
__all__ = ("Guild", "GuildMember", "GuildInvite", "ListedGuild")
1817

@@ -173,11 +172,7 @@ def from_tibiadata(cls, content):
173172
InvalidContent
174173
If content is not a JSON response of a guild's page.
175174
"""
176-
try:
177-
json_content = json.loads(content)
178-
except json.JSONDecodeError:
179-
raise InvalidContent("content is not a json string.")
180-
175+
json_content = parse_json(content)
181176
guild = cls()
182177
try:
183178
guild_obj = json_content["guild"]
@@ -543,10 +538,7 @@ def list_from_tibiadata(cls, content):
543538
InvalidContent
544539
If content is not a JSON response of TibiaData's guild list.
545540
"""
546-
try:
547-
json_content = json.loads(content)
548-
except json.JSONDecodeError:
549-
raise InvalidContent("content is not a valid json string.")
541+
json_content = parse_json(content)
550542
try:
551543
guilds_obj = json_content["guilds"]
552544
guilds = []

0 commit comments

Comments
 (0)