""" Warmup tool for sites with CAPTCHA/bot protection. Run this before the main monitor to solve CAPTCHAs manually. Usage: python tools/warmup.py gamestop python tools/warmup.py all """ import sys import os # Add parent directory to path sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import logging from scrapers.gamestop import warmup_gamestop logging.basicConfig( level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s" ) logger = logging.getLogger(__name__) def warmup_all(): """Warm up all sites that need it""" results = {} logger.info("=" * 50) logger.info("Starting warmup for GameStop...") logger.info("=" * 50) results["gamestop"] = warmup_gamestop() # Add more sites here as needed # results["pokemoncenter"] = warmup_pokemoncenter() logger.info("=" * 50) logger.info("Warmup Results:") for site, success in results.items(): status = "OK" if success else "FAILED" logger.info(f" {site}: {status}") logger.info("=" * 50) return all(results.values()) def main(): if len(sys.argv) < 2: print(__doc__) print("\nAvailable sites: gamestop, all") sys.exit(1) site = sys.argv[1].lower() if site == "gamestop": success = warmup_gamestop() elif site == "all": success = warmup_all() else: print(f"Unknown site: {site}") print("Available sites: gamestop, all") sys.exit(1) if success: logger.info("Warmup completed successfully!") sys.exit(0) else: logger.error("Warmup failed or timed out") sys.exit(1) if __name__ == "__main__": main()