From 68ad8fe0dd6a387d14fb50ee39943c20f35a6356 Mon Sep 17 00:00:00 2001 From: JoYo <> Date: Sat, 15 Jul 2023 17:46:26 -0400 Subject: [PATCH] fix for LibAddonMenu using stupid versioning --- README.mdown | 6 +++--- banana.py | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/README.mdown b/README.mdown index 2a2a503..0aebf95 100644 --- a/README.mdown +++ b/README.mdown @@ -27,7 +27,7 @@ Follow the installation instructions for your `platform`: - [Windows](#windows-installation) - [Linux](#linux-installation) -On first run, the `addons.text` file will be created in your ESO live directory. +On first run, the `addons.list` file will be created in your ESO live directory. It will look similar to the following: ``` @@ -117,12 +117,12 @@ sudo systemctl enable banana.timer sudo systemctl enable banana.service ``` -3. Now that `eso-banana-script` has been installed, run it once to create the `addons.text` file. +3. Now that `eso-banana-script` has been installed, run it once to create the `addons.list` file. If the mentioned command is missing your may need to restart the TTY. 4. The created file can be edited with vim to include additional adddon URLs at the following path. -`vim "~/.steam/steam/steamapps/compatdata/306130/pfx/drive_c/users/steamuser/Documents/Elder Scrolls Online/live/addons.text"` +`vim "~/.steam/steam/steamapps/compatdata/306130/pfx/drive_c/users/steamuser/Documents/Elder Scrolls Online/live/addons.list"` It will look similar to the following: diff --git a/banana.py b/banana.py index 54e0829..38d6eab 100644 --- a/banana.py +++ b/banana.py @@ -6,6 +6,7 @@ from pathlib import Path from platform import system from shutil import rmtree, copytree from tempfile import TemporaryDirectory +from typing import Tuple from zipfile import ZipFile import logging import re @@ -40,6 +41,7 @@ def live_to_esoui(*, path: Path, esoui_uris: list): esoui_name, esoui_version, esoui_uri = _name, _version, _uri break + if not esoui_name: rmtree(live_path) logging.info(f"{live_name} addon removed from: {live_path}") @@ -113,7 +115,7 @@ live_version = re.compile("##\s+Version:\s+.*") live_version_split = re.compile("##\s+Version:\s+") -def esoui_parse(url: str): +def esoui_parse(url: str) -> Tuple[str, version.Version, str]: addon_name = esoui_prefix.split(url)[1] addon_name = addon_name.split(".html")[0] @@ -122,7 +124,11 @@ def esoui_parse(url: str): version_line = esoui_version_html.search(response.text).group(0) _version = esoui_version_split.split(version_line)[1] - _version = version.parse(_version) + try: + _version = version.parse(_version) + except version.InvalidVersion: + _version = version.parse("1") + return esoui_page_url = url.replace("info", "download").replace(".html", "") @@ -161,7 +167,10 @@ def parsing_live(path: Path): if result: _version = result.group(0) _version = live_version_split.split(_version)[1] - _version = version.parse(_version) + try: + _version = version.parse(_version) + except version.InvalidVersion: + _version = version.parse("0") else: _version = version.parse("0") @@ -228,7 +237,7 @@ def periodical_script(): logging.info(args) - config_path = Path(args.eso_live_path).joinpath("addons.text") + config_path = Path(args.eso_live_path).joinpath("addons.list") if not config_path.exists(): config_new(config_path) @@ -244,7 +253,8 @@ def periodical_script(): for url in config_current: esoui = esoui_parse(url) - esoui_uris.append(esoui) + if esoui: + esoui_uris.append(esoui) for child in live_path.iterdir(): live_to_esoui(path=child, esoui_uris=esoui_uris)