diff --git a/src/handlers/handle_ftp.py b/src/handlers/handle_ftp.py index 774b07d..27fbebb 100644 --- a/src/handlers/handle_ftp.py +++ b/src/handlers/handle_ftp.py @@ -101,8 +101,7 @@ def ftp_validateFileAttributes(ftp, pluginPath): pluginFTPAttribute = ftp.lstat(pluginPath) if stat.S_ISDIR(pluginFTPAttribute.st_mode): return False - if stat.S_ISDIR(pluginFTPAttribute.st_mode): - if re.search(r'.jar$', pluginFTPAttribute.filename): - return True - else: - return False + elif re.search(r'.jar$', pluginPath): + return True + else: + return False diff --git a/src/handlers/handle_sftp.py b/src/handlers/handle_sftp.py index 7b15380..df5e71a 100644 --- a/src/handlers/handle_sftp.py +++ b/src/handlers/handle_sftp.py @@ -97,8 +97,7 @@ def sftp_validateFileAttributes(sftp, pluginPath): pluginSFTPAttribute = sftp.lstat(pluginPath) if stat.S_ISDIR(pluginSFTPAttribute.st_mode): return False - if stat.S_ISDIR(pluginSFTPAttribute.st_mode): - if re.search(r'.jar$', pluginSFTPAttribute.filename): - return True - else: - return False + elif re.search(r'.jar$', pluginPath): + return True + else: + return False diff --git a/src/plugin/plugin_updatechecker.py b/src/plugin/plugin_updatechecker.py index 12874bd..350f32a 100644 --- a/src/plugin/plugin_updatechecker.py +++ b/src/plugin/plugin_updatechecker.py @@ -3,6 +3,7 @@ import re import io import stat import pysftp +import base64 from zipfile import ZipFile from urllib.error import HTTPError from pathlib import Path @@ -114,6 +115,25 @@ def eggCrackingJar(localJarFileName, searchMode): return pluginName +def getUpdateDescription(pluginId): + url = f"https://api.spiget.org/v2/resources/{pluginId}/updates?size=1&sort=-date" + latestDescriptionSearch = doAPIRequest(url) + versionLatestDescription = latestDescriptionSearch[0]["description"] + versionLatestDescription = base64.b64decode(versionLatestDescription) + versionLatestDescriptionText =versionLatestDescription.decode('utf-8') + htmlRegex = re.compile('<.*?>') + versionLatestDescriptionText = re.sub(htmlRegex, '', versionLatestDescriptionText) + lines = versionLatestDescriptionText.split("\n") + non_empty_lines = [line for line in lines if line.strip() != ""] + string_without_empty_lines = "" + for line in non_empty_lines: + string_without_empty_lines += line + "\n" + return string_without_empty_lines + + + + + def checkInstalledPackage(inputSelectedObject="all"): configValues = configurationValues() createPluginList() @@ -154,7 +174,6 @@ def checkInstalledPackage(inputSelectedObject="all"): continue if not re.search(r'.jar$', plugin): continue - try: fileName = getFileName(plugin) fileVersion = getFileVersion(plugin) @@ -209,6 +228,8 @@ def checkInstalledPackage(inputSelectedObject="all"): print(f"{fileVersion}".ljust(15), end='') print(f"{pluginLatestVersion}".ljust(15), end='') print(f"{pluginIsOutdated}".ljust(5) + oColors.standardWhite) + description = getUpdateDescription(pluginId) + print(description) i += 1 except TypeError: