Skip to content

Instantly share code, notes, and snippets.

@Siarkowy
Last active January 24, 2016 00:49
Show Gist options
  • Save Siarkowy/d91c8487b5459c8512f5 to your computer and use it in GitHub Desktop.
Save Siarkowy/d91c8487b5459c8512f5 to your computer and use it in GitHub Desktop.
HellGround boss fights notifier for Linux
#!/bin/bash
# HellGround boss fights notifier
#
# This utility checks periodically for boss slains and notifies you of them.
# You may want to set this script to start when you login.
# The MIT License (MIT)
#
# Copyright (c) 2016 Siarkowy
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
BASE_URL="https://hellground.net"
GUILD="Liga+Dzentelmenow"
NOTIFY_DURATION=$((3 * 60 * 1000))
FIGHTS_CHECK_INTERVAL="10m"
LAST_BOSS_FILE="$HOME/.last_boss"
touch "$LAST_BOSS_FILE"
LAST_BOSS=$(cat "$LAST_BOSS_FILE")
get_url() {
curl "$1" 2>/dev/null |
tidy 2>/dev/null |
sed -e "s#<\(/\?\)\(article\|section\|aside\|footer\|header\)#<\1div#g" -e 's#id="toppvp_realm_2"# #g'
}
get_boss_fights() {
get_url "${BASE_URL}/boss_fights/index/1?searchString=${GUILD}&sortTime=default&searchTime=all"
}
xpath() {
xmllint --html --xpath "$1" -
}
while true; do
BOSS_LOG=$(get_boss_fights)
NEXT_BOSS=$(echo "$BOSS_LOG" | xpath "(//div[@class = 'fightListRow']//a)[1]//text()")
if [ "$LAST_BOSS" != "$NEXT_BOSS" ]; then
LAST_BOSS="$NEXT_BOSS"
echo "$LAST_BOSS" > "$LAST_BOSS_FILE"
DETAIL_URL=$(echo "$BOSS_LOG" | xpath "string((//div[@class = 'fightListRow']//a)[4]/@href)")
DETAILS=$(get_url "$BASE_URL$DETAIL_URL")
LOOT=$(echo $DETAILS | xpath "//a[contains(@href, '?item=')]/text()" | sed -e "s#\([^$]\)\([0-9]x\)#\1\n\2#g")
notify-send -i joystick -t $NOTIFY_DURATION "$LAST_BOSS has been slain" "$LOOT\n\n<a href='$BASE_URL$DETAIL_URL'>More details</a>"
fi
sleep $FIGHTS_CHECK_INTERVAL
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment