Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/CONFIGINI.md
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,13 @@ or
userCreds="<Client-ID>:<Client-Secret>"
```

or

```ini
[thegamesdb]
userCreds="<your-private-api-key-of-64chars>"
```

Default value: unset
Allowed in sections: `[<SCRAPER>]`

Expand Down
4 changes: 2 additions & 2 deletions docs/SCRAPINGMODULES.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ I strongly recommend supporting them by contributing data to the database, or by
- Website: _[www.thegamesdb.net](http://www.thegamesdb.net)_
- Type: _File name search based_
- User credential support: _Not required_
- API request limit: _Limited to 3000 requests per IP per month_
- API request limit: _Limited to 1000 requests per IP per month_
- Thread limit: _None_
- Platform support: _[Link to list](https://thegamesdb.net/list_platforms.php) or see `tgdb_platforms.json` sibling to your `config.ini`_
- Media support: `backcover`, `cover`, `fanart`, `marquee`, `screenshot`, `wheel`
Expand All @@ -107,7 +107,7 @@ I strongly recommend supporting them by contributing data to the database, or by

For newer games there's no way around TheGames DB. It recently had a huge redesign and their database remains one of the best out there. I would recommend scraping your roms with `screenscraper` first, and then use `thegamesdb` to fill out the gaps in your cache.

There's a small caveat to this module, as it has a monthly request limit (see above) per IP per month. But this should be plenty for most people.
There's a small caveat to this module, as it has a monthly request limit (see above) per IP per month. As per Feb 17th of 2026 TGDB have changed they API usage policy: You may have to register for your private API key to increase the above limits. Put your private API key then in the [`userCreds=`](CONFIGINI.md#usercreds) section of `[thegamesdb]`, or use the `-u` option when scraping with this module.

Their API is based on a file name search. This means that the returned results do have a chance of being faulty. Skyscraper does a lot internally to make sure accepted data is for the correct game. But it is impossible to ensure 100% correct results, so do keep that in mind when using it. Consider using the `--flags interactive` command line flag if you want complete control of the accepted entries.

Expand Down
61 changes: 36 additions & 25 deletions src/thegamesdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,9 @@ void TheGamesDb::getSearchResults(QList<GameEntry> &gameEntries,
pIds.append(QString::number(p));
}
}

QString req =
searchUrlPre +
StrTools::unMagic(
"187;161;217;126;172;149;202;122;163;197;163;219;162;171;203;197;"
"139;151;215;173;122;206;161;162;200;216;217;123;124;215;200;170;"
"171;132;158;155;215;120;149;169;140;164;122;154;178;174;160;172;"
"157;131;210;161;203;137;159;117;205;166;162;139;171;169;210;163") +
"&name=" + searchName + "&filter[platform]=" + pIds.join(",");
QString k = getKey();
QString req = searchUrlPre + k + "&name=" + searchName +
"&filter[platform]=" + pIds.join(",");
netComm->request(req);
q.exec();
data = netComm->getData();
Expand All @@ -84,14 +78,25 @@ void TheGamesDb::getSearchResults(QList<GameEntry> &gameEntries,
return;
}

reqRemaining = jsonDoc.object()["remaining_monthly_allowance"].toInt();
QString status = jsonDoc.object()["status"].toString();
if (status != "Success") {
QString code = jsonDoc.object()["code"].toString();
if (code != "200") {
printf("\033[1;31mServer response HTTP %s: %s\033[0m\n",
code.toStdString().c_str(), status.toStdString().c_str());
}
return;
}
QJsonObject obj = jsonDoc.object();
reqRemaining = obj["extra_allowance"].toInt();
if (reqRemaining <= 0) {
reqRemaining = obj["remaining_monthly_allowance"].toInt();
}
if (reqRemaining <= 0)
printf("\033[1;31mYou've reached TheGamesdDb's request limit for this "
"month.\033[0m\n");
"month with %s API key.\033[0m\n",
config->userCreds.isEmpty() ? "the public" : "your private");

if (jsonDoc.object()["status"].toString() != "Success") {
return;
}
if (jsonDoc.object()["data"].toObject()["count"].toInt() < 1) {
return;
}
Expand All @@ -109,17 +114,11 @@ void TheGamesDb::getSearchResults(QList<GameEntry> &gameEntries,
GameEntry game;

game.id = QString::number(jsonGame["id"].toInt());
game.url =
QString("%1/Games/ByGameID?id=%2&apikey=%3&fields=%4")
.arg(baseUrl)
.arg(game.id)
.arg(QString(StrTools::unMagic(
"187;161;217;126;172;149;202;122;163;197;163;219;162;"
"171;203;197;139;151;215;173;122;206;161;162;200;216;"
"217;123;124;215;200;170;171;132;158;155;215;120;149;"
"169;140;164;122;154;178;174;160;172;157;131;210;161;"
"203;137;159;117;205;166;162;139;171;169;210;163")))
.arg(fields.join(","));
game.url = QString("%1/Games/ByGameID?id=%2&apikey=%3&fields=%4")
.arg(baseUrl)
.arg(game.id)
.arg(k)
.arg(fields.join(","));

game.title = jsonGame["game_title"].toString();
// Remove anything at the end with a parentheses. 'thegamesdb' has a
Expand Down Expand Up @@ -301,4 +300,16 @@ void TheGamesDb::loadMaps() {

QVector<int> TheGamesDb::getPlatformId(const QString platform) {
return Platform::get().getPlatformIdOnScraper(platform, config->scraper);
}

QString TheGamesDb::getKey() {
QString k = config->userCreds;
if (k.isEmpty()) {
k = StrTools::unMagic(
"189;159;218;132;218;153;203;170;166;155;168;177;211;217;203;153;"
"137;152;167;175;126;161;209;162;150;165;216;128;173;168;149;169;"
"213;137;203;161;163;170;196;215;182;168;118;156;132;171;202;165;"
"153;177;168;208;155;134;212;166;164;163;161;184;168;163;160;211");
}
return k;
}
1 change: 1 addition & 0 deletions src/thegamesdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class TheGamesDb : public AbstractScraper {
void getFanart(GameEntry &game) override;
void getBackcover(GameEntry &game) override;
QVector<int> getPlatformId(const QString platform) override;
QString getKey();

QString gfxUrl;
QJsonDocument jsonDoc;
Expand Down
Loading