mirror of
https://github.com/Neocky/pluGET.git
synced 2024-04-29 16:12:30 +00:00
Eggcracking for better name finding & added better version digging
Added: - eggcracking to get plugin name - better version find mechanism
This commit is contained in:
parent
6e980a1580
commit
edc300a33d
@ -46,7 +46,7 @@ def getFileVersion(pluginName):
|
|||||||
if pluginVersionString.endswith('.'):
|
if pluginVersionString.endswith('.'):
|
||||||
pluginVersionString = ''
|
pluginVersionString = ''
|
||||||
if pluginVersionString == '':
|
if pluginVersionString == '':
|
||||||
pluginVersionString = eggCrackingJar(pluginNameFull)
|
pluginVersionString = eggCrackingJar(pluginNameFull, 'version')
|
||||||
return pluginVersionString
|
return pluginVersionString
|
||||||
|
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ def compareVersions(plugin_latest_version, pluginVersion):
|
|||||||
return plugin_is_outdated
|
return plugin_is_outdated
|
||||||
|
|
||||||
|
|
||||||
def eggCrackingJar(localJarFileName):
|
def eggCrackingJar(localJarFileName, searchMode):
|
||||||
configValues = configurationValues()
|
configValues = configurationValues()
|
||||||
if not configValues.localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
if configValues.sftp_useSftp:
|
if configValues.sftp_useSftp:
|
||||||
@ -82,21 +82,34 @@ def eggCrackingJar(localJarFileName):
|
|||||||
pluginPath = configValues.pathToPluginFolder
|
pluginPath = configValues.pathToPluginFolder
|
||||||
pathToPluginJar = Path(f"{pluginPath}/{localJarFileName}")
|
pathToPluginJar = Path(f"{pluginPath}/{localJarFileName}")
|
||||||
pluginVersion = ''
|
pluginVersion = ''
|
||||||
|
pluginName = ''
|
||||||
with ZipFile(pathToPluginJar, 'r') as pluginJar:
|
with ZipFile(pathToPluginJar, 'r') as pluginJar:
|
||||||
try:
|
try:
|
||||||
with io.TextIOWrapper(pluginJar.open('plugin.yml', 'r'), encoding="utf-8") as pluginYml:
|
with io.TextIOWrapper(pluginJar.open('plugin.yml', 'r'), encoding="utf-8") as pluginYml:
|
||||||
pluginYmlContentLine = pluginYml.readlines()
|
pluginYmlContentLine = pluginYml.readlines()
|
||||||
for line in pluginYmlContentLine:
|
for line in pluginYmlContentLine:
|
||||||
if "version: " in line:
|
if searchMode == 'version':
|
||||||
|
if re.match(r'^version: ', line):
|
||||||
pluginVersion = line.replace('version: ', '')
|
pluginVersion = line.replace('version: ', '')
|
||||||
pluginVersion = pluginVersion.replace('\n', '')
|
pluginVersion = pluginVersion.replace('\n', '')
|
||||||
break
|
pluginVersion = pluginVersion.replace("'", '')
|
||||||
|
pluginVersion = pluginVersion.replace('"', '')
|
||||||
|
elif searchMode == 'name':
|
||||||
|
if re.match(r'^name: ', line):
|
||||||
|
pluginName = line.replace('name: ', '')
|
||||||
|
pluginName = pluginName.replace('\n', '')
|
||||||
|
pluginName = pluginName.replace("'", '')
|
||||||
|
pluginName = pluginName.replace('"', '')
|
||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pluginVersion = ''
|
pluginVersion = ''
|
||||||
|
pluginName = ''
|
||||||
if not configValues.localPluginFolder:
|
if not configValues.localPluginFolder:
|
||||||
deleteTempPluginFolder(tempPluginFolderPath)
|
deleteTempPluginFolder(tempPluginFolderPath)
|
||||||
|
if searchMode == 'version':
|
||||||
return pluginVersion
|
return pluginVersion
|
||||||
|
if searchMode == 'name':
|
||||||
|
return pluginName
|
||||||
|
|
||||||
|
|
||||||
def checkInstalledPackage(inputSelectedObject="all"):
|
def checkInstalledPackage(inputSelectedObject="all"):
|
||||||
@ -122,7 +135,7 @@ def checkInstalledPackage(inputSelectedObject="all"):
|
|||||||
try:
|
try:
|
||||||
fileName = getFileName(plugin)
|
fileName = getFileName(plugin)
|
||||||
fileVersion = getFileVersion(plugin)
|
fileVersion = getFileVersion(plugin)
|
||||||
pluginId = getInstalledPlugin(fileName, fileVersion)
|
pluginId = getInstalledPlugin(fileName, fileVersion, plugin)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
continue
|
continue
|
||||||
pluginIdStr = str(pluginId)
|
pluginIdStr = str(pluginId)
|
||||||
@ -200,7 +213,7 @@ def updateInstalledPackage(inputSelectedObject='all'):
|
|||||||
try:
|
try:
|
||||||
fileName = getFileName(plugin)
|
fileName = getFileName(plugin)
|
||||||
fileVersion = getFileVersion(plugin)
|
fileVersion = getFileVersion(plugin)
|
||||||
pluginId = getInstalledPlugin(fileName, fileVersion)
|
pluginId = getInstalledPlugin(fileName, fileVersion, plugin)
|
||||||
latestVersion = getLatestPluginVersion(pluginId)
|
latestVersion = getLatestPluginVersion(pluginId)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
continue
|
continue
|
||||||
@ -331,11 +344,24 @@ def updateInstalledPackage(inputSelectedObject='all'):
|
|||||||
print(oColors.brightGreen + "All found plugins are on the latest version!" + oColors.standardWhite)
|
print(oColors.brightGreen + "All found plugins are on the latest version!" + oColors.standardWhite)
|
||||||
|
|
||||||
|
|
||||||
def getInstalledPlugin(localFileName, localFileVersion):
|
def getInstalledPlugin(localFileName, localFileVersion, localPluginFullName):
|
||||||
url = "https://api.spiget.org/v2/search/resources/" + localFileName + "?field=name&sort=-downloads"
|
url = "https://api.spiget.org/v2/search/resources/" + localFileName + "?field=name&sort=-downloads"
|
||||||
packageName = doAPIRequest(url)
|
packageName = doAPIRequest(url)
|
||||||
plugin_match_found = False
|
plugin_match_found = False
|
||||||
pluginID = None
|
pluginID = None
|
||||||
|
localFileVersionNew = localFileVersion
|
||||||
|
i = 0
|
||||||
|
for i in range(0, 3):
|
||||||
|
if plugin_match_found == True:
|
||||||
|
break
|
||||||
|
if i == 1:
|
||||||
|
localFileVersionNew = re.sub(r'(\-\w*)', '', localFileVersion)
|
||||||
|
if i == 2:
|
||||||
|
pluginNameinYML = eggCrackingJar(localPluginFullName, 'name')
|
||||||
|
url = "https://api.spiget.org/v2/search/resources/" + pluginNameinYML + "?field=name&sort=-downloads"
|
||||||
|
packageName = doAPIRequest(url)
|
||||||
|
localFileVersion = localFileVersionNew
|
||||||
|
|
||||||
for ressource in packageName:
|
for ressource in packageName:
|
||||||
if plugin_match_found == True:
|
if plugin_match_found == True:
|
||||||
break
|
break
|
||||||
@ -344,7 +370,7 @@ def getInstalledPlugin(localFileName, localFileVersion):
|
|||||||
packageVersions = doAPIRequest(url2)
|
packageVersions = doAPIRequest(url2)
|
||||||
for updates in packageVersions:
|
for updates in packageVersions:
|
||||||
updateVersion = updates["name"]
|
updateVersion = updates["name"]
|
||||||
if localFileVersion in updateVersion:
|
if localFileVersionNew in updateVersion:
|
||||||
plugin_match_found = True
|
plugin_match_found = True
|
||||||
pluginID = pID
|
pluginID = pID
|
||||||
updateId = updates["id"]
|
updateId = updates["id"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user