From 9c7819dfbdeb8bb53537dcdbbc46aea6e6ae9c7d Mon Sep 17 00:00:00 2001 From: Evgenij Titarenko Date: Sun, 23 Jul 2023 14:15:53 +0300 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=83=D1=81=D1=82=D0=B0=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B8=20=D1=80=D0=B5=D1=81=D1=83=D1=80=D1=81=20?= =?UTF-8?q?=D0=B8=20=D1=88=D0=B5=D0=B9=D0=B4=D0=B5=D1=80=20=D0=BF=D0=B0?= =?UTF-8?q?=D0=BA=D0=BE=D0=B2.=20=D0=92=D1=8B=D0=B1=D1=80=D0=B0=D1=81?= =?UTF-8?q?=D1=8B=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BE=D1=88=D0=B8=D0=B1?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=BF=D1=80=D0=B8=20=D0=BF=D0=BE=D0=BF=D1=83?= =?UTF-8?q?=D1=82=D0=BA=D0=B8=20=D1=83=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=BC=D0=BE=D0=B4=D0=BF=D0=B0=D0=BA=D0=B0=20-?= =?UTF-8?q?=20=D1=82=D1=80=D0=B5=D0=B1=D1=83=D0=B5=D1=82=D1=81=D1=8F=20?= =?UTF-8?q?=D0=B8=D0=B7=D1=83=D1=87=D0=B8=D1=82=D1=8C=20=D0=BA=D0=B0=D0=BA?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=B2=D0=BB=D0=B8=D1=8F=D0=BB=D0=BE=20=20=D0=B8?= =?UTF-8?q?=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D1=86=D0=B5=D1=81=D1=81=D0=B0=20=D1=83=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mc-get.py | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/mc-get.py b/mc-get.py index 86d46ab..284336b 100755 --- a/mc-get.py +++ b/mc-get.py @@ -74,15 +74,25 @@ def install(projects: list, version, loader): for project in projects_ids: project_data = api.project(project=project) - versions = api.get_versions(project=project, loaders=f'["{loader}"]', - game_versions=f'["{mc_ver}"]') + match project_data.project_type: + case "resourcepack": + versions = api.get_versions(project=project, game_versions=f'["{mc_ver}"]') + case "mod": + versions = api.get_versions(project=project, loaders=f'["{loader}"]', game_versions=f'["{mc_ver}"]') + case "shader": # TODO: Реализовать поддержку загрузчиков шейдеров + versions = api.get_versions(project=project, game_versions=f'["{mc_ver}"]') + case "modpack": # TODO: [РЕГРЕССИЯ] Реализовать поддержку модпаков + raise NotImplementedError + case _: + raise NotImplementedError + if versions: to_install.append((project_data, versions[0])) dependency_solver(versions[0]) else: unavailable.append(project_data) - - print("To install:", *[project.title + " " + version.version_number for project, version in to_install], sep="\n\t") + if to_install: + print("To install:", *[project.title + " " + version.version_number for project, version in to_install], sep="\n\t") if dependencies_to_install: print("With dependencies:", *[project.title + " " + version.version_number for project, version in dependencies_to_install], @@ -93,14 +103,19 @@ def install(projects: list, version, loader): if unavailable: print("Cannot be installed:", *[project.title for project in unavailable], sep="\n\t") - choose = input("Continue? [y/n]") + all_to_install = to_install + dependencies_to_install + + if not all_to_install: + return + + choose = input("Continue? [y/n] ") if choose.strip().lower() in ["n", "no"]: print("Canceled.") return - for project, version in to_install + dependencies_to_install: + for project, version in all_to_install: file = type("mc_file", (object,), version.files[0]) - filename = project.slug + ".jar" + filename = file.filename download_cache(file.url, filename, file.size) match project.project_type: case "resourcepack":