From 34e53f4861e39f6c9158120c6680cff2287b1c85 Mon Sep 17 00:00:00 2001 From: Neocky Date: Fri, 26 Feb 2021 01:22:16 +0100 Subject: [PATCH] Added initial files Added: - consoleouput.py - plugin_downloader.py --- .vscode/settings.json | 4 +++ consoleoutput.py | 36 ++++++++++++++++++++++++++ plugin_downloader.py | 59 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 consoleoutput.py create mode 100644 plugin_downloader.py diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..cc67606 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "python.linting.pylintEnabled": true, + "python.linting.enabled": true +} \ No newline at end of file diff --git a/consoleoutput.py b/consoleoutput.py new file mode 100644 index 0000000..9aa543c --- /dev/null +++ b/consoleoutput.py @@ -0,0 +1,36 @@ +# Handles the console output +from os import system +from os import name + +def consoleTitle(): + system("title " + "🧱 pluGET by Neocky") + + +def clearConsole(): + system('cls' if name=='nt' else 'clear') + + +def printLogo(): + print() + print(r" ___ ___ ___ ___ ___ ___ ") + print(r" /\ \ /\__\ /\__\ /\ \ /\ \ /\ "'\\ ') + print(r" /::\ \ /:/ / /:/ / /::\ \ /::\ \ \:\ "'\\ ') + print(r" /:/\:\ \ /:/ / /:/ / /:/\:\ \ /:/\:\ \ \:\ "'\\ ') + print(r" /::\~\:\ \ /:/ / /:/ / ___ /:/ \:\ \ /::\~\:\ \ /::\ "'\\') + print(r" /:/\:\ \:\__\ /:/__/ /:/__/ /\__\ /:/__/_\:\__\ /:/\:\ \:\__\ /:/\:\__\ ") + print(r" \/__\:\/:/ / \:\ \ \:\ \ /:/ / \:\ /\ \/__/ \:\~\:\ \/__/ /:/ \/__/") + print(r" \::/ / \:\ \ \:\ /:/ / \:\ \:\__\ \:\ \:\__\ /:/ / ") + print(r" \/__/ \:\ \ \:\/:/ / \:\/:/ / \:\ \/__/ \/__/ ") + print(r" \:\__\ \::/ / \::/ / \:\__\ ") + print(r" \/__/ \/__/ \/__/ \/__/ ") + print() + print() + print(" by Neocky ") + print() + +def printMainMenu(): + printLogo() + print(" ─────────────────────────────────────────────────────────────────────────────────") + print(" [1] Download a specific package") + print(" [2] Get update info of package") + print() \ No newline at end of file diff --git a/plugin_downloader.py b/plugin_downloader.py new file mode 100644 index 0000000..b7ae436 --- /dev/null +++ b/plugin_downloader.py @@ -0,0 +1,59 @@ +import urllib.request +from urllib.request import urlopen +from urllib.request import urlretrieve +import cgi +from consoleoutput import consoleTitle, clearConsole, printMainMenu +import time + + +def calculateFileSize(downloadFileSize): + fileSizeDownload = int(downloadFileSize) + fileSizeMb = fileSizeDownload / 1024 / 1024 + roundedFileSize = round(fileSizeMb, 2) + return roundedFileSize + +consoleTitle() + +print("if you see this clearConsole dont work") +clearConsole() +printMainMenu() +choice = input("pluGET >> ") +if choice == "1": + ressourceId = input("SpigotMC Ressource ID: ") + +# 28140 for Luckperms (Testing only) +url = "https://api.spiget.org/v2/resources/" + ressourceId + "/download" +print(url) + +# getting original filename +remotefile = urlopen(url) +filecontent = remotefile.info()['Content-Disposition'] +filesize = remotefile.info()['Content-Length'] +value, params = cgi.parse_header(filecontent) +filename = params["filename"] + +# creating file path +path = r"C:\\Users\USERNAME\Desktop\\" +ppath = path + filename + +# download file +urllib.request.urlretrieve(url, ppath) + +filesizeData = calculateFileSize(filesize) +print(filesizeData) + +#print(format(filesizeinmb, '.2f')) + +print("Hello world") +print("Waiting still seconds: 5", end='\r') +time.sleep(1) +print("Waiting still seconds: 4", end='\r') +time.sleep(1) +print("Waiting still seconds: 3", end='\r') +time.sleep(1) +print("Waiting still seconds: 2", end='\r') +time.sleep(1) +print("Waiting still seconds: 1", end='\r') +time.sleep(1) +print("Done βœ…") +input("Taste drΓΌcken zum Beenden...") \ No newline at end of file