"""Check how lots link to auctions""" import sys import os sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src')) from cache import CacheManager import sqlite3 import zlib import json import re cache = CacheManager() conn = sqlite3.connect(cache.db_path) cursor = conn.cursor() # Get a lot page from cache cursor.execute("SELECT url, content FROM cache WHERE url LIKE '%/l/%' LIMIT 1") url, content_blob = cursor.fetchone() content = zlib.decompress(content_blob).decode('utf-8') # Extract __NEXT_DATA__ match = re.search(r']*id="__NEXT_DATA__"[^>]*>(.+?)', content, re.DOTALL) data = json.loads(match.group(1)) props = data.get('props', {}).get('pageProps', {}) print("PageProps keys:", list(props.keys())) lot = props.get('lot', {}) print("\nLot data:") print(f" displayId: {lot.get('displayId')}") print(f" auctionId (UUID): {lot.get('auctionId')}") # Check if auction data is also included auction = props.get('auction') if auction: print("\nAuction data IS included in lot page!") print(f" Auction displayId: {auction.get('displayId')}") print(f" Auction id (UUID): {auction.get('id')}") print(f" Auction name: {auction.get('name', '')[:60]}") else: print("\nAuction data NOT included in lot page") print("Need to look up auction by UUID") # Check if we can find the auction by UUID lot_auction_uuid = lot.get('auctionId') if lot_auction_uuid: # Try to find auction page with this UUID cursor.execute(""" SELECT url, content FROM cache WHERE url LIKE '%/a/%' LIMIT 10 """) found_match = False for auction_url, auction_content_blob in cursor.fetchall(): auction_content = zlib.decompress(auction_content_blob).decode('utf-8') match = re.search(r']*id="__NEXT_DATA__"[^>]*>(.+?)', auction_content, re.DOTALL) if match: auction_data = json.loads(match.group(1)) auction_obj = auction_data.get('props', {}).get('pageProps', {}).get('auction', {}) if auction_obj.get('id') == lot_auction_uuid: print(f"\n✓ Found matching auction!") print(f" Auction displayId: {auction_obj.get('displayId')}") print(f" Auction UUID: {auction_obj.get('id')}") print(f" Auction URL: {auction_url}") found_match = True break if not found_match: print(f"\n✗ Could not find auction with UUID {lot_auction_uuid} in first 10 cached auctions") conn.close()