From 3bcb3de4cf33d2111a39b8e82f884e46fe9a602e Mon Sep 17 00:00:00 2001 From: Neocky Date: Thu, 26 Aug 2021 19:24:17 +0200 Subject: [PATCH] Fixed error when searching for plugins Changes: - fixed bug when searching for plugins where the name couldn't be sanitized - fixed bug when searching for plugins with numbers in name --- src/plugin/plugin_downloader.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/plugin/plugin_downloader.py b/src/plugin/plugin_downloader.py index 805ca12..246bc4a 100644 --- a/src/plugin/plugin_downloader.py +++ b/src/plugin/plugin_downloader.py @@ -21,8 +21,11 @@ def handleRegexPackageName(packageNameFull): packageNameFull2 = packageNameFull.replace(unwantedpackageNameString, '') # gets the real packagename "word1 & word2" is not supported only gets word 1 packageName = re.search(r'([a-zA-Z]\d*)+(\s?\-*\_*[a-zA-Z]\d*\+*\-*\'*)+', packageNameFull2) - packageNameFullString = packageName.group() - packageNameOnly = packageNameFullString.replace(' ', '') + try: + packageNameFullString = packageName.group() + packageNameOnly = packageNameFullString.replace(' ', '') + except AttributeError: + packageNameOnly = unwantedpackageNameString return packageNameOnly @@ -133,7 +136,11 @@ def getSpecificPackage(resourceId, downloadPath, inputPackageVersion='latest'): downloadPath = createTempPluginFolder() url = f"https://api.spiget.org/v2/resources/{resourceId}" packageDetails = doAPIRequest(url) - packageName = packageDetails["name"] + try: + packageName = packageDetails["name"] + except KeyError: + print(oColors.brightRed + "Error: Plugin ID couldn't be found" + oColors.standardWhite) + return None packageNameNew = handleRegexPackageName(packageName) versionId = getVersionID(resourceId, inputPackageVersion) packageVersion = getVersionName(resourceId, versionId)