diff --git a/mc-get.py b/mc-get.py index cd9dba8..d3ea972 100644 --- a/mc-get.py +++ b/mc-get.py @@ -1,18 +1,18 @@ import argparse import api -#import urllib.request +import mcfs def validate(): pass def install(projects:list): + to_install = [] for project in projects: project_data = api.project(project=project) version = api.version(version=project_data.versions[0]) file = version.files[0].get("url", "NO URL") print(file) api.download(file, version.files[0].get("size", 0)) - #urllib.request.urlretrieve(file) def search(): pass @@ -29,7 +29,7 @@ validate - validate mods installation\n search - search mods''' args = parser.parse_args() match args.method: case "install": - install(args.method_args) + pass case "search": search() case "validate": diff --git a/mcfs.py b/mcfs.py new file mode 100644 index 0000000..f8333ee --- /dev/null +++ b/mcfs.py @@ -0,0 +1,39 @@ +import os +from sys import platform + +def __get_mc_dir(): + directory = "" + if platform == 'linux': + home = os.getenv("HOME", "") + directory = home + "/.minecraft" + elif platform == 'win32': + appdata = os.getenv('APPDATA') + directory = appdata + r"\.minecraft" + elif platform == "darwin": + directory = "~/Library/Application Support/minecraft" #unsure + directory = os.getenv("MC_DIR", directory) + return directory + +def __get_cache_dir(): + directory = "" + if platform == 'win32': + appdata_local = os.getenv("LOCALAPPDATA") + directory = appdata_local + r"\mc-get" + elif platform == 'darwin': + directory = '~/Library/Caches/mc-get' #unsure + elif platform == 'linux': + cache = os.getenv("HOME") + "/.cache" + directory = cache + "/mc-get" + else: + cache = os.getenv("XDG_CACHE_HOME", "") + directory = cache + "/mc-get" + return directory + +def is_path_exist(path:str): + return os.path.exists(os.path.join(path)) + +def is_standart_dir_structure(): + return not os.path.exists(os.path.join(directory, "home")) + +mc_dir = __get_mc_dir() +cache_dir = __get_cache_dir()