mtg-decks-downloader

Tool to download Magic: The Gathering decklists from the Internet
git clone https://kevincorvisier.fr/git/mtg-decks-downloader.git
Log | Files | Refs | README

commit abbef7bcbc0dc8dd0a9c1c62d39af35989ba03a6
parent 80dabb6e5b49b1ebbd488874204909527d5ac0ba
Author: Kevin Corvisier <git@kevincorvisier.fr>
Date:   Tue, 24 Dec 2024 19:07:01 +0900

Fix decks downloader crashing at the end of a tcdecks download
Diffstat:
Msrc/main/java/fr/kevincorvisier/mtg/dd/Main.java | 4++++
Msrc/main/java/fr/kevincorvisier/mtg/dd/downloaders/TcdecksDecklistDownloader.java | 11+++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/main/java/fr/kevincorvisier/mtg/dd/Main.java b/src/main/java/fr/kevincorvisier/mtg/dd/Main.java @@ -65,6 +65,10 @@ public class Main context.getBean(Main.class).run(); } + catch (final Exception e) + { + log.error("main: realFile={}", realFile, e); + } } } diff --git a/src/main/java/fr/kevincorvisier/mtg/dd/downloaders/TcdecksDecklistDownloader.java b/src/main/java/fr/kevincorvisier/mtg/dd/downloaders/TcdecksDecklistDownloader.java @@ -112,11 +112,18 @@ public class TcdecksDecklistDownloader implements DecklistDownloader tournaments.add(new URL(tournamentName.getAttribute("href"))); } - next = new URL(crawler.findElement(By.xpath("//a[text()='Next']")).getAttribute("href")); + try + { + next = new URL(crawler.findElement(By.xpath("//a[text()='Next']")).getAttribute("href")); + } + catch (final NoSuchElementException e) + { + next = null; + } for (final URL tournament : tournaments) downloadTournament(tournament); - } while (stopCondition.capacity() > 0); + } while (stopCondition.capacity() > 0 && next != null); } private void downloadArchetype(final URL url, final String archetype) throws MalformedURLException