fix(time_utils): make playtime parsing robust to malformed data
All checks were successful
Code check / Check code (push) Successful in 1m16s

Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
This commit is contained in:
2026-01-13 14:13:30 +05:00
parent 5f3a451c50
commit dd65021976

View File

@@ -94,8 +94,13 @@ def parse_playtime_file(file_path):
if len(parts) < 3:
continue
exe_path = parts[0]
seconds = int(parts[2])
playtime_data[exe_path] = seconds
# Find playtime: first numeric value after exe_path
# Format: <exe_path> <hash> <playtime_seconds> <platform> ...
# Hash is 64 hex chars, playtime is digits only
for i in range(1, len(parts)):
if parts[i].isdigit():
playtime_data[exe_path] = int(parts[i])
break
return playtime_data
def format_playtime(seconds):