mirror of
https://github.com/Neocky/pluGET.git
synced 2024-04-29 16:12:30 +00:00
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:
parent
26d7965422
commit
764e8bcb81
@ -89,14 +89,14 @@ def eggCrackingJar(localJarFileName, searchMode):
|
|||||||
pluginYmlContentLine = pluginYml.readlines()
|
pluginYmlContentLine = pluginYml.readlines()
|
||||||
for line in pluginYmlContentLine:
|
for line in pluginYmlContentLine:
|
||||||
if searchMode == 'version':
|
if searchMode == 'version':
|
||||||
if re.match(r'^version: ', line):
|
if re.match(r'^\s*?version: ', line):
|
||||||
pluginVersion = line.replace('version: ', '')
|
pluginVersion = re.sub(r'^\s*?version: ', '', line)
|
||||||
pluginVersion = pluginVersion.replace('\n', '')
|
pluginVersion = pluginVersion.replace('\n', '')
|
||||||
pluginVersion = pluginVersion.replace("'", '')
|
pluginVersion = pluginVersion.replace("'", '')
|
||||||
pluginVersion = pluginVersion.replace('"', '')
|
pluginVersion = pluginVersion.replace('"', '')
|
||||||
elif searchMode == 'name':
|
elif searchMode == 'name':
|
||||||
if re.match(r'^name: ', line):
|
if re.match(r'^\s*?name: ', line):
|
||||||
pluginName = line.replace('name: ', '')
|
pluginName = re.sub(r'^\s*?name: ', '', line)
|
||||||
pluginName = pluginName.replace('\n', '')
|
pluginName = pluginName.replace('\n', '')
|
||||||
pluginName = pluginName.replace("'", '')
|
pluginName = pluginName.replace("'", '')
|
||||||
pluginName = pluginName.replace('"', '')
|
pluginName = pluginName.replace('"', '')
|
||||||
@ -138,6 +138,7 @@ def checkInstalledPackage(inputSelectedObject="all"):
|
|||||||
pluginId = getInstalledPlugin(fileName, fileVersion, plugin)
|
pluginId = getInstalledPlugin(fileName, fileVersion, plugin)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
pluginIdStr = str(pluginId)
|
pluginIdStr = str(pluginId)
|
||||||
if fileVersion == '':
|
if fileVersion == '':
|
||||||
fileVersion = 'N/A'
|
fileVersion = 'N/A'
|
||||||
@ -160,6 +161,9 @@ def checkInstalledPackage(inputSelectedObject="all"):
|
|||||||
if pluginIsOutdated == True:
|
if pluginIsOutdated == True:
|
||||||
oldPlugins = oldPlugins + 1
|
oldPlugins = oldPlugins + 1
|
||||||
|
|
||||||
|
if re.search(r'.jar', fileName):
|
||||||
|
fileName = eggCrackingJar(plugin, "name")
|
||||||
|
|
||||||
if inputSelectedObject != "*" and inputSelectedObject != "all":
|
if inputSelectedObject != "*" and inputSelectedObject != "all":
|
||||||
if inputSelectedObject == pluginIdStr or re.search(inputSelectedObject, fileName, re.IGNORECASE):
|
if inputSelectedObject == pluginIdStr or re.search(inputSelectedObject, fileName, re.IGNORECASE):
|
||||||
if pluginLatestVersion == 'N/A':
|
if pluginLatestVersion == 'N/A':
|
||||||
@ -219,6 +223,8 @@ def updateInstalledPackage(inputSelectedObject='all'):
|
|||||||
continue
|
continue
|
||||||
except ValueError:
|
except ValueError:
|
||||||
continue
|
continue
|
||||||
|
if re.search(r'.jar', fileName):
|
||||||
|
fileName = eggCrackingJar(plugin, "name")
|
||||||
pluginIdStr = str(pluginId)
|
pluginIdStr = str(pluginId)
|
||||||
if pluginId == None or pluginId == '':
|
if pluginId == None or pluginId == '':
|
||||||
print(oColors.brightRed + "Couldn't find plugin id. Sorry :(" + oColors.standardWhite)
|
print(oColors.brightRed + "Couldn't find plugin id. Sorry :(" + oColors.standardWhite)
|
||||||
@ -353,21 +359,29 @@ def getInstalledPlugin(localFileName, localFileVersion, localPluginFullName):
|
|||||||
i = 0
|
i = 0
|
||||||
for i in range(0, 3):
|
for i in range(0, 3):
|
||||||
if plugin_match_found == True:
|
if plugin_match_found == True:
|
||||||
break
|
break
|
||||||
if i == 1:
|
if i == 1:
|
||||||
localFileVersionNew = re.sub(r'(\-\w*)', '', localFileVersion)
|
localFileVersionNew = re.sub(r'(\-\w*)', '', localFileVersion)
|
||||||
if i == 2:
|
if i == 2:
|
||||||
pluginNameinYML = eggCrackingJar(localPluginFullName, 'name')
|
pluginNameinYML = eggCrackingJar(localPluginFullName, 'name')
|
||||||
url = "https://api.spiget.org/v2/search/resources/" + pluginNameinYML + "?field=name&sort=-downloads"
|
url = "https://api.spiget.org/v2/search/resources/" + pluginNameinYML + "?field=name&sort=-downloads"
|
||||||
packageName = doAPIRequest(url)
|
try:
|
||||||
|
packageName = doAPIRequest(url)
|
||||||
|
except ValueError:
|
||||||
|
continue
|
||||||
|
|
||||||
localFileVersion = localFileVersionNew
|
localFileVersion = localFileVersionNew
|
||||||
|
|
||||||
for ressource in packageName:
|
for ressource in packageName:
|
||||||
if plugin_match_found == True:
|
if plugin_match_found == True:
|
||||||
break
|
continue
|
||||||
pID = ressource["id"]
|
pID = ressource["id"]
|
||||||
url2 = f"https://api.spiget.org/v2/resources/{pID}/versions?size=100&sort=-name"
|
url2 = f"https://api.spiget.org/v2/resources/{pID}/versions?size=100&sort=-name"
|
||||||
packageVersions = doAPIRequest(url2)
|
|
||||||
|
try:
|
||||||
|
packageVersions = doAPIRequest(url2)
|
||||||
|
except ValueError:
|
||||||
|
continue
|
||||||
for updates in packageVersions:
|
for updates in packageVersions:
|
||||||
updateVersion = updates["name"]
|
updateVersion = updates["name"]
|
||||||
if localFileVersionNew in updateVersion:
|
if localFileVersionNew in updateVersion:
|
||||||
|
Loading…
Reference in New Issue
Block a user