Skip to content

Commit 04b8f7d

Browse files
committed
Fixed bug with extraneous character in some item descriptions, causing auction to give a parsing error.
1 parent a6c70d3 commit 04b8f7d

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ Changelog
66
Due to this library relying on external content, older versions are not guaranteed to work.
77
Try to always use the latest version.
88

9+
.. v4.1.1
10+
11+
4.1.1 (2021-04-19)
12+
==================
13+
- Fixed bug with extraneous character in some item descriptions, causing auction to give a parsing error.
14+
915
.. v4.1.0
1016
1117
4.1.0 (2021-03-30)

tibiapy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '4.1.0'
1+
__version__ = '4.1.1'
22
__author__ = 'Allan Galarza'
33

44
import logging

tibiapy/bazaar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ def _parse_image_box(cls, item_box):
524524
description = None
525525
name, *desc = title_text.split("\n")
526526
if desc:
527-
description = desc[0]
527+
description = " ".join(desc)
528528
m = id_regex.search(img_tag["src"])
529529
if m:
530530
item_id = int(m.group(1))

tibiapy/client.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,9 @@ async def _fetch_all_pages(self, auction_id, paginator, item_type):
343343
current_page = 2
344344
while current_page <= paginator.total_pages:
345345
content = await self._fetch_ajax_page(auction_id, item_type, current_page)
346-
entries = AuctionDetails._parse_page_items(content, paginator.entry_class)
347-
paginator.entries.extend(entries)
346+
if content:
347+
entries = AuctionDetails._parse_page_items(content, paginator.entry_class)
348+
paginator.entries.extend(entries)
348349
current_page += 1
349350
paginator.fully_fetched = True
350351

@@ -371,7 +372,10 @@ async def _fetch_ajax_page(self, auction_id, type_id, page):
371372
f"type={type_id}&"
372373
f"currentpage={page}",
373374
headers=headers)
374-
data = json.loads(page_response.content)
375+
try:
376+
data = json.loads(page_response.content.replace("\x0a", " "))
377+
except json.decoder.JSONDecodeError:
378+
return None
375379
try:
376380
return data['AjaxObjects'][0]['Data']
377381
except KeyError:

0 commit comments

Comments
 (0)