Skip to content

Commit

Permalink
Fallback thread version if not in api, full check it every 2 days (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy-JL committed Jan 27, 2024
1 parent 087694f commit 423a603
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
18 changes: 14 additions & 4 deletions modules/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)
Expand Down Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion modules/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 423a603

Please sign in to comment.