#!/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__