Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement