Fixed JsonDecodeError & Better pluginnames

Changes:
- fixed JsonDecodeError when filename had many special characters in it
- fixed version & name wouldn't get detectet when plugin.yml file would have whitespaces in the beginning
- better output of plugin names when checking & updating
This commit is contained in:
Neocky 2021-05-28 23:52:16 +02:00
parent 26d7965422
commit 764e8bcb81

View File

@ -89,14 +89,14 @@ def eggCrackingJar(localJarFileName, searchMode):
pluginYmlContentLine = pluginYml.readlines()
for line in pluginYmlContentLine:
if searchMode == 'version':
if re.match(r'^version: ', line):
pluginVersion = line.replace('version: ', '')
if re.match(r'^\s*?version: ', line):
pluginVersion = re.sub(r'^\s*?version: ', '', line)
pluginVersion = pluginVersion.replace('\n', '')
pluginVersion = pluginVersion.replace("'", '')
pluginVersion = pluginVersion.replace('"', '')
elif searchMode == 'name':
if re.match(r'^name: ', line):
pluginName = line.replace('name: ', '')
if re.match(r'^\s*?name: ', line):
pluginName = re.sub(r'^\s*?name: ', '', line)
pluginName = pluginName.replace('\n', '')
pluginName = pluginName.replace("'", '')
pluginName = pluginName.replace('"', '')
@ -138,6 +138,7 @@ def checkInstalledPackage(inputSelectedObject="all"):
pluginId = getInstalledPlugin(fileName, fileVersion, plugin)
except TypeError:
continue
pluginIdStr = str(pluginId)
if fileVersion == '':
fileVersion = 'N/A'
@ -160,6 +161,9 @@ def checkInstalledPackage(inputSelectedObject="all"):
if pluginIsOutdated == True:
oldPlugins = oldPlugins + 1
if re.search(r'.jar', fileName):
fileName = eggCrackingJar(plugin, "name")
if inputSelectedObject != "*" and inputSelectedObject != "all":
if inputSelectedObject == pluginIdStr or re.search(inputSelectedObject, fileName, re.IGNORECASE):
if pluginLatestVersion == 'N/A':
@ -219,6 +223,8 @@ def updateInstalledPackage(inputSelectedObject='all'):
continue
except ValueError:
continue
if re.search(r'.jar', fileName):
fileName = eggCrackingJar(plugin, "name")
pluginIdStr = str(pluginId)
if pluginId == None or pluginId == '':
print(oColors.brightRed + "Couldn't find plugin id. Sorry :(" + oColors.standardWhite)
@ -359,15 +365,23 @@ def getInstalledPlugin(localFileName, localFileVersion, localPluginFullName):
if i == 2:
pluginNameinYML = eggCrackingJar(localPluginFullName, 'name')
url = "https://api.spiget.org/v2/search/resources/" + pluginNameinYML + "?field=name&sort=-downloads"
try:
packageName = doAPIRequest(url)
except ValueError:
continue
localFileVersion = localFileVersionNew
for ressource in packageName:
if plugin_match_found == True:
break
continue
pID = ressource["id"]
url2 = f"https://api.spiget.org/v2/resources/{pID}/versions?size=100&sort=-name"
try:
packageVersions = doAPIRequest(url2)
except ValueError:
continue
for updates in packageVersions:
updateVersion = updates["name"]
if localFileVersionNew in updateVersion: