/*************************************************************************** * worldofspectrum.cpp * * Wed Jun 18 12:00:00 CEST 2017 * Copyright 2017 Lars Muldjord * muldjordlars@gmail.com ****************************************************************************/ /* * This file is part of skyscraper. * * skyscraper is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * skyscraper is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with skyscraper; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include "worldofspectrum.h" #include "strtools.h" WorldOfSpectrum::WorldOfSpectrum(Settings *config) : AbstractScraper(config) { connect(&manager, &NetComm::dataReady, &q, &QEventLoop::quit); baseUrl = "http://www.worldofspectrum.org"; searchResultPre = "
"; urlPre.append("Full title"); urlPre.append(""); titlePost = ""; releaseDatePre.append("Year of release"); releaseDatePre.append(""); releaseDatePost = ""; publisherPre.append("Find other titles from this publisher\">"); publisherPost = ""; developerPre.append("Find other titles by this author\">"); developerPost = ""; playersPre.append("Number of players"); playersPre.append(""); playersPost = ""; tagsPre.append("Type"); tagsPre.append(""); tagsPost = ""; descriptionPre.append("Additional info"); descriptionPre.append(""); descriptionPost = ""; coverPre.append(""); coverPre.append("
"); coverPost = "\" TARGET"; screenshotPost = "\" BORDER"; fetchOrder.append(COVER); fetchOrder.append(SCREENSHOT); fetchOrder.append(RELEASEDATE); fetchOrder.append(PUBLISHER); fetchOrder.append(DEVELOPER); fetchOrder.append(PLAYERS); fetchOrder.append(TAGS); fetchOrder.append(DESCRIPTION); } void WorldOfSpectrum::getSearchResults(QList &gameEntries, QString searchName, QString platform) { searchName = searchName.replace("the+", ""); manager.request("http://www.worldofspectrum.org/infoseek.cgi", "regexp=" + searchName + "&model=spectrum&loadpics=3"); q.exec(); data = manager.getData(); GameEntry game; while(data.indexOf(searchResultPre) != -1) { nomNom(searchResultPre); // Digest until url foreach(QString nom, urlPre) { nomNom(nom); } game.url = baseUrl + data.left(data.indexOf(urlPost)) + "&loadpics=3&allowadult=on"; // Digest until title foreach(QString nom, titlePre) { nomNom(nom); } game.title = data.left(data.indexOf(titlePost)); if(game.title.indexOf(", The") != -1) { game.title = game.title.replace(", The", "").prepend("The "); } game.platform = "zxspectrum"; if(platformMatch(game.platform, platform)) { gameEntries.append(game); } } } void WorldOfSpectrum::getDescription(GameEntry &game) { foreach(QString nom, descriptionPre) { if(!checkNom(nom)) { return; } } foreach(QString nom, descriptionPre) { nomNom(nom); } game.description = data.left(data.indexOf(descriptionPost)); // Remove all html tags within description game.description = StrTools::stripHtmlTags(game.description); } void WorldOfSpectrum::getCover(GameEntry &game) { foreach(QString nom, coverPre) { nomNom(nom); } if(data.left(2) != "