feat: add job progress, retry and rotating logs
This commit is contained in:
1 parent
626650e44a
commit
c441d770e2
16 files changed
+297
-72
No files matched your search
+37
-33
@@ -129,12 +129,14 @@ def main():
|
||||
|
||||
existing_ids = {r["appid"] for r in con.execute("SELECT appid FROM games")}
|
||||
imported = new_count = updated_count = 0
|
||||
total_apps = len(lib_ids)
|
||||
report_every = max(1, total_apps // 20)
|
||||
with con:
|
||||
if new_tags:
|
||||
con.executemany("INSERT OR REPLACE INTO tag_names (tag_id, name) VALUES (?, ?)",
|
||||
new_tags.items())
|
||||
|
||||
for appid in lib_ids:
|
||||
for index, appid in enumerate(lib_ids, 1):
|
||||
pt = playtime.get(appid)
|
||||
inst = installed.get(appid)
|
||||
is_new = appid not in existing_ids
|
||||
@@ -143,39 +145,41 @@ def main():
|
||||
write_playtime(appid, pt)
|
||||
write_install(appid, inst)
|
||||
updated_count += 1
|
||||
continue
|
||||
|
||||
info = appinfo.get(appid, {})
|
||||
name = info.get("name") or installed.get(appid, {}).get("name") or f"App {appid}"
|
||||
upsert_game((appid, name, info.get("type"), iso_from_unix(info.get("release")),
|
||||
info.get("metacritic"), info.get("review_pct"), now))
|
||||
|
||||
genre_ids = info.get("genres") or {}
|
||||
con.execute("DELETE FROM game_genres WHERE appid = ?", (appid,))
|
||||
con.executemany(
|
||||
"INSERT OR IGNORE INTO game_genres (appid, genre) VALUES (?, ?)",
|
||||
[(appid, steam_source.GENRES.get(v, f"Genre {v}")) for v in genre_ids.values()
|
||||
if isinstance(v, int) and v not in steam_source.SKIP_GENRE_IDS],
|
||||
)
|
||||
|
||||
tag_ids = info.get("tags") or {}
|
||||
con.execute("DELETE FROM game_tags WHERE appid = ?", (appid,))
|
||||
con.executemany(
|
||||
"INSERT OR IGNORE INTO game_tags (appid, tag_id) VALUES (?, ?)",
|
||||
[(appid, v) for v in tag_ids.values() if isinstance(v, int)],
|
||||
)
|
||||
|
||||
write_playtime(appid, pt)
|
||||
write_install(appid, inst)
|
||||
|
||||
default_status = "played" if pt and pt["minutes"] > 0 else "backlog"
|
||||
con.execute("INSERT OR IGNORE INTO personal (appid, status, updated_at) VALUES (?, ?, ?)",
|
||||
(appid, default_status, now))
|
||||
imported += 1
|
||||
if is_new:
|
||||
new_count += 1
|
||||
else:
|
||||
updated_count += 1
|
||||
info = appinfo.get(appid, {})
|
||||
name = info.get("name") or installed.get(appid, {}).get("name") or f"App {appid}"
|
||||
upsert_game((appid, name, info.get("type"), iso_from_unix(info.get("release")),
|
||||
info.get("metacritic"), info.get("review_pct"), now))
|
||||
|
||||
genre_ids = info.get("genres") or {}
|
||||
con.execute("DELETE FROM game_genres WHERE appid = ?", (appid,))
|
||||
con.executemany(
|
||||
"INSERT OR IGNORE INTO game_genres (appid, genre) VALUES (?, ?)",
|
||||
[(appid, steam_source.GENRES.get(v, f"Genre {v}")) for v in genre_ids.values()
|
||||
if isinstance(v, int) and v not in steam_source.SKIP_GENRE_IDS],
|
||||
)
|
||||
|
||||
tag_ids = info.get("tags") or {}
|
||||
con.execute("DELETE FROM game_tags WHERE appid = ?", (appid,))
|
||||
con.executemany(
|
||||
"INSERT OR IGNORE INTO game_tags (appid, tag_id) VALUES (?, ?)",
|
||||
[(appid, v) for v in tag_ids.values() if isinstance(v, int)],
|
||||
)
|
||||
|
||||
write_playtime(appid, pt)
|
||||
write_install(appid, inst)
|
||||
|
||||
default_status = "played" if pt and pt["minutes"] > 0 else "backlog"
|
||||
con.execute("INSERT OR IGNORE INTO personal (appid, status, updated_at) VALUES (?, ?, ?)",
|
||||
(appid, default_status, now))
|
||||
imported += 1
|
||||
if is_new:
|
||||
new_count += 1
|
||||
else:
|
||||
updated_count += 1
|
||||
|
||||
if index % report_every == 0 or index == total_apps:
|
||||
print(f" {index}/{total_apps} apps", flush=True)
|
||||
|
||||
con.execute("""UPDATE personal SET status = 'played'
|
||||
WHERE status = 'backlog'
|
||||
|
||||
Reference in new issue
Block a user