From 12b04f7bb17dc7bb791fa7a80a7263717b04e5b6 Mon Sep 17 00:00:00 2001 From: Jan Vais Date: Sun, 7 Apr 2019 22:49:56 +0200 Subject: [PATCH] =?UTF-8?q?P=C5=99idano=20parsov=C3=A1n=C3=AD=20rozvrhu=20?= =?UTF-8?q?Moc=20se=20mi=20to=20nel=C3=ADb=C3=AD,=20kdy=C5=BE=20bude=20?= =?UTF-8?q?=C4=8Das=20je=C5=A1t=C4=9B=20p=C5=99ed=C4=9Bl=C3=A1m.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sisfetch.sh | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/sisfetch.sh b/sisfetch.sh index b60f80d..816248d 100755 --- a/sisfetch.sh +++ b/sisfetch.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # 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 @@ -13,10 +13,29 @@ # All utilities used: curl, sed, grep, tr, iconv -ROOM_NAME=$(hostname | sed "s/.*-//" | tr "[:lower:]" "[:upper:]") +#ROOM_NAME=$(hostname | sed "s/.*-//" | tr "[:lower:]" "[:upper:]") +ROOM_NAME=$(echo rzv-r013h | 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 + +DATE=$(date -d "tomorrow" "+%-d.%-m.%Y" ) +FILE="$ROOM_NAME"".csv" +TODAY=$(grep "$DATE" "$FILE") + +echo "$TODAY" +while read line +do + +LECTURE=$(echo $line | cut -d';' -f 4) +START=$(date -d "today 0 +$(echo $line | cut -d';' -f 7) minutes" "+%T") +DURRATION=$(echo $line | cut -d';' -f 9) +END=$(date -d "$START $DURRATION minutes" "+%T") +TEACHER=$(echo $line | cut -d';' -f 10) + +echo "$LECTURE; $START; $END; $TEACHER" + +done <<< "$TODAY"