Skip to content

Bash script to query the Celcat Calendar application to retrieve the day's schedule of courses displayed cleanly on the terminal.

Notifications You must be signed in to change notification settings

uN4sh/CLI-Daily-Calendar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

CLI-Daily-Calendar (Celcat)

Bash script to query the UVSQ Celcat Calendar application to retrieve the day's schedule of courses displayed cleanly on the terminal.

Usage

$ chmod +x edt.sh
$ bash edt.sh [DATE] [TD]

Requires

  • jq flexible command-line JSON processor
  • recode converts files between character sets

Customize the default configuration

  • Type your college domain here replacing UVSQ
https://edt.uvsq.fr/Home/GetCalendarData
td_list=( 'S6 INFO TD01' 'S6 INFO TD02' 'S6 INFO TD03' 'S6 INFO TD04' ) # Semester 6 INFO by default
day=${1:-`date +%Y-%m-%d`};  # Today's date by default
td=$((${2:-X}-1));  # TDX by default, replace with [1, 2, 3, 4]

Output preview

Terminal output for bash edt.sh

Script details

  1. Save the JSON result of the query in a temporary file /tmp/res.json, HTML recoded for the accented characters
curl -s --data "start=${day}&end=${day}&resType=103&calView=agendaDay&federationIds[]=${tdlst[$td]}" https://edt.uvsq.fr/Home/GetCalendarData | recode html > /tmp/res.json
  1. Sort the day's sessions by start time and start a while loop in the sessions array
jq -c 'sort_by(.start)|.[]' "/tmp/res.json" | while read i; do
  # ...
done
  1. Parse and format the datetime objects to HH:MM
deb=`echo "${i}" | jq -c ".start" | sed -e 's/^"//' -e 's/"$//'`; deb=$(date --date=${deb} "+%Hh%M");
    end=`echo "${i}" | jq -c ".end" | sed -e 's/^"//' -e 's/"$//'`; end=$(date --date=${end} "+%Hh%M");
  1. Parse and format the description field to extract the course name, room, type and group
desc=${desc//rn/}; desc=${desc//\"/}; # Removal of residual characters
IFS='<br />'; splitted=($desc); unset IFS; # Split the string into an array object
  1. Cut to format the course name without the duplicate course code
mod=`echo ${splitted[2]}`; mod=`echo ${mod} | cut -c 3-$((${#mod}-11))`
  1. Format and prints the schedule of the day's sessions
echo -e "\n\033[33;01m 📆 EDT du ${day} — TD${2:-1}\033[0m\n"
echo -e "\033[2m$deb$end\033[0m\n\033[37;1m${mod}\033[0m\n| ${splitted[0]}\n| ${splitted[1]}\n"

About

Bash script to query the Celcat Calendar application to retrieve the day's schedule of courses displayed cleanly on the terminal.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages