void IBSFetcher::slotCompleteISBN(KJob* job_) { if(m_job->error()) { m_job->ui()->showErrorMessage(); stop(); return; } QByteArray data = m_job->data(); if(data.isEmpty()) { myDebug() << "no data"; stop(); return; } // since the fetch is done, don't worry about holding the job pointer m_job = 0; QString str = Tellico::decodeHTML(data); if(str.indexOf(QLatin1String("Libro non presente"), 0, Qt::CaseInsensitive) > -1) { stop(); return; } Data::EntryPtr entry = parseEntry(str); if(entry) { QString desc = entry->field(QLatin1String("author")) + QLatin1Char('/') + entry->field(QLatin1String("publisher")); FetchResult* r = new FetchResult(Fetcher::Ptr(this), entry->title(), desc, entry->field(QLatin1String("isbn"))); m_matches.insert(r->uid, static_cast<KIO::TransferJob*>(job_)->url()); emit signalResultFound(r); } stop(); }
Tellico::Fetch::FetchRequest BoardGameGeekFetcher::updateRequest(Data::EntryPtr entry_) { QString bggid = entry_->field(QLatin1String("bggid")); if(!bggid.isEmpty()) { return FetchRequest(Raw, bggid); } QString title = entry_->field(QLatin1String("title")); if(!title.isEmpty()) { return FetchRequest(Title, title); } return FetchRequest(); }
Tellico::Fetch::FetchRequest GoogleScholarFetcher::updateRequest(Data::EntryPtr entry_) { QString title = entry_->field(QLatin1String("title")); if(!title.isEmpty()) { return FetchRequest(Title, title); } return FetchRequest(); }
Tellico::Fetch::FetchRequest DBLPFetcher::updateRequest(Data::EntryPtr entry_) { QString title = entry_->field(QLatin1String("title")); if(!title.isEmpty()) { return FetchRequest(Keyword, title); } return FetchRequest(); }
FetchResult::FetchResult(Fetcher::Ptr fetcher_, Data::EntryPtr entry_) : uid(KRandom::random()) , fetcher(fetcher_) , title(entry_->title()) , desc(makeDescription(entry_)) , isbn(entry_->field(QLatin1String("isbn"))) { }
Tellico::Data::EntryPtr BoardGameGeekFetcher::fetchEntryHookData(Data::EntryPtr entry_) { Q_ASSERT(entry_); const QString id = entry_->field(QLatin1String("bggid")); if(id.isEmpty()) { myDebug() << "no bgg id found"; return entry_; } KUrl u(BGG_THING_URL); u.addQueryItem(QLatin1String("id"), id); u.addQueryItem(QLatin1String("type"), QLatin1String("boardgame,boardgameexpansion")); // myDebug() << "url: " << u; // quiet QString output = FileHandler::readXMLFile(u, true); #if 0 myWarning() << "Remove output debug from boardgamegeekfetcher.cpp"; QFile f(QLatin1String("/tmp/test.xml")); if(f.open(QIODevice::WriteOnly)) { QTextStream t(&f); t.setCodec("UTF-8"); t << output; } f.close(); #endif Import::TellicoImporter imp(xsltHandler()->applyStylesheet(output)); // be quiet when loading images imp.setOptions(imp.options() ^ Import::ImportShowImageErrors); Data::CollPtr coll = imp.collection(); // getTracks(entry); if(!coll) { myWarning() << "no collection pointer"; return entry_; } if(coll->entryCount() == 0) { myWarning() << "no entries"; return entry_; } if(coll->entryCount() > 1) { myDebug() << "weird, more than one entry found"; } // don't want to include id coll->removeField(QLatin1String("bggid")); return coll->entries().front(); }