Files
mtgonline/backend/scripts/update_refresh_script.py
T

34 lines
1.2 KiB
Python

#!/usr/bin/env python3
"""
Update refresh_mtg.py to fetch image_url from MTGJSON set.json.
"""
import re
from pathlib import Path
refresh_script = Path('/home/wall-o/projects/mtgonline/backend/scripts/refresh_mtg.py')
# Read the current content
content = refresh_script.read_text()
# Find the section where set data is loaded and inserted
# Look for the set insertion code
if 'image' not in content.lower() or 'image_url' not in content.lower():
# Find the set data mapping
old_set_mapping = ''' "icon_svg_url": set_data.get("iconSvgUrl"),'''
new_set_mapping = ''' "icon_svg_url": set_data.get("iconSvgUrl"),
"image_url": set_data.get("image", {}).get("normal"),'''
if old_set_mapping in content:
content = content.replace(old_set_mapping, new_set_mapping)
print("✓ Updated set data mapping to include image_url")
else:
print("⚠ Could not find set data mapping pattern")
print(" Manual update needed for refresh_mtg.py")
else:
print("✓ refresh_mtg.py already includes image_url")
refresh_script.write_text(content)
print("\nNext step: Restart the backend to apply changes")