Updated for new API
* Use the new, shortest API m= * for a card, grab prices for all sets * use the lower price for a card from all sets, but avoid prices=0 (e.g.: some M15 cards have no price yet)
This commit is contained in:
parent
06def7f46a
commit
106e9d1538
1 changed files with 11 additions and 5 deletions
|
@ -126,14 +126,20 @@ void DBPriceUpdater::updatePrices()
|
||||||
muidMap.clear();
|
muidMap.clear();
|
||||||
CardInfo * card;
|
CardInfo * card;
|
||||||
int muid;
|
int muid;
|
||||||
|
SetList sets;
|
||||||
for (int i = 0; i < cards.size(); ++i) {
|
for (int i = 0; i < cards.size(); ++i) {
|
||||||
card = db->getCard(cards[i], false);
|
card = db->getCard(cards[i], false);
|
||||||
muid=card->getPreferredMuId();
|
sets = card->getSets();
|
||||||
q += (i ? "&" : "?") + QString("multiverseid=%1").arg(muid);
|
for(int j = 0; j < sets.size(); ++j)
|
||||||
muidMap.insert(muid, cards[i]);
|
{
|
||||||
|
muid=card->getMuId(sets[j]->getShortName());
|
||||||
|
//qDebug() << "muid " << muid << " card: " << cards[i] << endl;
|
||||||
|
q += (i ? "&" : "?") + QString("m=%1").arg(muid);
|
||||||
|
muidMap.insert(muid, cards[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
QUrl url(q);
|
QUrl url(q);
|
||||||
|
//qDebug() << "request prices from: " << url.toString() << endl;
|
||||||
QNetworkReply *reply = nam->get(QNetworkRequest(url));
|
QNetworkReply *reply = nam->get(QNetworkRequest(url));
|
||||||
connect(reply, SIGNAL(finished()), this, SLOT(downloadFinished()));
|
connect(reply, SIGNAL(finished()), this, SLOT(downloadFinished()));
|
||||||
}
|
}
|
||||||
|
@ -208,7 +214,7 @@ void DBPriceUpdater::downloadFinished()
|
||||||
* physically exist. Also check the price to see that the cheapest set
|
* physically exist. Also check the price to see that the cheapest set
|
||||||
* ends up as the final price.
|
* ends up as the final price.
|
||||||
*/
|
*/
|
||||||
if (set != "MED" && (!cardsPrice.contains(name) || cardsPrice.value(name) > price))
|
if (set != "MED" && price > 0 && (!cardsPrice.contains(name) || cardsPrice.value(name) > price))
|
||||||
cardsPrice.insert(name, price);
|
cardsPrice.insert(name, price);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue