/** * @brief Called when the search result was downloaded * Emits "searchDone" if there are no more pages in the result set * @see Cinefacts::parseSearch */ void Cinefacts::searchFinished() { QNetworkReply *reply = static_cast<QNetworkReply*>(QObject::sender()); reply->deleteLater(); if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 302 || reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 301) { qDebug() << "Got redirect" << reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl(); QString redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toString(); if (!redirect.startsWith("http")) redirect.prepend("http://www.cinefacts.de"); QUrl url(redirect); QNetworkReply *reply = qnam()->get(QNetworkRequest(url)); new NetworkReplyWatcher(this, reply); connect(reply, SIGNAL(finished()), this, SLOT(searchFinished())); return; } QList<ScraperSearchResult> results; if (reply->error() == QNetworkReply::NoError) { QString msg = QString::fromUtf8(reply->readAll()); results = parseSearch(msg); } else { qWarning() << "Network Error" << reply->errorString(); } emit searchDone(results); }
/** * @brief Called when the search result was downloaded * Emits "searchDone" if there are no more pages in the result set * @see TMDbConcerts::parseSearch */ void TMDbConcerts::searchFinished() { qDebug() << "Entered"; QList<ScraperSearchResult> results; if (m_searchReply->error() != QNetworkReply::NoError ) { qWarning() << "Network Error" << m_searchReply->errorString(); m_searchReply->deleteLater(); emit searchDone(results); return; } QString msg = QString::fromUtf8(m_searchReply->readAll()); int nextPage = -1; results = parseSearch(msg, &nextPage); m_results.append(results); m_searchReply->deleteLater(); if (nextPage == -1) { emit searchDone(m_results); } else { QUrl url(QString("http://api.themoviedb.org/3/search/movie?api_key=%1&language=%2&page=%3&query=%4").arg(m_apiKey).arg(m_language).arg(nextPage).arg(m_searchString)); QNetworkRequest request(url); request.setRawHeader("Accept", "application/json"); m_searchReply = this->qnam()->get(request); connect(m_searchReply, SIGNAL(finished()), this, SLOT(searchFinished())); } }
/** * @brief Called when the search result was downloaded * Emits "sigSearchDone" if there was an error * @see TheTvDb::parseSearch */ void TheTvDb::onSearchFinished() { QNetworkReply *reply = static_cast<QNetworkReply*>(QObject::sender()); QList<ScraperSearchResult> results; if (reply->error() == QNetworkReply::NoError ) { QString msg = QString::fromUtf8(reply->readAll()); results = parseSearch(msg); } else { qWarning() << "Network Error" << reply->errorString(); } reply->deleteLater(); emit sigSearchDone(results); }
/** * @brief Called when the search result was downloaded * Emits "searchDone" if there are no more pages in the result set * @see VideoBuster::parseSearch */ void VideoBuster::searchFinished() { QNetworkReply *reply = static_cast<QNetworkReply*>(QObject::sender()); QList<ScraperSearchResult> results; if (reply->error() == QNetworkReply::NoError ) { QString msg = reply->readAll(); msg = replaceEntities(msg); results = parseSearch(msg); } else { qWarning() << "Network Error" << reply->errorString(); } reply->deleteLater(); emit searchDone(results); }
/** * @brief Called when the search result was downloaded * Emits "searchDone" if there are no more pages in the result set * @see OFDb::parseSearch */ void OFDb::searchFinished() { QNetworkReply *reply = static_cast<QNetworkReply*>(QObject::sender()); QString searchStr = reply->property("searchString").toString(); int notFoundCounter = reply->property("notFoundCounter").toInt(); if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 302 || reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 301) { qDebug() << "Got redirect" << reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl(); reply->deleteLater(); reply = qnam()->get(QNetworkRequest(reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl())); reply->setProperty("searchString", searchStr); connect(reply, SIGNAL(finished()), this, SLOT(searchFinished())); return; } // try to get another mirror when 404 occurs if (reply->error() == QNetworkReply::ContentNotFoundError && notFoundCounter < 3) { qWarning() << "Got 404"; notFoundCounter++; reply->deleteLater(); QUrl url(QString("http://www.ofdbgw.org/search/%1").arg(searchStr)); reply = qnam()->get(QNetworkRequest(url)); reply->setProperty("searchString", searchStr); reply->setProperty("notFoundCounter", notFoundCounter); connect(reply, SIGNAL(finished()), this, SLOT(searchFinished())); return; } QList<ScraperSearchResult> results; if (reply->error() == QNetworkReply::NoError ) { QString msg = QString::fromUtf8(reply->readAll()); results = parseSearch(msg, searchStr); } else { qWarning() << "Network Error" << reply->errorString(); } reply->deleteLater(); emit searchDone(results); }
Echonest::Artists Echonest::Artist::parseTopHottt( QNetworkReply* reply ) throw( Echonest::ParseError ) { return parseSearch( reply ); }