Skip to content

Commit 8068427

Browse files
committed
Parse item tier in displayed items
1 parent 6a9345a commit 8068427

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tibiapy/bazaar.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
id_regex = re.compile(r'(\d+).(?:gif|png)')
4343
description_regex = re.compile(r'"(?:an?\s)?([^"]+)"')
4444
amount_regex = re.compile(r'([\d,]+)x')
45+
tier_regex = re.compile(r"(.*)\s\(tier (\d)\)")
4546

4647
log = logging.getLogger("tibiapy")
4748

@@ -500,10 +501,16 @@ def _parse_image_box(cls, item_box):
500501
name, *desc = title_text.split("\n")
501502
if desc:
502503
description = " ".join(desc)
504+
tier = 0
505+
m = tier_regex.search(name)
506+
if m:
507+
tier = int(m.group(2))
508+
name = m.group(1)
503509
m = id_regex.search(img_tag["src"])
504510
if m:
505511
item_id = int(m.group(1))
506-
return DisplayItem(image_url=img_tag["src"], name=name, count=amount, item_id=item_id, description=description)
512+
return DisplayItem(image_url=img_tag["src"], name=name, count=amount, item_id=item_id, description=description,
513+
tier=tier)
507514

508515

509516
class DisplayMount(DisplayImage):

0 commit comments

Comments
 (0)