mirror of
https://github.com/Neocky/pluGET.git
synced 2024-04-29 16:12:30 +00:00
Made config path correct; Deleted unnecessary stuff; Beautified outpout; Plugin version now correct;
Changes: - config path will always be correct - deleted unnexessary stuff - plugin version will display now correct - changed some formating - created SFTP check before launching
This commit is contained in:
@@ -31,14 +31,6 @@ def handleRegexPackageName(packageNameFull):
|
||||
return packageNameOnly
|
||||
|
||||
|
||||
# TODO ununsed function
|
||||
def getlatestVersion(packageId):
|
||||
url = f"https://api.spiget.org/v2/resources/{packageId}/versions/latest"
|
||||
response = doAPIRequest(url)
|
||||
packageVersion = response["name"]
|
||||
return packageVersion
|
||||
|
||||
|
||||
def getVersionID(packageId, packageVersion):
|
||||
if packageVersion == None or packageVersion == 'latest':
|
||||
url = f"https://api.spiget.org/v2/resources/{packageId}/versions/latest"
|
||||
@@ -68,23 +60,27 @@ def searchPackage(ressourceName):
|
||||
url = f"https://api.spiget.org/v2/search/resources/{ressourceName}?field=name"
|
||||
packageName = doAPIRequest(url)
|
||||
i = 1
|
||||
print("Index / Name / Description / Downloads")
|
||||
print(f"Searching: {ressourceName}")
|
||||
print("Index | Name | Description | Downloads")
|
||||
for ressource in packageName:
|
||||
pName = ressource["name"]
|
||||
newName = handleRegexPackageName(pName)
|
||||
pTag = ressource["tag"]
|
||||
pDownloads = ressource["downloads"]
|
||||
print(f" [{i}] {pName} / {pTag}/ {pDownloads}")
|
||||
print(f" [{i}]".ljust(8), end='')
|
||||
print(f"{newName}".ljust(30), end='')
|
||||
print(f"{pTag}".ljust(120), end='')
|
||||
print(f"{pDownloads}".ljust(7))
|
||||
i = i + 1
|
||||
|
||||
ressourceSelected = int(input("Select your wanted Ressource: "))
|
||||
ressourceSelected = ressourceSelected - 1
|
||||
#fileInfo = packageName[ressourceSelected]["file"]
|
||||
#packageUrl = fileInfo["url"]
|
||||
ressourceId = packageName[ressourceSelected]["id"]
|
||||
if not checkConfig().localPluginFolder:
|
||||
getSpecificPackage(ressourceId, checkConfig().sftp_folderPath)
|
||||
else:
|
||||
getSpecificPackage(ressourceId, checkConfig().pathToPluginFolder)
|
||||
ressourceSelected = int(input("Select your wanted Ressource (Index)(0 to exit): "))
|
||||
if ressourceSelected != 0:
|
||||
ressourceSelected = ressourceSelected - 1
|
||||
ressourceId = packageName[ressourceSelected]["id"]
|
||||
if not checkConfig().localPluginFolder:
|
||||
getSpecificPackage(ressourceId, checkConfig().sftp_folderPath)
|
||||
else:
|
||||
getSpecificPackage(ressourceId, checkConfig().pathToPluginFolder)
|
||||
|
||||
|
||||
def downloadSpecificVersion(ressourceId, downloadPath, versionID='latest'):
|
||||
@@ -94,7 +90,7 @@ def downloadSpecificVersion(ressourceId, downloadPath, versionID='latest'):
|
||||
print(oColors.brightRed + "Reverting to latest version." + oColors.standardWhite)
|
||||
|
||||
url = f"https://api.spiget.org/v2/resources/{ressourceId}/download"
|
||||
#url = f"https://api.spiget.org/v2/resources/{ressourceId}/versions/latest/download" #throws 403 forbidden error
|
||||
#url = f"https://api.spiget.org/v2/resources/{ressourceId}/versions/latest/download" #throws 403 forbidden error...cloudflare :(
|
||||
|
||||
remotefile = urllib.request.urlopen(url)
|
||||
filesize = remotefile.info()['Content-Length']
|
||||
@@ -116,7 +112,6 @@ def getSpecificPackage(ressourceId, downloadPath, inputPackageVersion='latest'):
|
||||
packageNameNew = handleRegexPackageName(packageName)
|
||||
versionId = getVersionID(ressourceId, inputPackageVersion)
|
||||
packageVersion = getVersionName(ressourceId, versionId)
|
||||
#packageVersion = getlatestVersion(ressourceId)
|
||||
packageDownloadName = f"{packageNameNew}-{packageVersion}.jar"
|
||||
downloadPackagePath = f"{downloadPath}\\{packageDownloadName}"
|
||||
if checkConfig().localPluginFolder:
|
||||
@@ -145,7 +140,3 @@ def getSpecificPackage(ressourceId, downloadPath, inputPackageVersion='latest'):
|
||||
except HTTPError as err:
|
||||
print(oColors.brightRed + f"Error: {err.code} - {err.reason}" + oColors.standardWhite)
|
||||
|
||||
# get latest update > https://api.spiget.org/v2/resources/28140/updates/latest
|
||||
# this also > https://api.spiget.org/v2/resources/28140/versions/latest
|
||||
# get latest download with correct name > https://api.spiget.org/v2/resources/28140/versions/latest/download cloudflare protected
|
||||
# query for a plugin https://api.spiget.org/v2/search/resources/luckperms?field=name
|
||||
|
@@ -18,7 +18,7 @@ def addToPluginList(pluginId, versionId, plugin_latest_version, plugin_is_outdat
|
||||
INSTALLEDPLUGINLIST.append([pluginId, versionId, plugin_latest_version, plugin_is_outdated])
|
||||
|
||||
|
||||
def getFileName(pluginName): # TODO delete end of pluginName -v like BossShopPro-v
|
||||
def getFileName(pluginName):
|
||||
pluginNameFull = pluginName
|
||||
pluginVersion = re.search(r'([\d.]+[.jar]+)', pluginNameFull)
|
||||
try:
|
||||
@@ -27,7 +27,8 @@ def getFileName(pluginName): # TODO delete end of pluginName -v like BossShopPro
|
||||
pluginVersionFull = pluginVersion
|
||||
pluginNameOnlyy = pluginNameFull.replace(pluginVersionFull, '')
|
||||
pluginNameOnly = re.sub(r'(\-$)', '', pluginNameOnlyy)
|
||||
return pluginNameOnly
|
||||
pluginNameOnlyy = re.sub(r'(\-v$)', '', pluginNameOnly)
|
||||
return pluginNameOnlyy
|
||||
|
||||
|
||||
def getFileVersion(pluginName):
|
||||
@@ -217,7 +218,7 @@ def getInstalledPlugin(localFileName, localFileVersion):
|
||||
packageVersions = doAPIRequest(url2)
|
||||
for updates in packageVersions:
|
||||
updateVersion = updates["name"]
|
||||
if localFileVersion == updateVersion:
|
||||
if localFileVersion in updateVersion:
|
||||
plugin_match_found = True
|
||||
pluginID = pID
|
||||
updateId = updates["id"]
|
||||
|
Reference in New Issue
Block a user