From 0154918c7141399d93407256e27480464a1dc5ee Mon Sep 17 00:00:00 2001 From: Y Date: Tue, 12 Nov 2019 08:07:13 +0100 Subject: [PATCH] work around unreliable EDT server --- epsiEDTtoICS.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/epsiEDTtoICS.sh b/epsiEDTtoICS.sh index 76ca085..ed5a7a3 100755 --- a/epsiEDTtoICS.sh +++ b/epsiEDTtoICS.sh @@ -41,7 +41,11 @@ ENDOFTEXT thu=$(date +%Y%m%dT%z -d "$(($offset+4-$dayOfWeek))days") fri=$(date +%Y%m%dT%z -d "$(($offset+5-$dayOfWeek))days") - curl -s "https://edtmobiliteng.wigorservices.net/WebPsDyn.aspx?action=posEDTBEECOME&serverid=C&Tel=${1}&date=$(date +%m/%d/%Y -d "${offset}days")" \ + for ((i=1; i<5; i=i*2)); do + week="$(curl -s "https://edtmobiliteng.wigorservices.net/WebPsDyn.aspx?action=posEDTBEECOME&serverid=C&Tel=${1}&date=$(date +%m/%d/%Y -d "${offset}days")")" \ + && { echo "$week"; break; } + sleep ${i}s + done \ | tr '\r\n' ' ' \ | sed -r 's/[[:blank:]]+/ /g' \ | grep -oE '
]*class="Case" [^>]*style="[^"]*left *:[^"]*"|DIV [^>]*style="[^"]*left *:[^"]*" [^>]*class="Case"|]*class="TC(ase|Prof|hdeb|Salle)"([^<]|<[^/]|' \ @@ -104,6 +108,7 @@ ENDOFTEXT out() }' offset=$(($offset+7)) + sleep 0.3s done cat <<-ENDOFTEXT