Skip to content

Commit

Permalink
Fix a few more issues with the scraper
Browse files Browse the repository at this point in the history
  • Loading branch information
dh4 committed Jul 30, 2018
1 parent 604d73e commit c4cf014
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 32 deletions.
24 changes: 12 additions & 12 deletions resources/locale/mupen64plus-qt_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,24 +512,24 @@
<translation>%1 - MB</translation>
</message>
<message>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="247"/>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="320"/>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="360"/>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="249"/>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="322"/>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="362"/>
<source>Game Information Download</source>
<translation>Télécharger des informations sur le jeu</translation>
</message>
<message>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="316"/>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="318"/>
<source>No results found.</source>
<translation>Aucun résultat.</translation>
</message>
<message>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="318"/>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="320"/>
<source>No more results found.</source>
<translation>Pas d&apos;autre résultat.</translation>
</message>
<message>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="361"/>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="363"/>
<source>Download Complete!</source>
<translation>Téléchargement terminé !</translation>
</message>
Expand Down Expand Up @@ -1101,33 +1101,33 @@
<translation>Effacer les informations du jeu</translation>
</message>
<message>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="221"/>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="223"/>
<source>The following error from TheGamesDB occured while downloading:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="244"/>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="246"/>
<source>Released on: </source>
<translation>Publié le :</translation>
</message>
<message>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="245"/>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="247"/>
<source>Does this look correct?</source>
<translation>Ces informations vous semblent-elles correctes ?</translation>
</message>
<message>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="400"/>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="402"/>
<source>Request timed out. Check your network settings.</source>
<translation>Temps dépassé. Vérifier vos paramètres de connexion.</translation>
</message>
<message>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="408"/>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="410"/>
<source>Continue scraping information?</source>
<translation>Continuer à récolter des informations ?</translation>
</message>
<message>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="411"/>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="413"/>
<location filename="../../src/roms/thegamesdbscraper.cpp" line="415"/>
<source>Network Error</source>
<translatorcomment>Erreur réseau</translatorcomment>
<translation>Erreur réseau</translation>
Expand Down
44 changes: 24 additions & 20 deletions src/roms/thegamesdbscraper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,22 +182,24 @@ void TheGamesDBScraper::downloadGameInfo(QString identifier, QString searchName,
searchName.remove(QRegExp("\\W*(\\(|\\[).+(\\)|\\])\\W*"));

//Few game specific hacks
//TODO: Contact thegamesdb.net and see if these can be fixed on their end
if (searchName == "Legend of Zelda, The - Majora's Mask")
if (searchName == "Legend of Zelda, The - Majora's Mask" ||
searchName == "ZELDA MAJORA'S MASK")
searchName = "Majora's Mask";
else if (searchName == "Legend of Zelda, The - Ocarina of Time" ||
searchName == "THE LEGEND OF ZELDA")
searchName = "The Legend of Zelda: Ocarina of Time";
else if (searchName == "Tsumi to Batsu - Hoshi no Keishousha")
else if (searchName.toLower().startsWith("tsumi to batsu"))
searchName = "Sin and Punishment";
else if (searchName == "1080 Snowboarding")
else if (searchName.toLower() == "1080 snowboarding")
searchName = "1080: TenEighty Snowboarding";
else if (searchName == "Extreme-G XG2")
else if (searchName == "Extreme-G XG2" || searchName == "Extreme G 2")
searchName = "Extreme-G 2";
else if (searchName.contains("Pokemon"))
searchName.replace("Pokemon", "Pokémon");
else if (searchName.toLower() == "f-zero x")
gameID = "10836";
else if (searchName.contains("Pokemon", Qt::CaseInsensitive))
searchName.replace("Pokemon", "Pokémon", Qt::CaseInsensitive);
else if (searchName.toLower() == "smash brothers")
searchName = "Super Smash Bros.";
else if (searchName.toLower() == "conker bfd")
searchName = "Conker's Bad Fur Day";

QString apiFilter = "&filter[platform]=3&include=boxart&fields=game_title,release_date,";
apiFilter += "developers,publishers,genres,overview,rating,players";
Expand Down Expand Up @@ -240,7 +242,7 @@ void TheGamesDBScraper::downloadGameInfo(QString identifier, QString searchName,

QString check = "Game: " + title.toString();
check.remove(QRegExp(QString("[^A-Za-z 0-9 \\.,\\?'""!@#\\$%\\^&\\*\\")
+ "(\\)-_=\\+;:<>\\/\\\\|\\}\\{\\[\\]`~]*"));
+ "(\\)-_=\\+;:<>\\/\\\\|\\}\\{\\[\\]`~é]*"));
if (date.toString() != "") check += "\n" + tr("Released on: ") + date.toString();
check += "\n\n" + tr("Does this look correct?");

Expand All @@ -255,7 +257,7 @@ void TheGamesDBScraper::downloadGameInfo(QString identifier, QString searchName,
} else {
//We only want one game, so search for a perfect match in the GameTitle element.
//Otherwise this will default to 0 (the first game found)
if(title.toString() == searchName)
if(title.toString().toLower() == searchName.toLower())
found = count;
}

Expand Down Expand Up @@ -421,13 +423,15 @@ void TheGamesDBScraper::showError(QString error)

void TheGamesDBScraper::updateListCache(QFile *file, QString list)
{
QUrl url;
url.setUrl("https://api.thegamesdb.net/" + list + "?apikey=" + TheGamesDBAPIKey);
QString data = getUrlContents(url);
QJsonDocument document = QJsonDocument::fromJson(data.toUtf8());
QJsonDocument result(document.object().value("data").toObject().value(list.toLower()).toObject());

file->open(QIODevice::WriteOnly);
file->write(result.toJson());
file->close();
if (keepGoing) {
QUrl url;
url.setUrl("https://api.thegamesdb.net/" + list + "?apikey=" + TheGamesDBAPIKey);
QString data = getUrlContents(url);
QJsonDocument document = QJsonDocument::fromJson(data.toUtf8());
QJsonDocument result(document.object().value("data").toObject().value(list.toLower()).toObject());

file->open(QIODevice::WriteOnly);
file->write(result.toJson());
file->close();
}
}

0 comments on commit c4cf014

Please sign in to comment.