Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- USERNAME=""
- PASSWORD=""
- INTERVAL="2m"
- TIMEOUT=10000
- COOKIEFILE="/tmp/hup.hu.cookies"
- EXITFILE="/tmp/hup.hu.exit"
- ICONFILE="/tmp/hup.hu.png"
- NEEDAPPS="notify-send wget sed"
- if [ "$1" == "-q" ]; then
- touch "${EXITFILE}"
- kill $(ps x | grep "sleep ${INTERVAL}" | grep -v grep | sed 's/\([0-9]\+\).*/\1/') 2>&1 >/dev/null
- exit 0
- fi
- for APP in $NEEDAPPS; do
- if ! type -P $APP >/dev/null; then
- echo "You need ${APP} to run this script."
- exit 1
- fi
- done
- function CleanUp {
- rm -f "${COOKIEFILE}"
- rm -f "${ICONFILE}"
- rm -f "${EXITFILE}"
- }
- CleanUp
- # HUP Login
- USERID=$(wget -q -O- --keep-session-cookies \
- --save-cookies "${COOKIEFILE}" \
- --post-data="name=${USERNAME}&pass=${PASSWORD}&op=Bel%C3%A9p%C3%A9s&form_id=user_login_block" \
- "http://hup.hu/modules.php?destination=node" | \
- sed -n '/<li\ class="leaf"><a\ href="\/user\//s/.*\/user\/\([0-9]\+\)\">saj.*/\1/p')
- if [ "_$USERID" == "_" ]; then
- echo "Could not log in, or cannot find user ID."
- exit 1
- fi
- # Get the logo
- if [ ! -f "${ICONFILE}" ]; then
- wget -q -O"${ICONFILE}" 'http://hup.hu/images/powered/hup_main.png'
- fi
- # Get new message info
- while [ ! -f "${EXITFILE}" ]; do
- wget -q -O- --keep-session-cookies \
- --save-cookies "${COOKIEFILE}" \
- --load-cookies "${COOKIEFILE}" \
- "http://hup.hu/user/${USERID}/track" | tr ":" ";" | \
- sed -n '/\(node\|cikkek\)\/[0-9]\+\(\/[A-Za-z0-9_]\+\)\?#new/s/.*\/\(node\|cikkek\)\/[0-9]\+\(\/[A-Za-z0-9_]\+\)\?\">\(.*\)<\/a>\s*<span\ class.*\/\(node\|cikkek\)\/\([0-9]\+\)\(\/[A-Za-z0-9_]\+\)\?#new\">\([0-9]\+\)\ .*<td>\(.*\)<\/td>.*/\3:\1:\5:\6:\7:\8/p' | \
- while IFS=: read TITLE TYPE NUM URL NEW TIME; do
- HUPURL="http://hup.hu/${TYPE}/${NUM}${URL}#new"
- notify-send -i "${ICONFILE}" -u low -t ${TIMEOUT} "${TITLE}" "${NEW} új üzenet
- ${TIME}
- <a href=\"${HUPURL}\">${HUPURL}</a>" &
- done
- sleep "${INTERVAL}"
- done
- CleanUp
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement