autoslot.sh
This commit is contained in:
parent
20b2a2ffa3
commit
680284566a
|
@ -0,0 +1,49 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
PROJECT_NAME='c-piscine-c-02'
|
||||||
|
START='2023-03-20'
|
||||||
|
END='2023-03-27'
|
||||||
|
TEAM_ID='4767869'
|
||||||
|
API="https://projects.intra.42.fr/projects/${PROJECT_NAME}/slots.json"
|
||||||
|
PARAMETERS="?team_id=${TEAM_ID}&start=${START}&end=${END}"
|
||||||
|
FULL_COOKIE='cookie: user.id=MTQ3ODQ1--2ed4a01852220e3253f40a3457511a8ae91ca457; _intra_42_session_production=bea76bc0dd96771867156f2e827a8472'
|
||||||
|
FULL_CSRF_TOKEN='x-csrf-token: V0LuxOHdvRv+52H0ax3CPPIZmoWoCDUMoyayLoRhC6APF5oGEZH/zf20lmP4aVC48co4FnnFFHeFknOyzZC42A=='
|
||||||
|
FULL_USER_AGENT='user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36'
|
||||||
|
FULL_REFERER="referer: https://projects.intra.42.fr/projects/${PROJECT_NAME}/slots?team_id=${TEAM_ID}"
|
||||||
|
ITERS=100
|
||||||
|
HEAD=5
|
||||||
|
DELAY=3
|
||||||
|
|
||||||
|
for i in $(seq ${ITERS}); do
|
||||||
|
clear
|
||||||
|
printf '\033[36m%s\033[m\n' "AUTOSLOT: Query available slots periodically."
|
||||||
|
printf '\033[33m%s\033[m\n' "Iter: ${i} / ${ITERS}"
|
||||||
|
printf '\033[32m%s\033[m\n' "$(date)"
|
||||||
|
printf '\033[34m%s\033[m\n' "Next ${HEAD} Slots Open At:"
|
||||||
|
curl "${API}${PARAMETERS}" \
|
||||||
|
-H 'authority: projects.intra.42.fr' \
|
||||||
|
-H 'accept: application/json, text/javascript, */*; q=0.01' \
|
||||||
|
-H 'accept-language: en-US,en;q=0.8' \
|
||||||
|
-H 'cache-control: no-cache' \
|
||||||
|
-H "${FULL_COOKIE}" \
|
||||||
|
-H 'pragma: no-cache' \
|
||||||
|
-H "${FULL_REFERER}" \
|
||||||
|
-H 'sec-ch-ua: "Chromium";v="110", "Not A(Brand";v="24", "Brave";v="110"' \
|
||||||
|
-H 'sec-ch-ua-mobile: ?0' \
|
||||||
|
-H 'sec-ch-ua-platform: "Linux"' \
|
||||||
|
-H 'sec-fetch-dest: empty' \
|
||||||
|
-H 'sec-fetch-mode: cors' \
|
||||||
|
-H 'sec-fetch-site: same-origin' \
|
||||||
|
-H 'sec-gpc: 1' \
|
||||||
|
-H "${FULL_USER_AGENT}" \
|
||||||
|
-H "${FULL_CSRF_TOKEN}" \
|
||||||
|
-H 'x-requested-with: XMLHttpRequest' \
|
||||||
|
-s |
|
||||||
|
jq '.[].start' -r |
|
||||||
|
tr 'T' ' ' |
|
||||||
|
sed 's/\.000+0[[:digit:]]:00//g' |
|
||||||
|
sort -n |
|
||||||
|
head -n${HEAD}
|
||||||
|
printf '\033[35m%s\033[m\n' "<EOF>"
|
||||||
|
sleep ${DELAY}
|
||||||
|
done
|
Loading…
Reference in New Issue