Skip to content

Instantly share code, notes, and snippets.

@mathgeniuszach
Last active July 28, 2024 02:54
Show Gist options
  • Select an option

  • Save mathgeniuszach/210fe25eca2e441d66ba2d62f3266f80 to your computer and use it in GitHub Desktop.

Select an option

Save mathgeniuszach/210fe25eca2e441d66ba2d62f3266f80 to your computer and use it in GitHub Desktop.
Updater Script for RetroRewind
#!/usr/bin/env python3
import requests
import sys
import glob
import shutil
import re
import os
from zipfile import ZipFile
from pathlib import Path
if len(sys.argv) < 2:
if os.name == "posix":
print('User path not specified, defaulting to "~/.local/share/dolphin-emu"')
dolphin_folder = Path("~/.local/share/dolphin-emu").expanduser()
else:
print(f"Specify a user path like so: {sys.argv[0]} (user path)")
sys.exit(1)
else:
dolphin_folder = Path(sys.argv[1]).expanduser()
IP_LOC = "https://raw.githubusercontent.com/patchzyy/WheelWizard/main/WheelWizard/Services/Endpoints.cs"
NETWORK_IP_REGEX = re.compile(r'RRUrl\s*=\s*"(.*?)"')
with requests.get(IP_LOC) as resp:
RR_NETWORK_IP = NETWORK_IP_REGEX.search(resp.text)[1]
if RR_NETWORK_IP[-1] != "/":
RR_NETWORK_IP += "/"
ZIP_URL = RR_NETWORK_IP + "RetroRewind/zip/RetroRewind.zip"
RR_DOLPHIN_PATH = dolphin_folder / "Wii/shared2/Pulsar/"
RII_DOLPHIN_PATH = dolphin_folder / "Load/Riivolution/"
if Path("RetroRewind.zip").is_file():
print("RetroRewind.zip already present in working directory. Please delete it to redownload.")
else:
print("Downloading RetroRewind.zip")
with requests.get(ZIP_URL) as resp:
with open("RetroRewind.zip", "wb") as file:
file.write(resp.content)
print("Extracting RetroRewind.zip")
with ZipFile("RetroRewind.zip") as zfile:
zfile.extractall("RetroRewind")
vername = list(Path("./RetroRewind").glob("RetroRewind*"))[0].name
print("Copying Ghosts")
ghosts_dir = RR_DOLPHIN_PATH / vername / "Ghosts"
ghosts_dir.mkdir(parents=True, exist_ok=True)
shutil.rmtree(ghosts_dir)
shutil.copytree(Path("RetroRewind") / vername / "Ghosts", ghosts_dir)
print("Copying Riivolution Data")
for p in (
"apps/RetroRewind",
"apps/yawmME",
vername,
"riivolution/" + vername + ".xml"
):
path = RII_DOLPHIN_PATH / p
path.parent.mkdir(parents=True, exist_ok=True)
if path.is_dir():
shutil.rmtree(path)
elif path.is_file():
path.unlink()
src = Path("RetroRewind") / p
if src.is_dir():
shutil.copytree(src, path)
else:
shutil.copy(src, path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment