Skip to content

Commit

Permalink
fix mtgdecksniffer
Browse files Browse the repository at this point in the history
  • Loading branch information
nicol authored and nicol committed Dec 2, 2024
1 parent 7c82ea5 commit 4e72932
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
24 changes: 10 additions & 14 deletions src/main/java/org/magic/api/decksniffer/impl/MTGDecksSniffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.util.List;
import java.util.Map;

import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.magic.api.beans.MTGCard;
Expand All @@ -28,7 +27,7 @@ public class MTGDecksSniffer extends AbstractDeckSniffer {

@Override
public String[] listFilter() {
return new String[] { "Standard", "Modern", "Legacy", "Vintage", "Commander", "Historic", "Pauper", "Pioneer", "Highlander","Old-school" };
return new String[] { "Standard", "Modern", "Legacy", "Vintage", "Commander", "Historic", "Timeless","Explorer","Pauper", "Pioneer", "Highlander","Old-school" };
}


Expand Down Expand Up @@ -85,18 +84,17 @@ public MTGDeck getDeck(RetrievableDeck info) throws IOException {
@Override
public List<RetrievableDeck> getDeckList(String filter, MTGCard mc) throws IOException {
List<RetrievableDeck> list = new ArrayList<>();
var nbPage = 1;
var maxPage = getInt(MAX_PAGE);

for (var i = 1; i <= maxPage; i++) {
var url = URL + "/" + filter + "/decklists/page:" + nbPage;
for (var i = 1; i <= getInt(MAX_PAGE); i++)
{
var url = URL + "/" + filter + "/decklists/page:" + i;
logger.debug("read deck list at {}", url);
Document d = URLTools.extractAsHtml(url);
var d = URLTools.extractAsHtml(url);
var trs = d.select("table.hidden-xs tr ");

Elements trs = d.select("table.hidden-xs tr ");

for (var j = 1; j < trs.size(); j++) {
Element tr = trs.get(j);
for (var j = 1; j < trs.size(); j++)
{
var tr = trs.get(j);
var deck = new RetrievableDeck();

deck.setName(tr.select("td a").first().text());
Expand All @@ -107,7 +105,7 @@ public List<RetrievableDeck> getDeckList(String filter, MTGCard mc) throws IOExc
}
deck.setAuthor(tr.select("td").get(2).select("strong").text());

String manas = tr.select("td").get(3).html();
var manas = tr.select("td").get(3).html();

var build = new StringBuilder();

Expand All @@ -125,13 +123,11 @@ public List<RetrievableDeck> getDeckList(String filter, MTGCard mc) throws IOExc
deck.setColor(build.toString());
list.add(deck);
}
nbPage++;
}

return list;
}


@Override
public String getName() {
return "MTGDecks";
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/magic/services/logging/MTGLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public static void changeLevel(Logger logger, String l) {
{
getContext().getLogger(MTGLogger.class).error("Error setting logger level to {}",l);
}

}

public static void changeLevel(Level l) {
Expand All @@ -55,7 +54,7 @@ public static void changeLevel(Level l) {

public static LoggerContext getContext()
{
return (LoggerContext) LogManager.getContext(true);
return (LoggerContext) LogManager.getContext(false);
}


Expand Down

0 comments on commit 4e72932

Please sign in to comment.