ENDPOINT='https://commons.wikimedia.org/w/api.php'
NAMESPACE='Data'
+UPLOAD_MAX_RATE=15 # Per minute
USERNAME_PATH='login_username'
PASSWORD_PATH='login_password'
requestCSRFToken > "${CSRF_TOKEN_PATH}"
readCSRFToken
+MINUTE=$(date +%M)
+MINUTE_UPLOADS=0
while IFS= read -r -d '' -u 9
do
URI_PATH=${NAMESPACE}:$(realpath --relative-to="${SOURCE}" "${REPLY}")
case "${RESULT}" in
Success)
+ SECOND_NOW=$(date +%S)
+ MINUTE_NOW=$(date +%M)
+ MINUTE_UPLOADS=$((MINUTE_UPLOADS+1))
+
+ if [ ${MINUTE_NOW} -ne ${MINUTE} ]
+ then
+ MINUTE=$(date +%M)
+ MINUTE_UPLOADS=0
+ elif [ ${MINUTE_NOW} -eq ${MINUTE} ]&&[ ${MINUTE_UPLOADS} -eq ${UPLOAD_MAX_RATE} ]
+ then
+ sleep $((60-SECOND_NOW))
+ MINUTE=$(date +%M)
+ MINUTE_UPLOADS=0
+ fi
+
echo "Everything went right. Continue…"
- sleep 4
;;
*)
echo "Unknown code: ${RESULT}. Exiting."