Skip to content

Commit

Permalink
Split into 2 versions & add a CLI argument parser (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
KTrain5169 authored Oct 18, 2024
1 parent 0665663 commit 038246b
Show file tree
Hide file tree
Showing 10 changed files with 430 additions and 258 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Other pack forms may be considered.

## How does this work?

Modrinth's `mrpack` format is just a `zip` file with a renamed extension. So, the program downloads the `mrpack` file and renames it to have the `.zip` extension.
Modrinth's `mrpack` format is just a `zip` file with a renamed extension. So, the program downloads the `mrpack` file and extracts it like a `zip` file.
Afterwards, the program reads the `modrinth.index.json` file, which contains links to download projects in the pack. It's why modpacks are so light, because they are (usually) links instead of actual mods.

If the modpack contains an `overrides` folder, which may be the case for most modpacks, it will also copy over the `overrides/` contents.
Expand All @@ -27,3 +27,10 @@ Update: The program now has support for ensuring modpack dependency integrity (i
## Should I use this?

Absolutely... not! If you can, try to use a third-party launcher instead. (For `mrpack` packs, you can use [Prism](https://prismlauncher.org), [Modrinth](https://modrinth.com/app) or [ATLauncher](https://atlauncher.com), all open-source.) This was more a project for fun and shouldn't be taken seriously *for now*.

## CLI usage

The direct-download script can also double as a CLI app. Here are the commands for it:

* --url (-u for short) - Specifies the download URL.
* --output (-o for short) - Specifies the output directory. If omitted but --url or -u is used, it will download into the current working directory instead.
52 changes: 52 additions & 0 deletions direct-download.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import os
import requests
import argparse
from pathlib import Path
from modules.modpack_processor import ModpackProcessor

def main():
# Set up argument parsing
parser = argparse.ArgumentParser(description="Download and process a Minecraft modpack.")
parser.add_argument('-u', '--url', type=str, help='Modpack download URL')
parser.add_argument('-o', '--output', type=str, help='Output folder path')

# Parse the arguments
args = parser.parse_args()

# Check if args were provided
if args.url and args.output:
modpack_url = args.url
output_folder = args.output if args.output else os.getcwd()
else:
# Prompt the user for inputs if no args were given
modpack_url = input("Enter the Modpack URL: ")
output_folder = input("Enter the Output Folder Path (or leave blank to use current directory): ")
if not output_folder:
output_folder = os.getcwd()

# Check if output folder exists, create if not
output_folder_path = Path(output_folder)
if not output_folder_path.exists():
output_folder_path.mkdir(parents=True, exist_ok=True)

# Initialize the modpack processor
modpack_processor = ModpackProcessor(output_folder)

# Process the modpack download
try:
print("Downloading modpack...")
manifest_path, overrides_path, modpack_name = modpack_processor.process_modpack(
modpack_url, status_callback=print_status)

if manifest_path or overrides_path:
print("Finished unpacking, enjoy the modpack!")
else:
print("Failed to locate manifest or overrides in the modpack.")
except Exception as e:
print(f"An error occurred: {e}")

def print_status(message):
print(message)

if __name__ == "__main__":
main()
54 changes: 0 additions & 54 deletions downloader/modpack_processor.py

This file was deleted.

113 changes: 0 additions & 113 deletions downloader/modrinth_packs.py

This file was deleted.

90 changes: 0 additions & 90 deletions gui.py

This file was deleted.

File renamed without changes.
Loading

0 comments on commit 038246b

Please sign in to comment.