enrichment

This commit is contained in:
Tour
2025-12-07 02:20:14 +01:00
parent 08bf112c3f
commit 765361d582
9 changed files with 1096 additions and 5 deletions

View File

@@ -109,7 +109,8 @@ class DataParser:
page_props = data.get('props', {}).get('pageProps', {})
if 'lot' in page_props:
return self._parse_lot_json(page_props.get('lot', {}), url)
# Pass both lot and auction data (auction is included in lot pages)
return self._parse_lot_json(page_props.get('lot', {}), url, page_props.get('auction'))
if 'auction' in page_props:
return self._parse_auction_json(page_props.get('auction', {}), url)
return None
@@ -118,8 +119,14 @@ class DataParser:
print(f" → Error parsing __NEXT_DATA__: {e}")
return None
def _parse_lot_json(self, lot_data: Dict, url: str) -> Dict:
"""Parse lot data from JSON"""
def _parse_lot_json(self, lot_data: Dict, url: str, auction_data: Optional[Dict] = None) -> Dict:
"""Parse lot data from JSON
Args:
lot_data: Lot object from __NEXT_DATA__
url: Page URL
auction_data: Optional auction object (included in lot pages)
"""
location_data = lot_data.get('location', {})
city = location_data.get('city', '')
country = location_data.get('countryCode', '').upper()
@@ -145,10 +152,16 @@ class DataParser:
category = lot_data.get('category', {})
category_name = category.get('name', '') if isinstance(category, dict) else ''
# Get auction displayId from auction data if available (lot pages include auction)
# Otherwise fall back to the UUID auctionId
auction_id = lot_data.get('auctionId', '')
if auction_data and auction_data.get('displayId'):
auction_id = auction_data.get('displayId')
return {
'type': 'lot',
'lot_id': lot_data.get('displayId', ''),
'auction_id': lot_data.get('auctionId', ''),
'auction_id': auction_id,
'url': url,
'title': lot_data.get('title', ''),
'current_bid': current_bid_str,