commit eff6f7ad205b31722671543a7c6481d5134fbec6 Author: nixi Date: Mon Mar 25 18:24:47 2019 +0100 Initial commit diff --git a/sisfetch.sh b/sisfetch.sh new file mode 100755 index 0000000..b60f80d --- /dev/null +++ b/sisfetch.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# This script parses SIS for a CSV file of a specific room and saves it +# in the working directory. The correct room ID is parsed first followed +# by a given CSV file. + +# The hostname of the computer running this script has to have the name +# of a corresponding room after the first hyphen, eg. "rzv-r013h", +# where the room name would be "R013H" as defined in SIS. + +# Curl with TLS support needs to be installed as well as iconv for +# Windows-1250 to UTF-8 encoding conversion. + +# All utilities used: curl, sed, grep, tr, iconv + +ROOM_NAME=$(hostname | sed "s/.*-//" | tr "[:lower:]" "[:upper:]") +ROOM_ID=$(curl -s "https://is.cuni.cz/studium/rozvrhng/roz_ucebna_macro.php?skr=2018&sem=2&fak=11410" | sed "s,,\n,g" | grep $ROOM_NAME | grep -oP "ucebna=\K[^ ]+" | tr -d "\"") + +printf "%s\n" "Fetching room $ROOM_NAME with ID $ROOM_ID" +curl -s "https://is.cuni.cz/studium/rozvrhng/roz_ucebna_micro.php?ucebna=$ROOM_ID&fak=11410&csv=1" > $ROOM_NAME.csv +iconv -f WINDOWS-1250 -t UTF-8 $ROOM_NAME.csv -o $ROOM_NAME.csv +