From ba4aa69173f151cf00dd6900c35e7debd248eef3 Mon Sep 17 00:00:00 2001 From: Neocky Date: Wed, 3 Mar 2021 00:17:15 +0100 Subject: [PATCH] Formatted code and added test query to plugin updater --- pluGET/consoleoutput.py | 3 ++- pluGET/plugin_downloader.py | 8 ++++---- pluGET/plugin_updatechecker.py | 11 +++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/pluGET/consoleoutput.py b/pluGET/consoleoutput.py index 060eae3..87b353f 100644 --- a/pluGET/consoleoutput.py +++ b/pluGET/consoleoutput.py @@ -69,7 +69,8 @@ def printLogo(): oColors.standardWhite) print() print() - print(" " + oColors.darkMagenta + "by Neocky" + oColors.standardWhite+ " ") + print(oColors.brightYellow + " [" + oColors.darkMagenta + "by Neocky" + + oColors.brightYellow + "] " + oColors.standardWhite) print() diff --git a/pluGET/plugin_downloader.py b/pluGET/plugin_downloader.py index 3403e3c..25f6298 100644 --- a/pluGET/plugin_downloader.py +++ b/pluGET/plugin_downloader.py @@ -1,8 +1,8 @@ import urllib.request import cgi import time -import requests import re +import requests from consoleoutput import consoleTitle, clearConsole, printMainMenu from plugin_updatechecker import getInstalledPackages @@ -147,6 +147,7 @@ def searchPackage(): print(packageUrl) print(ressourceId) + def downloadLatestVersion(ressourceId, packageDownloadName, sourcePath): url = "https://api.spiget.org/v2/resources/" + ressourceId + "/download" remotefile = urllib.request.urlopen(url) @@ -154,6 +155,8 @@ def downloadLatestVersion(ressourceId, packageDownloadName, sourcePath): downloadPath = sourcePath + packageDownloadName urllib.request.urlretrieve(url, downloadPath) filesizeData = calculateFileSize(filesize) + print(filesizeData) + print(filesize) print(f" Downloadsize: {filesizeData} MB") @@ -170,9 +173,6 @@ def getLatestPackageVersion(): downloadLatestVersion(ressourceId, packageDownloadName, downloadPath) - - - consoleTitle() inputMainMenu() outputTest() diff --git a/pluGET/plugin_updatechecker.py b/pluGET/plugin_updatechecker.py index 63370d5..ecee4ba 100644 --- a/pluGET/plugin_updatechecker.py +++ b/pluGET/plugin_updatechecker.py @@ -1,5 +1,6 @@ import os import re +import requests #from consoleoutput import consoleTitle, clearConsole #from plugin_downloader import handleInput @@ -22,6 +23,16 @@ def getInstalledPluginVersion(pluginName): pluginNameOnly = pluginNameOnly[:-1] print(pluginNameOnly) print(pluginVersionString) + response = requests.get("https://api.spiget.org/v2/search/resources/" + pluginNameOnly + "?field=name") + #https://api.spiget.org/v2/search/resources/luckperms?field=name + print("https://api.spiget.org/v2/search/resources/" + pluginNameOnly + "?field=name") + packageName = response.json() + i = 1 + for ressource in packageName: + pName = ressource["name"] + pID = ressource["id"] + print(f" [{i}] {pName}") + i = i + 1 # start query # get id