@Override
public PGNTournament findTournament(String tournamentName) throws ChessHogScannerException {
+ PGNTournament tournament = null;
Map<String, String> result = matchMap(
assignUrl(
tournamentName, true
getSettings().getTournamentQueryUrlRegex(),
true
);
- PGNTournament tournament = null;
for (Map.Entry<String, String> entry : result.entrySet()) {
if (entry.getValue().contains(tournamentName)) { // todo: contains?
tournament = new PGNTournament(
String pgn = request(
assignUrl(gameId)
);
+ if (!isPgnFormat(pgn)) {
+ throw new ChessHogScannerException(
+ String.format("Failed to get PGN for requesting game ID: %s", gameId)
+ );
+ }
return new PGNGame(
gameId, pgn
);
@Override
public PGNGame scanUrl(String gameUrl) throws ChessHogScannerException {
- return null;
+ String pgn = regex(
+ request(
+ gameUrl
+ ),
+ getSettings().getGameUrlRegex()
+ );
+ if (pgn == null || !isPgnFormat(pgn)) {
+ throw new ChessHogScannerException(
+ String.format("Failed to get PGN for requesting URL: %s", gameUrl)
+ );
+ }
+ return new PGNGame(
+ null,
+ pgn
+ );
}
private void assignTournamentGames(PGNTournament tournament) throws ChessHogScannerException {