Ensure there is no duplicate sets downloaded.
This commit is contained in:
@@ -150,7 +150,7 @@ public class MtgGoldfishProvider implements MtgDataProvider {
|
|||||||
String link = "http://www.mtggoldfish.com/index/" + mtgCardSet.getUrlPostfix();
|
String link = "http://www.mtggoldfish.com/index/" + mtgCardSet.getUrlPostfix();
|
||||||
Document doc = Jsoup.parse(new URL(link), TIMEOUT);
|
Document doc = Jsoup.parse(new URL(link), TIMEOUT);
|
||||||
boolean isInPaper = (doc.select("#priceHistoryTabs [href=#tab-paper]").size() > 0);
|
boolean isInPaper = (doc.select("#priceHistoryTabs [href=#tab-paper]").size() > 0);
|
||||||
if (isInPaper) {
|
if (isInPaper && !containsLinkSet(result, link)) {
|
||||||
List<CardData> allCards = new LinkedList<CardData>();
|
List<CardData> allCards = new LinkedList<CardData>();
|
||||||
|
|
||||||
Elements cardElements = doc.select(".index-price-table-paper tbody tr");
|
Elements cardElements = doc.select(".index-price-table-paper tbody tr");
|
||||||
@@ -169,6 +169,14 @@ public class MtgGoldfishProvider implements MtgDataProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean containsLinkSet(List<SetCardData> result, String link) {
|
||||||
|
for (SetCardData setCardData : result) {
|
||||||
|
if (setCardData.getSetLink().equals(link))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private int getSleepTime() {
|
private int getSleepTime() {
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
return SLEEP_MINIMUM + rnd.nextInt(SLEEP_MAXIMUM - SLEEP_MINIMUM);
|
return SLEEP_MINIMUM + rnd.nextInt(SLEEP_MAXIMUM - SLEEP_MINIMUM);
|
||||||
|
|||||||
Reference in New Issue
Block a user