Created
February 10, 2012 23:17
-
-
Save gist777/1793925 to your computer and use it in GitHub Desktop.
Check what ddo raids are on timer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USERNAME="xxxchangemexxx" | |
COOKIE="cookies.txt" | |
URL="http://my.ddo.com" | |
RAIDLIST="Accursed Ascension,The Titan Awakes,The Chronoscope,Hound of Xoriat,The Thirteenth Eclipse,A Vision of Destruction,The Reaver's Fate,The Vault of Night,The Devil You Know,Against the Demon Queen,The Master Artificer,The Lord of Blades" | |
VERS=.1 | |
DEBUG=${DEBUG:-0} | |
RAIDTIMER=237600 | |
CURTIME=$(date +%s) | |
let TIMER=$CURTIME-$RAIDTIMER | |
if ! type wget &>/dev/null; then | |
echo "Couldn't find wget on your system. Please install wget." | |
exit | |
fi | |
usage() | |
{ | |
echo "$0, version $VERS" | |
echo "Usage: checktimers [-v] [-h] [-u userid] [-l] [-a]" | |
echo "-v, -h: this help" | |
echo "-u: ddo forum userid" | |
echo "-l: ask for password (caches cookies in file $COOKIE)" | |
echo "-a: show all quests" | |
} | |
check_raid() | |
{ | |
# character name/quest name/completion date | |
if [ "xxx$QUESTLIST" != "xxx" ]; then | |
printf "%-18s %-24s %-30s\n" "$1" "$2" "$(date -d @$3)" | |
elif echo "$RAIDLIST" | grep -q "$2"; then | |
let TIMELEFT=$3+$RAIDTIMER | |
printf "%-18s %-24s %-30s %-30s\n" "$1" "$2" "$(date -d @$3)" "$(date -d @$TIMELEFT)" | |
fi | |
} | |
while [[ $1 ]]; do | |
if [ "$1" == "-v" ] || [ "$1" == "-h" ]; then | |
usage | |
exit | |
fi | |
if [ "$1" == "-u" ]; then | |
# userid | |
USERNAME="$2" | |
shift 2 | |
fi | |
if [ "$1" == "-l" ]; then | |
# login | |
read -sep "password: " | |
echo | |
if [ "xxx$REPLY" == "xxx" ]; then | |
exit | |
fi | |
PASS=$(echo -n $REPLY | xxd -p | sed 's/\(..\)/%\1/g') | |
wget -q \ | |
--save-cookies $COOKIE --keep-session-cookies \ | |
--post-data "log=$USERNAME&pwd=$PASS&redirect_to=%2F" \ | |
-O /dev/null \ | |
$URL/wp-login.php | |
RET=$? | |
if [ $RET -ne 0 ]; then | |
echo "sorry, had some type of problem logging into account \"$USERNAME\"" | |
exit | |
fi | |
shift | |
fi | |
if [ "$1" == "-a" ]; then | |
# show all quests | |
QUESTLIST=1 | |
shift | |
fi | |
done; | |
# main | |
PAGE=1 | |
while [[ $PAGE > 0 ]]; do | |
SANITY=0 | |
while read EVENT; do | |
if [ "xxx$EVENT" = "xxx" ]; then | |
echo "empty line, try logging in with -l?" | |
PAGE=0 | |
break; | |
fi | |
if [ "xxx$DEBUG" = "xxx1" ]; then | |
echo "DEBUG: EVENT=$EVENT" | |
fi | |
SANITY=1 | |
DDOCHAR=$(echo $EVENT | egrep -o 'title="[^".]+' | head -n 1) | |
DDOCHAR=${DDOCHAR#title=\"} | |
# echo $DDOCHAR | |
DDOQUEST=$(echo $EVENT | egrep -o 'title="[^".]+' | tail -n 1) | |
DDOQUEST=${DDOQUEST#title=\"Completed Quest \'} | |
DDOQUEST=${DDOQUEST%\'} | |
# echo $DDOQUEST | |
DDODATE=$(echo $EVENT | egrep -o 'class="clog_event_date">[^<.]+') | |
DDODATE=$(date -d "${DDODATE#class=\"clog_event_date\"\>}" +%s) | |
# echo $DDODATE | |
if [[ $DDODATE < $TIMER ]]; then | |
PAGE=0 | |
break; | |
fi | |
check_raid "$DDOCHAR" "$DDOQUEST" "$DDODATE" | |
done < <(wget -q \ | |
--load-cookies $COOKIE \ | |
-O - \ | |
"$URL/$USERNAME/log/?page=$PAGE&filters_flat=268435519" | \ | |
grep '<td class="left event">') | |
if [ $SANITY -eq 0 ]; then | |
echo "something went wrong, sorry." | |
usage | |
exit | |
fi | |
if [[ $PAGE > 0 ]]; then | |
let PAGE++ | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment