Initial check for pgnmentor.com downloader
This commit is contained in:
33
bin/pgnmentor_download.sh
Executable file
33
bin/pgnmentor_download.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# download/get files.html
|
||||
# find (Events|Players|Openings updated): Month YYYY
|
||||
# => store in last update
|
||||
# => if one changed -> process
|
||||
|
||||
# in files.html
|
||||
# div "Players"
|
||||
# => table below
|
||||
# => folder "players/"
|
||||
|
||||
# div "Openings"
|
||||
# h2 "Modern Queen Pawn", "Classical Queen Pawn", "Modern King Pawn", "Classical King Pawn", "Flank and Unorthodox"
|
||||
# => table below each h2
|
||||
# => folder "openings/"
|
||||
|
||||
# div "Events"
|
||||
# h2 "Tournaments", "Candidates and Interzonals", "World Championships"
|
||||
|
||||
function error() {
|
||||
if [ -t 1 ]; then echo "$1"; fi; exit 1;
|
||||
}
|
||||
|
||||
# has to be YYYYMMDD
|
||||
current_date="${1}";
|
||||
|
||||
if [ -z "${current_date}" ] || ! [[ "${current_date}" =~ ^[0-9]{8}$ ]]; then
|
||||
error "Current date must be set and in the format YYYYMMDD";
|
||||
fi;
|
||||
|
||||
|
||||
# __END__
|
||||
52
bin/pgnmentor_parse.sh
Executable file
52
bin/pgnmentor_parse.sh
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# download/get files.html
|
||||
# find (Events|Players|Openings updated): Month YYYY
|
||||
# => store in last update
|
||||
# => if one changed -> process
|
||||
|
||||
# in files.html
|
||||
# div "Players"
|
||||
# => table below
|
||||
# => folder "players/"
|
||||
|
||||
# div "Openings"
|
||||
# h2 "Modern Queen Pawn", "Classical Queen Pawn", "Modern King Pawn", "Classical King Pawn", "Flank and Unorthodox"
|
||||
# => table below each h2
|
||||
# => folder "openings/"
|
||||
|
||||
# div "Events"
|
||||
# h2 "Tournaments", "Candidates and Interzonals", "World Championships"
|
||||
|
||||
# has to be YYYYMMDD
|
||||
current_date="${1}";
|
||||
|
||||
current_date='20230718';
|
||||
|
||||
files=("Candidates_and_Interzonals" "Classical_King_Pawn" "Classical_Queen_Pawn" "Flank_and_Unorthodox" "Modern_King_Pawn" "Modern_Queen_Pawn" "Players" "Tournaments" "World_Championships");
|
||||
folder="pgnmentor-files/"
|
||||
|
||||
if [ ! -d "${folder}" ]; then
|
||||
echo "Missing $folder";
|
||||
exit;
|
||||
fi;
|
||||
|
||||
for i in ${files[*]}; do
|
||||
file=$(echo $i | sed -e "s/_/ /g")"."${current_date}".txt";
|
||||
output=$(echo $i | sed -e "s/_/ /g")".pgn";
|
||||
if [ -f "${file}" ]; then
|
||||
echo "OK: $file";
|
||||
rm -f "${output}";
|
||||
for pgn in $(cat "${file}"); do
|
||||
if [ -f "${folder}${pgn}" ]; then
|
||||
cat "${folder}${pgn}" >> "${output}";
|
||||
echo -n "."
|
||||
else
|
||||
echo "[!!] Missing ${folder}${pgn}";
|
||||
fi;
|
||||
done;
|
||||
echo "[DONE]";
|
||||
fi;
|
||||
done;
|
||||
|
||||
# __END__
|
||||
Reference in New Issue
Block a user