Formatted code and added test query to plugin updater

This commit is contained in:
Neocky 2021-03-03 00:17:15 +01:00
parent 42732d1ea5
commit ba4aa69173
3 changed files with 17 additions and 5 deletions

View File

@ -69,7 +69,8 @@ def printLogo():
oColors.standardWhite) oColors.standardWhite)
print() print()
print() print()
print(" " + oColors.darkMagenta + "by Neocky" + oColors.standardWhite+ " ") print(oColors.brightYellow + " [" + oColors.darkMagenta + "by Neocky" +
oColors.brightYellow + "] " + oColors.standardWhite)
print() print()

View File

@ -1,8 +1,8 @@
import urllib.request import urllib.request
import cgi import cgi
import time import time
import requests
import re import re
import requests
from consoleoutput import consoleTitle, clearConsole, printMainMenu from consoleoutput import consoleTitle, clearConsole, printMainMenu
from plugin_updatechecker import getInstalledPackages from plugin_updatechecker import getInstalledPackages
@ -147,6 +147,7 @@ def searchPackage():
print(packageUrl) print(packageUrl)
print(ressourceId) print(ressourceId)
def downloadLatestVersion(ressourceId, packageDownloadName, sourcePath): def downloadLatestVersion(ressourceId, packageDownloadName, sourcePath):
url = "https://api.spiget.org/v2/resources/" + ressourceId + "/download" url = "https://api.spiget.org/v2/resources/" + ressourceId + "/download"
remotefile = urllib.request.urlopen(url) remotefile = urllib.request.urlopen(url)
@ -154,6 +155,8 @@ def downloadLatestVersion(ressourceId, packageDownloadName, sourcePath):
downloadPath = sourcePath + packageDownloadName downloadPath = sourcePath + packageDownloadName
urllib.request.urlretrieve(url, downloadPath) urllib.request.urlretrieve(url, downloadPath)
filesizeData = calculateFileSize(filesize) filesizeData = calculateFileSize(filesize)
print(filesizeData)
print(filesize)
print(f" Downloadsize: {filesizeData} MB") print(f" Downloadsize: {filesizeData} MB")
@ -170,9 +173,6 @@ def getLatestPackageVersion():
downloadLatestVersion(ressourceId, packageDownloadName, downloadPath) downloadLatestVersion(ressourceId, packageDownloadName, downloadPath)
consoleTitle() consoleTitle()
inputMainMenu() inputMainMenu()
outputTest() outputTest()

View File

@ -1,5 +1,6 @@
import os import os
import re import re
import requests
#from consoleoutput import consoleTitle, clearConsole #from consoleoutput import consoleTitle, clearConsole
#from plugin_downloader import handleInput #from plugin_downloader import handleInput
@ -22,6 +23,16 @@ def getInstalledPluginVersion(pluginName):
pluginNameOnly = pluginNameOnly[:-1] pluginNameOnly = pluginNameOnly[:-1]
print(pluginNameOnly) print(pluginNameOnly)
print(pluginVersionString) 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 # start query
# get id # get id