DeaD_EyE icon

Steam: show state of fossilize_replay (tested on Linux) with logfile

DeaD_EyE | PRO | 05/04/24 12:44:51 PM UTC (Edited) | 0 ⭐ | 1423 👁️ | Never ⏰ | []
Python |

1.55 KB

|

None

|

0 👍

/

0 👎

import re
import time
from datetime import datetime as DateTime
from functools import cache
from pathlib import Path
 
import requests
 
reg = re.compile(r"\[(?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2}) (?P<hour>\d{2}):(?P<minute>\d{2}):(?P<second>\d{2})\] Still replaying (?P<appid>\d+) \(\d{2}%, (?P<done>\d+)\/(?P<total>\d+)\)")
 
 
@cache
def appids():
    return {
        app["appid"]: app["name"]
        for app in requests.get(
            "https://api.steampowered.com/ISteamApps/GetAppList/v2/"
        ).json()["applist"]["apps"]
    }
 
 
def names_shadercache():
    return [appids()[appid] for appid in appids_shadercache()]
 
 
def mktime(result: dict) -> DateTime:
    return DateTime(
        *(
            int(result[name])
            for name in ("year", "month", "day", "hour", "minute", "second")
        )
    )
 
 
def read_log():
    with Path.home().joinpath(".local/share/Steam/logs/shader_log.txt").open() as fd:
        while True:
            line = fd.readline().rstrip()
            if not line:
                continue
            if match := reg.search(line):
                result = match.groupdict()
                dt = mktime(result)
                game = appids().get(int(result["appid"]), "Unknown")
                progress = int(result["done"]) / int(result["total"])
                print("\033c", end="")
                print(f"[{dt}] [{progress:06.2%}] {game}")
 
                
if __name__ == "__main__":
    read_log()
 
 
# [2024-05-04 13:57:35] Still replaying 730 (80%, 1572280/1941272).
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎