|
@@ -18,8 +18,10 @@ EU_STRINGS = ["(e)", "eur", "europe", "pal"]
|
|
|
|
|
|
def update_media_root_for_import(file_path):
|
|
|
"""Given a file path, re-write it for our app MEDIA_ROOT"""
|
|
|
- split_path = file_path.split("/media/")
|
|
|
- return split_path[-1]
|
|
|
+ suffix = ""
|
|
|
+ if file_path:
|
|
|
+ suffix = file_path.split("/media/")[-1]
|
|
|
+ return suffix
|
|
|
|
|
|
|
|
|
def import_gamelist_file_to_db_for_system(game_system_slug, file_path=None):
|
|
@@ -88,7 +90,10 @@ def import_gamelist_file_to_db_for_system(game_system_slug, file_path=None):
|
|
|
description = game.find("desc").text
|
|
|
screenshot_path = update_media_root_for_import(game.find("image").text)
|
|
|
rom_path = update_media_root_for_import(game.find("path").text)
|
|
|
- video_path = update_media_root_for_import(game.find("video").text)
|
|
|
+ video_path_elem = game.find("video")
|
|
|
+ video_path = ""
|
|
|
+ if video_path_elem:
|
|
|
+ video_path = update_media_root_for_import(video_path_elem.text)
|
|
|
marquee_path = update_media_root_for_import(game.find("marquee").text)
|
|
|
|
|
|
obj, created = Game.objects.get_or_create(name=name)
|
|
@@ -166,26 +171,29 @@ def export_gamelist_file_to_path_for_system(game_system_slug, file_path=None):
|
|
|
|
|
|
|
|
|
def skyscrape_console(game_system_slug):
|
|
|
- scraper_config = settings.SCRAPER_CONFIG
|
|
|
- binary = scraper_config["bin_path"]
|
|
|
- site = scraper_config["site"]
|
|
|
- user = scraper_config["user"]
|
|
|
- password = scraper_config["pass"]
|
|
|
- threads = scraper_config["threads"]
|
|
|
-
|
|
|
- scrape_cmd = f"{binary} -s {site} -u {user}:{password} -t {threads} -f emulationstation -p {game_system_slug}"
|
|
|
- load_cmd = f"{binary} -f emulationstation -p {game_system_slug}"
|
|
|
+ scraper_config = settings.SCRAPER_CONFIG_FILE
|
|
|
+ scraper_binary = settings.SCRAPER_BIN_PATH
|
|
|
+ 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}")
|
|
|
+
|
|
|
+ # 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(
|
|
|
[
|
|
|
- binary,
|
|
|
+ scraper_binary,
|
|
|
+ "-c",
|
|
|
+ f"{scraper_config}",
|
|
|
"-s",
|
|
|
- "{site}",
|
|
|
- "-u",
|
|
|
- f"{user}:{password}",
|
|
|
- "-t",
|
|
|
- f"{threads}",
|
|
|
- "-f",
|
|
|
- "emulationstation",
|
|
|
+ f"{scraper_site}",
|
|
|
"-p",
|
|
|
f"{game_system_slug}",
|
|
|
],
|
|
@@ -193,12 +201,16 @@ def skyscrape_console(game_system_slug):
|
|
|
)
|
|
|
load_output = subprocess.run(
|
|
|
[
|
|
|
- binary,
|
|
|
+ scraper_binary,
|
|
|
+ "-c",
|
|
|
+ f"{scraper_config}",
|
|
|
"-f",
|
|
|
- "emulationstation",
|
|
|
+ "{scraper_site}",
|
|
|
"-p",
|
|
|
f"{game_system_slug}",
|
|
|
],
|
|
|
capture_output=True,
|
|
|
)
|
|
|
+ print(scrape_output)
|
|
|
+ print(load_output)
|
|
|
return scrape_output, load_output
|