Add games.parent_appid (schema v9), parse appinfo parent links, show addons and parent game in the card, and add import_steam.py --refresh-parents for existing databases.
This commit is contained in:
1 parent
376a2ee7a0
commit
528fcb7474
18 files changed
+135
-11
No files matched your search
+23
-3
@@ -49,6 +49,8 @@ def main():
|
||||
ap.add_argument("--incremental", action="store_true",
|
||||
help="only add new apps; update install/playtime for existing")
|
||||
ap.add_argument("--no-network", action="store_true", help="never download tag names")
|
||||
ap.add_argument("--refresh-parents", action="store_true",
|
||||
help="update games.parent_appid from appinfo and exit")
|
||||
args = ap.parse_args()
|
||||
|
||||
root = args.steam_root or steam_source.find_steam_root()
|
||||
@@ -80,6 +82,21 @@ def main():
|
||||
db.init(con)
|
||||
db.seed_moods(con)
|
||||
|
||||
if args.refresh_parents:
|
||||
updated = 0
|
||||
for appid, info in appinfo.items():
|
||||
parent = info.get("parent")
|
||||
if not parent:
|
||||
continue
|
||||
cursor = con.execute(
|
||||
"UPDATE games SET parent_appid = ? WHERE appid = ? AND "
|
||||
"COALESCE(parent_appid, 0) <> ?", (parent, appid, parent))
|
||||
updated += max(0, cursor.rowcount)
|
||||
con.commit()
|
||||
print(f"Parents updated: {updated}")
|
||||
con.close()
|
||||
return
|
||||
|
||||
existing_tags = {r["tag_id"]: r["name"] for r in con.execute("SELECT tag_id, name FROM tag_names")}
|
||||
new_tags = {}
|
||||
if not args.no_network and (args.refresh_tags or len(existing_tags) < 50):
|
||||
@@ -93,12 +110,14 @@ def main():
|
||||
|
||||
def upsert_game(row):
|
||||
con.execute(
|
||||
"""INSERT INTO games (appid, name, type, release_date, metacritic, review_pct, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
"""INSERT INTO games (appid, name, type, release_date, metacritic, review_pct,
|
||||
parent_appid, updated_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||
ON CONFLICT(appid) DO UPDATE SET
|
||||
name = excluded.name, type = excluded.type,
|
||||
release_date = COALESCE(excluded.release_date, games.release_date),
|
||||
metacritic = excluded.metacritic, review_pct = excluded.review_pct,
|
||||
parent_appid = COALESCE(excluded.parent_appid, games.parent_appid),
|
||||
updated_at = excluded.updated_at""",
|
||||
row,
|
||||
)
|
||||
@@ -150,7 +169,8 @@ def main():
|
||||
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))
|
||||
info.get("metacritic"), info.get("review_pct"),
|
||||
info.get("parent"), now))
|
||||
|
||||
genre_ids = info.get("genres") or {}
|
||||
con.execute("DELETE FROM game_genres WHERE appid = ?", (appid,))
|
||||
|
||||
Reference in new issue
Block a user