import org.hedgecode.chess.scanner.Scanner;
import org.hedgecode.chess.scanner.ScannerException;
+import org.hedgecode.chess.scanner.StringUtils;
import org.hedgecode.chess.scanner.entity.PGNGame;
import org.hedgecode.chess.scanner.entity.PGNTournament;
import org.hedgecode.chess.scanner.format.lichess.Format;
import org.hedgecode.chess.scanner.format.lichess.GameFormat;
-import static org.hedgecode.chess.scanner.ScannerConstants.*;
+import static org.hedgecode.chess.scanner.format.PGNConstants.*;
/**
* LiChessScanner
String pgn = request(
assignUrl(gameId)
);
- if (!isPgnFormat(pgn)) {
+ if (!StringUtils.isPgn(pgn)) {
throw new ScannerException(
String.format("Failed to get PGN for requesting game ID: %s", gameId)
);
@Override
public PGNGame scanUrl(String gameUrl) throws ScannerException {
String gamePage = request(gameUrl);
- String pgn = regex(
+ String pgn = StringUtils.match(
gamePage,
getSettings().getGameUrlRegex()
);
if (pgn == null) {
- pgn = regex(
+ pgn = StringUtils.match(
gamePage,
getSettings().getGameJsonUrlRegex()
);
);
} else {
pgn = StringEscapeUtils.unescapeHtml4(pgn);
- if (!isPgnFormat(pgn)) {
+ if (!StringUtils.isPgn(pgn)) {
throw new ScannerException(
String.format("Failed to get PGN for requesting URL: %s", gameUrl)
);
}
return new PGNGame(
- regex(pgn, getSettings().getGameIdRegex()),
+ StringUtils.match(
+ pgn,
+ getSettings().getGameIdRegex()
+ ),
pgn
);
}
if (!pgnGames.isEmpty()) {
tournament.setName(
- regex(
+ StringUtils.match(
pgnGames.get(0),
getSettings().getTournamentNameRegex()
)
}
for (String pgn : pgnGames) {
- String gameId = regex(
+ String gameId = StringUtils.match(
pgn,
getSettings().getGameIdRegex()
);