Script 'game-add': slight changes.
This commit is contained in:
parent
d7a71b32e9
commit
6730e5d266
11
game-add
11
game-add
@ -58,8 +58,8 @@ function game_setup {
|
|||||||
|
|
||||||
function game_get_players {
|
function game_get_players {
|
||||||
# Extract players on Lichess
|
# Extract players on Lichess
|
||||||
local wt_lichess=$(sed -En "s/\[White \"([^\"]*)\"\]/\1/p" < $tmp_pgn)
|
local wt_lichess=$(sed -En "s/\[White \"([^\"]*)\"\]/\1/p" $tmp_pgn)
|
||||||
local bk_lichess=$(sed -En "s/\[Black \"([^\"]*)\"\]/\1/p" < $tmp_pgn)
|
local bk_lichess=$(sed -En "s/\[Black \"([^\"]*)\"\]/\1/p" $tmp_pgn)
|
||||||
|
|
||||||
# Get names of white and black players
|
# Get names of white and black players
|
||||||
local counter=1 players=()
|
local counter=1 players=()
|
||||||
@ -159,7 +159,7 @@ function game_add_to_repo {
|
|||||||
die "Game '${white} vs. ${black}' not found in ${tour_info}."
|
die "Game '${white} vs. ${black}' not found in ${tour_info}."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local pgn_date=$(sed -En "s/\[Date \"([^\"]*)\"\]/\1/p" < "$tmp_pgn")
|
local pgn_date=$(sed -En "s/\[Date \"([^\"]*)\"\]/\1/p" "$tmp_pgn")
|
||||||
local pgn_date=$(tr "." "-" <<< "$pgn_date")
|
local pgn_date=$(tr "." "-" <<< "$pgn_date")
|
||||||
pgn_dir=${REPO_DIR}/${TOURNAMENT}/tours/${TOUR}/${pgn_date}-${white}-vs-${black}
|
pgn_dir=${REPO_DIR}/${TOURNAMENT}/tours/${TOUR}/${pgn_date}-${white}-vs-${black}
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ function game_add_to_repo {
|
|||||||
|
|
||||||
echo "Updating tour_info..."
|
echo "Updating tour_info..."
|
||||||
local game_date=${pgn_date:8:2}.${pgn_date:5:2}.${pgn_date::4}
|
local game_date=${pgn_date:8:2}.${pgn_date:5:2}.${pgn_date::4}
|
||||||
local result=$(sed -En "s/\[Result \"([^\"]*)\"\]/\1/p" < $tmp_pgn)
|
local result=$(sed -En "s/\[Result \"([^\"]*)\"\]/\1/p" $tmp_pgn)
|
||||||
local spaces=$((length_max - length_rec + 1))
|
local spaces=$((length_max - length_rec + 1))
|
||||||
local sep=$(printf "%${spaces}s" " ")
|
local sep=$(printf "%${spaces}s" " ")
|
||||||
|
|
||||||
@ -230,8 +230,7 @@ trap "rm ${tmp_ini} ${tmp_ini}.prev ${tmp_pgn}" EXIT
|
|||||||
# Download PGN file
|
# Download PGN file
|
||||||
[[ $1 =~ ^(http://[^/]*)/([^/]*) ]]
|
[[ $1 =~ ^(http://[^/]*)/([^/]*) ]]
|
||||||
pgn_url=${BASH_REMATCH[1]}/${BASH_REMATCH[2]::8}/pgn
|
pgn_url=${BASH_REMATCH[1]}/${BASH_REMATCH[2]::8}/pgn
|
||||||
curl -q --fail --location --silent "$pgn_url" > $tmp_pgn \
|
wget -q "$pgn_url" -O $tmp_pgn || die "PGN file not found."
|
||||||
|| die "PGN file not found."
|
|
||||||
|
|
||||||
game_get_players
|
game_get_players
|
||||||
game_add_to_repo
|
game_add_to_repo
|
||||||
|
Loading…
Reference in New Issue
Block a user