Skip to content

Commit e96df46

Browse files
committed
fix some games aren't showing
1 parent 93ead0f commit e96df46

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

src/workers/indexdownloadworker.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <QJsonArray>
1212
#include <QFile>
1313
#include <QDir>
14+
#include <QUrlQuery>
1415

1516
IndexDownloadWorker::IndexDownloadWorker(QObject* parent)
1617
: QThread(parent)
@@ -84,6 +85,61 @@ void IndexDownloadWorker::run() {
8485
games.append({obj["id"].toString(), obj["name"].toString()});
8586
}
8687

88+
// Client-side Fallback: Check for missing/unknown names and fetch from Store API
89+
int missingCount = 0;
90+
for (const auto& game : games) {
91+
if (game.name.isEmpty() || game.name.startsWith("Unknown Game") || game.name == game.id) {
92+
missingCount++;
93+
}
94+
}
95+
96+
if (missingCount > 0 && missingCount < 50) { // Limit to avoid massive delays if everything is broken
97+
emit progress(QString("Fetching details for %1 games...").arg(missingCount));
98+
QNetworkAccessManager storeMgr;
99+
100+
for (auto& game : games) {
101+
if (game.name.isEmpty() || game.name.startsWith("Unknown Game") || game.name == game.id) {
102+
QUrl storeUrl("https://store.steampowered.com/api/appdetails");
103+
QUrlQuery query;
104+
query.addQueryItem("appids", game.id);
105+
query.addQueryItem("filters", "basic");
106+
storeUrl.setQuery(query);
107+
108+
QNetworkRequest req(storeUrl);
109+
req.setHeader(QNetworkRequest::UserAgentHeader, "SteamLuaPatcher/2.0");
110+
111+
QEventLoop storeLoop;
112+
QNetworkReply* storeReply = storeMgr.get(req);
113+
// Simple timeout to prevent hanging forever
114+
QTimer storeTimer;
115+
storeTimer.setSingleShot(true);
116+
connect(&storeTimer, &QTimer::timeout, &storeLoop, &QEventLoop::quit);
117+
connect(storeReply, &QNetworkReply::finished, &storeLoop, &QEventLoop::quit);
118+
storeTimer.start(5000);
119+
120+
storeLoop.exec();
121+
122+
if (storeReply->error() == QNetworkReply::NoError) {
123+
QJsonDocument storeDoc = QJsonDocument::fromJson(storeReply->readAll());
124+
QJsonObject storeRoot = storeDoc.object();
125+
if (storeRoot.contains(game.id)) {
126+
QJsonObject appData = storeRoot[game.id].toObject();
127+
if (appData["success"].toBool()) {
128+
QString newName = appData["data"].toObject()["name"].toString();
129+
if (!newName.isEmpty()) {
130+
game.name = newName;
131+
}
132+
}
133+
}
134+
}
135+
storeReply->deleteLater();
136+
137+
// Polite delay
138+
QThread::msleep(200);
139+
}
140+
}
141+
}
142+
87143
emit finished(games);
88144

89145

0 commit comments

Comments
 (0)