-
Notifications
You must be signed in to change notification settings - Fork 0
/
parseInfo.sh
executable file
·65 lines (43 loc) · 2.59 KB
/
parseInfo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# 2018 Beerware Licence, written by Roman Dobias
# This provides automated authentification to access limited-access records
# Arguments:
# toggle parts
# Use login at first
#./login.sh
#------------------------------------------------------------------------------
# Download the list of school years/terms and let user choose one
#------------------------------------------------------------------------------
YEARS=`curl -sS -i -L -k -b login-cookie https://video1.fit.vutbr.cz/av/records-categ.php?id=1 | iconv -f ISO-8859-2 -t UTF-8 | grep "<li " | sed 's/.*id=\([0-9]*\) class.*>\(.*\)<\/a>.*/"\1" "\2"/' | tr '\n' ' '`
OPTION=$(echo "$YEARS" | xargs whiptail --title "Choose the year: " --notags --cancel-button "Return back" --menu "Choose streaming year" 25 78 16 3>&1 1>&2 2>&3)
# Test if <Cancel> was pushed. If it was, return back / exit script.
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
exit 0
fi
#echo $OPTION
#------------------------------------------------------------------------------
# Download the list of subjects in given term and let him choose one
#------------------------------------------------------------------------------
# Get list of years
SUBJECTS=`curl -sS -i -L -k -b login-cookie https://video1.fit.vutbr.cz/av/records-categ.php?id=$OPTION | iconv -f ISO-8859-2 -t UTF-8 | grep "<li " | sed 's/.*id=\([0-9]*\) class.*>\(.*\)<\/a>.*/"\1" "\2"/' | tr '\n' ' '`
SUBJECT=$(echo "$SUBJECTS" | xargs whiptail --title "Choose the subject: " --cancel-button "Return back" --notags --menu "Choose streaming year" 25 78 16 3>&1 1>&2 2>&3)
# Test if <Cancel> was pushed. If it was, return back / exit script.
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
exit 0
fi
# Toggle default ON/OFF
TOGGLE="ON"
# Get list of records
RECORDS=`curl -sS -i -L -k -b login-cookie https://video1.fit.vutbr.cz/av/records-categ.php?id=$SUBJECT| iconv -f ISO-8859-2 -t UTF-8 | grep "<li " | sed "s/<\/b><\/a><div style=\"margin-left: 20px\">/ /" | sed "s/.*id=\(.*\)&.*<b>\(.*\)<\/div>.*/'\1' '\2' '$TOGGLE'/"`
#TODO - disable / remove already queued / downloaded lectures
RECORD=$(echo "$RECORDS" | xargs whiptail --title "Choose which records you wanna download: " --separate-output --notags --checklist "Choose streaming year" 25 78 16 3>&1 1>&2 2>&3)
#------------------------------------------------------------------------------
# Append lectures to queue
#------------------------------------------------------------------------------
LIST=`echo "$RECORD" | tr ' ' '\n'`
echo "$LIST" >> downloadQueue
# Take care of duplicates
TMP=`cat downloadQueue | sort |uniq`
echo "$TMP" > downloadQueue