From 423a603a9c7cea356e518181126abbaadb3a7fb8 Mon Sep 17 00:00:00 2001 From: Willy-JL <49810075+Willy-JL@users.noreply.github.com> Date: Sat, 27 Jan 2024 00:32:40 +0000 Subject: [PATCH] Fallback thread version if not in api, full check it every 2 days (#106) --- modules/api.py | 18 ++++++++++++++---- modules/parser.py | 9 ++++++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/modules/api.py b/modules/api.py index 3af7f1da..b781a378 100644 --- a/modules/api.py +++ b/modules/api.py @@ -64,6 +64,7 @@ updating = False session: aiohttp.ClientSession = None full_interval = int(dt.timedelta(days=7).total_seconds()) +part_interval = int(dt.timedelta(days=2).total_seconds()) webpage_prefix = "F95Checker-Temp-" fast_checks_sem: asyncio.Semaphore = None full_checks_sem: asyncio.Semaphore = None @@ -537,12 +538,16 @@ async def fast_check(games: list[Game], full_queue: list[tuple[Game, str]]=None, version = versions.get(str(game.id)) if not version or version == "Unknown": - version = "N/A" + version = None + # Full check games with no version data more often + interval = part_interval + else: + interval = full_interval this_full = full or ( - version != game.version or game.status is Status.Unchecked or - (game.last_full_check < time.time() - full_interval) or + (version and version != game.version) or + (game.last_full_check < time.time() - interval) or (game.image.missing and game.image_url != "missing") or last_check_before("10.1.1", game.last_check_version) # Switch away from HEAD requests, new version parsing ) @@ -604,7 +609,12 @@ async def full_check(game: Game, version: str): ret = parse(*args) if isinstance(ret, parser.ParserException): raise msgbox.Exc(*ret.args, **ret.kwargs) - (name, developer, type, status, last_updated, score, description, changelog, tags, image_url, downloads) = ret + (name, thread_version, developer, type, status, last_updated, score, description, changelog, tags, image_url, downloads) = ret + if not version: + if thread_version: + version = thread_version + else: + version = "N/A" breaking_name_parsing = last_check_before("9.6.4", game.last_check_version) # Skip name change in update popup breaking_version_parsing = last_check_before("10.1.1", game.last_check_version) # Skip update popup and keep installed/finished checkboxes diff --git a/modules/parser.py b/modules/parser.py index 89391836..c98788b2 100644 --- a/modules/parser.py +++ b/modules/parser.py @@ -177,6 +177,13 @@ def add_downloads(): name += elem.text name = fixed_spaces(sanitize_whitespace(re.search(r"^\s*(.*?)(?:\s*\[.*?\]\s*)*$", name).group(1))) + thread_version = get_game_attr("version", "game version", "mod version") + if not thread_version: + if match := re.search(r"(?:\[.+?\] - )*.+?\[(.+?)\]", html.title.text): + thread_version = fixed_spaces(sanitize_whitespace(match.group(1))) + if not thread_version: + thread_version = None + developer = get_game_attr( "developer/publisher", "developer & publisher", @@ -332,7 +339,7 @@ def add_downloads(): else: return e - ret = (name, developer, type, status, last_updated, score, description, changelog, tags, image_url, downloads) + ret = (name, thread_version, developer, type, status, last_updated, score, description, changelog, tags, image_url, downloads) if pipe: pipe.put_nowait(ret) else: