scrape_roms.py 1.0 KB

123456789101112131415161718192021222324252627282930
  1. from django.core.management.base import BaseCommand, CommandError
  2. from django.conf import settings
  3. from games.utils import skyscrape_console
  4. class Command(BaseCommand):
  5. help = "Scrape all games found in a given gamelist XML file"
  6. def add_arguments(self, parser):
  7. parser.add_argument("system", type=str)
  8. def handle(self, *args, **options):
  9. game_system_slug = options["system"]
  10. if not game_system_slug:
  11. self.stdout.write(self.style.ERROR(f"No game system, or all specified"))
  12. return False
  13. if game_system_slug == "all":
  14. for slug in settings.GAME_SYSTEM_DEFAULTS.keys():
  15. scrape_out, load_out = skyscrape_console(slug)
  16. self.stdout.write(
  17. self.style.SUCCESS(f"Successfully scraped roms for {slug}")
  18. )
  19. else:
  20. scrape_out, load_out = skyscrape_console(game_system_slug)
  21. self.stdout.write(
  22. self.style.SUCCESS("Successfully scraped roms for {slug}")
  23. )