Flaming Candle
|
Posted - 2008.11.26 14:28:00 -
[1]
My Additions to the script, since I have multiple characters, I thought that changing the script each time to get the skill in training was a little like effort!
Originally by: Script
#!/bin/sh # # Based on the script found at: # http://oldforums.eveonline.com/?a=topic&threadID=929881 # Modified by Flaming Candle # # More advanced caching of the skill tree. # Now capable of handling multiple accounts. # Picks up the character name and displays it # # Uses an input file, where each line represents # a character and each line has the format: # <userid>,<apiKey>,<characterID> # #
GetDefaults() { USERID="" APIKEY="" CHARID="" #FILL ABOVE FIELDS PAGE="http://api.eve-online.com" TREE=`Query "/eve/SkillTree.xml.aspx"` }
Query() { curl "${PAGE}${1}" --data "userID=${USERID}" --data "apikey=${APIKEY}" --data "characterID=${CHARID}" 2>/dev/null }
SkillTraining() { char=`Query "/account/Characters.xml.aspx"` ans=`Query "/char/SkillInTraining.xml.aspx"`
charName=$(echo $char | grep "${CHARID}" | sed 's/.*name="\(.[^"]*\)" characterID="'${CHARID}'".*/\1/') bit=`echo -e "${ans}" | grep '<skillInTraining>' | awk -F '>' '{ print $2 }' | awk -F '<' '{ print $1 }'` skillid=`echo -e "${ans}" | grep '<trainingTypeID>' | awk -F '>' '{ print $2 }' | awk -F '<' '{ print $1 }'` skillname=`echo -e "${TREE}" | grep -e ".*typeName.*typeID=\"${skillid}\"" | awk -F "\"" '{print $2}'` tolevel=`echo -e "${ans}" | grep '<trainingToLevel>' | awk -F '>' '{ print $2 }' | awk -F '<' '{ print $1 }'` curtime=`echo -e "${ans}" | grep '<currentTQTime' | awk -F '>' '{ print $2 }' | awk -F '<' '{ print $1 }'` endtime=`echo -e "${ans}" | grep '<trainingEndTime>' | awk -F '>' '{ print $2 }' | awk -F '<' '{ print $1 }'` localtime=`date +%Y" "%m" "%d" "%H" "%M" "%S` #echo "$ans"
echo "Character: ${charName}" if [ "${bit}" = "0" ]; then { echo "Not training!" exit 1 } else { echo "Training: ${skillname} ${tolevel} " awk -v curtime="${curtime}" -v endtime="${endtime}" -v localtime="${localtime}" ' BEGIN { gsub(/-/, " ", curtime) gsub(/:/, " ", curtime) cts=mktime(curtime) #EVE current time gsub(/-/, " ", endtime) gsub(/:/, " ", endtime) ets=mktime(endtime) #EVE end time gsub(/-/, " ", starttime) gsub(/:/, " ", starttime) lts=mktime(localtime) #local time diff=ets-cts #Time left lets=lts+diff #Local end time days=int(diff/60/60/24) diff=diff-(days*24*60*60) hours=int(diff/60/60) diff=diff-(hours*60*60) minutes=int(diff/60) diff=diff-(minutes*60) seconds=diff printf("Time left: "days" days, "hours" hours, "minutes" minutes, "seconds" seconds\n") printf("Will finish at: "strftime("%Y-%m-%d %H:%M:%S",lets)"\n") } ' } fi }
GetDefaults
# parse the input file. if [[ ! -a $1 ]]; then echo "please specify an input file as the first argument." exit 0 fi
cat $1 | while read LINE do USERID=$(echo $LINE | cut -d , -f 1); APIKEY=$(echo $LINE | cut -d , -f 2); CHARID=$(echo $LINE | cut -d , -f 3); SkillTraining; echo; done
|