Skip to content

Commit 105491d

Browse files
committed
enhancement to scrape with custom file extensions with screenscraper.fr
1 parent 99ba737 commit 105491d

4 files changed

Lines changed: 21 additions & 6 deletions

File tree

src/screenscraper.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ void ScreenScraper::getSearchResults(QList<GameEntry> &gameEntries,
263263

264264
// If title still unset, no acceptable rom was found, so return with no
265265
// results
266+
// TODO: replace with isEmpty()
266267
if (game.title.isNull()) {
267268
return;
268269
}
@@ -572,11 +573,20 @@ QList<QString> ScreenScraper::getSearchNames(const QFileInfo &info,
572573

573574
// Only one searchName, but direct match query
574575
if (info.size() != 0) {
575-
searchNames.append("crc=" + hashList.at(1) + "&md5=" + hashList.at(2) +
576-
"&sha1=" + hashList.at(3) +
577-
"&romnom=" + hashList.at(0) +
578-
"&romtaille=" + QString::number(info.size()));
576+
if (!config->addExtensions.contains(info.suffix().toLower())) {
577+
// sunny day approach
578+
searchNames.append(
579+
"crc=" + hashList.at(1) + "&md5=" + hashList.at(2) +
580+
"&sha1=" + hashList.at(3) + "&romnom=" + hashList.at(0) +
581+
"&romtaille=" + QString::number(info.size()));
582+
} else {
583+
// edge case: user has provided additional extensions via
584+
// addExtensions, then use basename only for search
585+
searchNames.append("romnom=" +
586+
QUrl::toPercentEncoding(baseName, "()"));
587+
}
579588
} else {
589+
// provided file has no content or can not be accessed
580590
searchNames.append("romnom=" + hashList.at(0));
581591
}
582592

src/settings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,8 +562,8 @@ void RuntimeCfg::applyCli(bool &inputFolderSet, bool &gameListFolderSet,
562562
config->frontendExtra = parser->value("e");
563563
} else {
564564
printf("\033[1;33mParameter -e is ignored. Only applicable "
565-
"with frontend %s.\n\033[0m",
566-
allowedFe.join(" or ").toUtf8().constData());
565+
"with frontend %s.\n\033[0m",
566+
allowedFe.join(" or ").toUtf8().constData());
567567
}
568568
}
569569
if (parser->isSet("i")) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AAAA

test/getsearchnames/test_getsearchnames.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,13 @@ private slots:
326326
QPair<QString, QStringList>(
327327
"./rom_samples/BillsTomatoGame_v2.0_1748.lha",
328328
{"romnom=BillsTomatoGame_v2.0_1748.lha"})},
329+
{"Screenscraper, ROM with uncommon suffix and size greater zero",
330+
QPair<QString, QStringList>("./rom_samples/Pac Man.desktop",
331+
{"romnom=Pac%20Man"})},
329332

330333
};
331334
settings.mameMap.insert("zaxxon.zip", "Should not break the test.zip");
335+
settings.addExtensions = "*.desktop";
332336

333337
match(tests);
334338
}

0 commit comments

Comments
 (0)