66 lines
1.6 KiB
Python
66 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Deep inspect lot JSON for viewing/pickup data"""
|
|
import sqlite3
|
|
import zlib
|
|
import json
|
|
import re
|
|
|
|
conn = sqlite3.connect('/mnt/okcomputer/output/cache.db')
|
|
|
|
cursor = conn.execute("""
|
|
SELECT url, content
|
|
FROM cache
|
|
WHERE url LIKE '%/l/%'
|
|
ORDER BY timestamp DESC
|
|
LIMIT 1
|
|
""")
|
|
|
|
row = cursor.fetchone()
|
|
url, content_blob = row
|
|
content = zlib.decompress(content_blob).decode('utf-8')
|
|
|
|
match = re.search(r'<script[^>]*id="__NEXT_DATA__"[^>]*>(.+?)</script>', content, re.DOTALL)
|
|
data = json.loads(match.group(1))
|
|
lot = data.get('props', {}).get('pageProps', {}).get('lot', {})
|
|
|
|
print(f"Inspecting: {url}\n")
|
|
|
|
# Check onboarding
|
|
if 'onboarding' in lot:
|
|
print("ONBOARDING:")
|
|
print(json.dumps(lot['onboarding'], indent=2))
|
|
print()
|
|
|
|
# Check attributes
|
|
if 'attributes' in lot:
|
|
print("ATTRIBUTES:")
|
|
attrs = lot['attributes']
|
|
print(json.dumps(attrs[:3] if isinstance(attrs, list) else attrs, indent=2))
|
|
print()
|
|
|
|
# Check condition
|
|
if 'condition' in lot:
|
|
print("CONDITION:")
|
|
print(json.dumps(lot['condition'], indent=2))
|
|
print()
|
|
|
|
# Check appearance
|
|
if 'appearance' in lot:
|
|
print("APPEARANCE:")
|
|
print(json.dumps(lot['appearance'], indent=2))
|
|
print()
|
|
|
|
# Check location
|
|
if 'location' in lot:
|
|
print("LOCATION:")
|
|
print(json.dumps(lot['location'], indent=2))
|
|
print()
|
|
|
|
# Check for any field with "view", "pick", "collect", "date", "time"
|
|
print("\nFIELDS WITH VIEWING/PICKUP/TIME:")
|
|
for key in lot.keys():
|
|
if any(term in key.lower() for term in ['view', 'pick', 'collect', 'date', 'time', 'day']):
|
|
print(f" {key}: {lot[key]}")
|
|
|
|
conn.close()
|