Skip to content

Commit baca8e6

Browse files
committed
Added description to displayed items
1 parent a7e8cb8 commit baca8e6

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed

tibiapy/bazaar.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,8 @@ class DisplayItem(abc.Serializable):
461461
The URL to the item's image.
462462
name: :class:`str`
463463
The item's name.
464+
description: :class:`str`
465+
The item's description, if any.
464466
count: :class:`int`
465467
The item's count.
466468
item_id: :class:`int`
@@ -469,13 +471,15 @@ class DisplayItem(abc.Serializable):
469471
__slots__ = (
470472
"image_url",
471473
"name",
474+
"description",
472475
"count",
473476
"item_id",
474477
)
475478

476479
def __init__(self, **kwargs):
477480
self.image_url: str = kwargs.get("image_url")
478481
self.name: str = kwargs.get("name")
482+
self.description: str = kwargs.get("description")
479483
self.count: int = kwargs.get("count", 1)
480484
self.item_id: int = kwargs.get("item_id", 0)
481485

@@ -484,21 +488,24 @@ def __repr__(self):
484488

485489
@classmethod
486490
def _parse_image_box(cls, item_box):
487-
description = item_box["title"]
491+
title_text = item_box["title"]
488492
img_tag = item_box.find("img")
489493
if not img_tag:
490494
return None
491495
amount_text = item_box.find("div", attrs={"class": "ObjectAmount"})
492496
amount = parse_tibia_money(amount_text.text) if amount_text else 1
493497
item_id = 0
494498
name = None
499+
description = None
500+
if "\n" in title_text:
501+
description = title_text.split("\n", 1)[1]
495502
m = id_regex.search(img_tag["src"])
496503
if m:
497504
item_id = int(m.group(1))
498-
m = description_regex.search(description)
505+
m = description_regex.search(title_text)
499506
if m:
500507
name = m.group(1)
501-
return DisplayItem(image_url=img_tag["src"], name=name, count=amount, item_id=item_id)
508+
return DisplayItem(image_url=img_tag["src"], name=name, count=amount, item_id=item_id, description=description)
502509

503510

504511
class DisplayMount(DisplayImage):
@@ -944,7 +951,7 @@ def from_content(cls, content, auction_id=0):
944951
Returns
945952
-------
946953
:class:`AuctionDetails`
947-
The auction detaiils if found, :obj:`None` otherwise.
954+
The auction details if found, :obj:`None` otherwise.
948955
949956
Raises
950957
------
@@ -996,6 +1003,16 @@ def from_content(cls, content, auction_id=0):
9961003

9971004
@classmethod
9981005
def _parse_tables(cls, parsed_content):
1006+
"""Parses c
1007+
1008+
Parameters
1009+
----------
1010+
parsed_content
1011+
1012+
Returns
1013+
-------
1014+
1015+
"""
9991016
details_tables = parsed_content.find_all("div", {"class": "CharacterDetailsBlock"})
10001017
return {table["id"]: table for table in details_tables}
10011018

tibiapy/enums.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,22 @@ class AuctionOrder(NumericEnum):
6060

6161
class AuctionOrderBy(NumericEnum):
6262
"""The possible values to order the auctions by."""
63-
BID = 0
63+
BID = 100
6464
"""The currently displayed bid for the auction."""
65-
END_DATE = 1
65+
END_DATE = 101
6666
"""The end date of the auction."""
67-
LEVEL = 2
67+
LEVEL = 102
6868
"""The experience level of the auctioned character."""
69-
START_DATE = 3
69+
START_DATE = 103
7070
"""The start date of the auction."""
71+
AXE_FIGHTING = 10
72+
CLUB_FIGHTING = 9
73+
DISTANCE_FIGHTING = 7
74+
FISHING = 13
75+
FIST_FIGHTING = 11
76+
MAGIC_LEVEL = 1
77+
SHIELDING = 6
78+
SWORD_FIGHTING = 8
7179

7280

7381
class AuctionStatus(BaseEnum):

0 commit comments

Comments
 (0)