windows-compatible modpack downloader
This commit is contained in:
@@ -6,7 +6,7 @@ from typing import Any
|
|||||||
|
|
||||||
OS = sys.platform
|
OS = sys.platform
|
||||||
|
|
||||||
MOD_DOWNLOADER_URL = "https://github.com/Advik-B/CMPDL/releases/download/v3.0.0/CMPDL-raw.ZipApp.zip"
|
MOD_DOWNLOADER_URL = "https://github.com/Joshyx/ModpackDownloader/releases/download/v1.3/ModpackDownloader-1.3.jar"
|
||||||
|
|
||||||
MODPACK_RELEASES_URL = "https://git.233hfd.com/api/v1/repos/joey/FishPogPixelmon/releases?limit=1"
|
MODPACK_RELEASES_URL = "https://git.233hfd.com/api/v1/repos/joey/FishPogPixelmon/releases?limit=1"
|
||||||
|
|
||||||
@@ -57,21 +57,40 @@ def mods():
|
|||||||
os.chdir(INSTANCE_DIR)
|
os.chdir(INSTANCE_DIR)
|
||||||
|
|
||||||
if not os.path.exists(os.path.join(INSTANCE_DIR, "downloader.zip")):
|
if not os.path.exists(os.path.join(INSTANCE_DIR, "downloader.zip")):
|
||||||
cprint("downloader.zip not found - downloading", "yellow")
|
cprint("downloader.jar not found - downloading", "yellow")
|
||||||
r = requests.get(MOD_DOWNLOADER_URL, allow_redirects=True)
|
r = requests.get(MOD_DOWNLOADER_URL, allow_redirects=True)
|
||||||
open("downloader.zip", "wb").write(r.content)
|
open("downloader.jar", "wb").write(r.content)
|
||||||
|
|
||||||
cprint("downloading mods. this may take a while, please wait.", "green")
|
cprint("downloading mods. this may take a while, please wait.", "green")
|
||||||
subprocess.run(["python", "downloader.zip", "manifest.json"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
||||||
|
os.makedirs(os.path.join(INSTANCE_DIR, "mods"))
|
||||||
|
if OS != "win32":
|
||||||
|
subprocess.run(["java", "-jar", "downloader.jar", ".", "mods"])
|
||||||
|
else:
|
||||||
|
subprocess.run(
|
||||||
|
[
|
||||||
|
"C:\\Program Files\\AdoptOpenJDK\\jdk-11.0.11.9-hotspot\\bin\\java",
|
||||||
|
"-jar",
|
||||||
|
"downloader.jar",
|
||||||
|
".",
|
||||||
|
"mods",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
for file in glob.glob(os.path.join(INSTANCE_DIR, ".minecraft", "mods", "*")):
|
for file in glob.glob(os.path.join(INSTANCE_DIR, ".minecraft", "mods", "*")):
|
||||||
if os.path.basename(file) == "OptiFine_1.16.5_HD_U_G8.jar":
|
if os.path.basename(file) == "OptiFine_1.16.5_HD_U_G8.jar":
|
||||||
continue
|
continue
|
||||||
os.remove(file)
|
os.remove(file)
|
||||||
|
|
||||||
for file in glob.glob(os.path.join(INSTANCE_DIR, "mods", "*")):
|
for file in glob.glob(os.path.join(INSTANCE_DIR, "mods", "mods", "*")):
|
||||||
shutil.move(file, os.path.join(INSTANCE_DIR, ".minecraft", "mods", os.path.basename(file)))
|
shutil.move(file, os.path.join(INSTANCE_DIR, ".minecraft", "mods", os.path.basename(file)))
|
||||||
|
|
||||||
|
os.makedirs(os.path.join(INSTANCE_DIR, ".minecraft", "resourcepacks"), exist_ok=True)
|
||||||
|
for file in glob.glob(os.path.join(INSTANCE_DIR, "mods", "resourcepacks", "*")):
|
||||||
|
if os.path.exists(os.path.join(INSTANCE_DIR, ".minecraft", "resourcepacks", os.path.basename(file))):
|
||||||
|
continue
|
||||||
|
shutil.move(file, os.path.join(INSTANCE_DIR, ".minecraft", "resourcepacks", os.path.basename(file)))
|
||||||
|
|
||||||
shutil.rmtree(os.path.join(INSTANCE_DIR, "mods"))
|
shutil.rmtree(os.path.join(INSTANCE_DIR, "mods"))
|
||||||
|
|
||||||
cprint("mods downloaded successfully", "green")
|
cprint("mods downloaded successfully", "green")
|
||||||
|
|||||||
2
venv.ps1
2
venv.ps1
@@ -12,7 +12,7 @@ if (-Not (Test-Path "./.venv")) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Activate the virtual environment
|
# Activate the virtual environment
|
||||||
. ./.venv/bin/Activate.ps1
|
. .\.venv\Scripts\Activate.ps1
|
||||||
|
|
||||||
# Install required packages
|
# Install required packages
|
||||||
& $python -m pip install --upgrade pip
|
& $python -m pip install --upgrade pip
|
||||||
|
|||||||
Reference in New Issue
Block a user