Added version lookup for egg_cracking_jar

This commit is contained in:
Jan-Luca Bogdan | BEL NET GmbH 2022-06-29 16:00:55 +02:00
parent 9b2ff6e208
commit 0b10a76a3b
2 changed files with 12 additions and 8 deletions

View File

@ -143,7 +143,7 @@ def download_specific_plugin_version_spiget(plugin_id, download_path, version_id
file_size_data = convert_file_size_down(file_size) file_size_data = convert_file_size_down(file_size)
console.print(" [not bold][bright_green]Downloaded[bright_magenta] " + (str(file_size_data)).rjust(9) + \ console.print(" [not bold][bright_green]Downloaded[bright_magenta] " + (str(file_size_data)).rjust(9) + \
f" KB [cyan]→ [white]{download_path}") f" KB [cyan]→ [white]{download_path}")
# TODO add sftp and ftp support
if config_values.connection == "sftp": if config_values.connection == "sftp":
sftp_session = sftp_create_connection() sftp_session = sftp_create_connection()
sftp_upload_file(sftp_session, download_path) sftp_upload_file(sftp_session, download_path)

View File

@ -243,14 +243,11 @@ def egg_cracking_jar(plugin_file_name: str) -> str:
if re.match(r"^\s*?name: ", line): if re.match(r"^\s*?name: ", line):
plugin_name = re.sub(r'^\s*?name: ', '', line) plugin_name = re.sub(r'^\s*?name: ', '', line)
plugin_name = plugin_name.replace("\n", "").replace("'", "").replace('"', "") plugin_name = plugin_name.replace("\n", "").replace("'", "").replace('"', "")
#plugin_name = plugin_name.replace("'", '')
#plugin_name = plugin_name.replace('"', '')
if re.match(r"^\s*?version: ", line): if re.match(r"^\s*?version: ", line):
plugin_verson = re.sub(r'^\s*?version: ', '', line) plugin_version = re.sub(r'^\s*?version: ', "", line)
plugin_verson = plugin_verson.replace('\n', '').replace("'", "").replace('"', "") plugin_version = plugin_version.replace("\n", "").replace("'", "").replace('"', "")
#pluginVersion = pluginVersion.replace("'", '')
#pluginVersion = pluginVersion.replace('"', '')
except FileNotFoundError: except FileNotFoundError:
plugin_name = plugin_version = "" plugin_name = plugin_version = ""
except KeyError: except KeyError:
@ -523,7 +520,7 @@ def search_plugin_spiget(plugin_file: str, plugin_file_name: str, plugin_file_ve
url = f"https://api.spiget.org/v2/search/resources/{plugin_file_name}?field=name&sort=-downloads" url = f"https://api.spiget.org/v2/search/resources/{plugin_file_name}?field=name&sort=-downloads"
plugin_list = api_do_request(url) plugin_list = api_do_request(url)
plugin_file_version2 = plugin_file_version plugin_file_version2 = plugin_file_version
for i in range(3): for i in range(4):
if i == 1: if i == 1:
plugin_file_version2 = re.sub(r'(\-\w*)', '', plugin_file_version) plugin_file_version2 = re.sub(r'(\-\w*)', '', plugin_file_version)
if i == 2: if i == 2:
@ -537,6 +534,11 @@ def search_plugin_spiget(plugin_file: str, plugin_file_name: str, plugin_file_ve
if plugin_list is None: if plugin_list is None:
continue continue
# search with version which is in plugin.yml for the plugin
if i == 3:
plugin_file_version2 = plugin_version_in_yml
for plugin in plugin_list: for plugin in plugin_list:
plugin_id = plugin["id"] plugin_id = plugin["id"]
url2 = f"https://api.spiget.org/v2/resources/{plugin_id}/versions?size=100&sort=-name" url2 = f"https://api.spiget.org/v2/resources/{plugin_id}/versions?size=100&sort=-name"
@ -544,6 +546,8 @@ def search_plugin_spiget(plugin_file: str, plugin_file_name: str, plugin_file_ve
plugin_versions = api_do_request(url2) plugin_versions = api_do_request(url2)
except ValueError: except ValueError:
continue continue
if plugin_versions is None:
continue
for updates in plugin_versions: for updates in plugin_versions:
update_version_name = updates["name"] update_version_name = updates["name"]
if plugin_file_version2 in update_version_name: if plugin_file_version2 in update_version_name: