|
@@ -12,7 +12,7 @@ import logging
|
|
|
logger = logging.Logger(__name__)
|
|
|
|
|
|
US_STRINGS = ["(u)", "(usa)", "(us)"]
|
|
|
-JP_STRINGS = ["(j)", "japan", "jp"]
|
|
|
+JP_STRINGS = ["(j)", "japan", "jp", "jpn"]
|
|
|
EU_STRINGS = ["(e)", "eur", "europe", "pal"]
|
|
|
|
|
|
|
|
@@ -28,6 +28,7 @@ def import_gamelist_file_to_db_for_system(
|
|
|
game_system_slug, file_path=None, full_scan=False
|
|
|
):
|
|
|
imported_games = []
|
|
|
+ not_imported_games = []
|
|
|
if not file_path:
|
|
|
file_path = os.path.join(settings.ROMS_DIR, game_system_slug, "gamelist.xml")
|
|
|
if not os.path.exists(file_path):
|
|
@@ -47,7 +48,9 @@ def import_gamelist_file_to_db_for_system(
|
|
|
for game in games:
|
|
|
name = game.find("name").text
|
|
|
obj, created = Game.objects.get_or_create(name=name)
|
|
|
+
|
|
|
if not created and not full_scan:
|
|
|
+ not_imported_games.append(game)
|
|
|
logger.info(f"Found game {game} and not doing full scan, so skipping")
|
|
|
continue
|
|
|
|
|
@@ -123,7 +126,7 @@ def import_gamelist_file_to_db_for_system(
|
|
|
obj.save()
|
|
|
|
|
|
imported_games.append(game)
|
|
|
- return imported_games
|
|
|
+ return {"imported": imported_games, "not_imported": not_imported_games}
|
|
|
|
|
|
|
|
|
def export_gamelist_file_to_path_for_system(game_system_slug, file_path=None):
|
|
@@ -181,17 +184,13 @@ def skyscrape_console(game_system_slug):
|
|
|
scraper_site = settings.SCRAPER_SITE
|
|
|
|
|
|
# If the config file is relative, append our base dir
|
|
|
- print(f"Preparing to scrape game info for {game_system_slug}")
|
|
|
if scraper_config[0] != "/":
|
|
|
scraper_config = os.path.join(settings.BASE_DIR, scraper_config)
|
|
|
if not os.path.exists(scraper_config):
|
|
|
logger.info(f"Config file not found at {scraper_config}")
|
|
|
- print(f"Config file not found at {scraper_config}")
|
|
|
return
|
|
|
- print(f"Using configuration file from {scraper_config}")
|
|
|
+ logger.info(f"Scraping game info using configuration file from {scraper_config}")
|
|
|
|
|
|
- # scrape_cmd = f"{binary} -c {config_file} -s {site} -u {user}:{password} -t {threads} -f emulationstation -p {game_system_slug}"
|
|
|
- # load_cmd = f"{binary} -f emulationstation -p {game_system_slug}"
|
|
|
scrape_output = subprocess.run(
|
|
|
[
|
|
|
scraper_binary,
|
|
@@ -199,6 +198,8 @@ def skyscrape_console(game_system_slug):
|
|
|
f"{scraper_config}",
|
|
|
"-s",
|
|
|
f"{scraper_site}",
|
|
|
+ "-f",
|
|
|
+ "emulationstation",
|
|
|
"-p",
|
|
|
f"{game_system_slug}",
|
|
|
],
|
|
@@ -210,12 +211,13 @@ def skyscrape_console(game_system_slug):
|
|
|
"-c",
|
|
|
f"{scraper_config}",
|
|
|
"-f",
|
|
|
- "{scraper_site}",
|
|
|
+ "emulationstation",
|
|
|
"-p",
|
|
|
f"{game_system_slug}",
|
|
|
],
|
|
|
capture_output=True,
|
|
|
)
|
|
|
+ # TODO We should progressively pipe output to a log file instead of this
|
|
|
print(scrape_output)
|
|
|
print(load_output)
|
|
|
return scrape_output, load_output
|