+ @Override
+ public PGNGame scanGame(String gameId, String tournamentId) throws ScannerException {
+ return scanGame(gameId);
+ }
+
+ @Override
+ public PGNGame scanUrl(String gameUrl) throws ScannerException {
+ String gamePage = request(gameUrl);
+ String pgn = StringUtils.match(
+ gamePage,
+ getSettings().getGameUrlRegex()
+ );
+ if (pgn == null) {
+ pgn = StringUtils.match(
+ gamePage,
+ getSettings().getGameJsonUrlRegex()
+ );
+ if (pgn == null) {
+ throw new ScannerException(
+ String.format("Failed to get source data for requesting URL: %s", gameUrl)
+ );
+ }
+ GameFormat gameFormat = Format.formatGame(pgn);
+ return new PGNGame(
+ gameFormat.id(),
+ gameFormat.pgn()
+ );
+ } else {
+ pgn = StringEscapeUtils.unescapeHtml4(pgn);
+ if (!StringUtils.isPgn(pgn)) {
+ throw new ScannerException(
+ String.format("Failed to get PGN for requesting URL: %s", gameUrl)
+ );
+ }
+ return new PGNGame(
+ StringUtils.match(
+ pgn,
+ getSettings().getGameIdRegex()
+ ),
+ pgn
+ );
+ }
+ }
+
+ private void assignTournamentGames(PGNTournament tournament) throws ScannerException {