Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #function pricecheck {
- #pricestr=$(curl -s "http://magictcgprices.appspot.com/api/tcgplayer/price.json?cardname=$(echo $1 | sed 's/ /%20/g')")
- #echo $pricestr | sed 's/\[\"$[0-9.]*\", \"$\([0-9.]*\)\", \"$[0-9.]*\"\]/\1/g'
- #}
- function pricecheck {
- cat $name | sed 's/<\/TR>/\n/g' | grep "$1" | grep -o '$[0-9,.]*' | tr -d '$,' | awk 'NR==2 {print}'
- }
- function linecount {
- wc -l $1 | awk '{print $1}'
- }
- function nameextract {
- cat $1 | sed 's/<\/TR>/<\/TR>\n/g' | grep "<td width=30 align=left valign=center><font class=default_7> $2<\/font><\/td>" | grep -o '<TR height=20><td width=200 align=left valign=center><font class=default_7> \([a-zA-Z0-9, -]*\)<\/font><\/td>' | sed 's/<TR height=20><td width=200 align=left valign=center><font class=default_7> \([a-zA-Z0-9, -]*\)<\/font><\/td>/\1/g'
- }
- while [ $# -gt 0 ] ; do
- case "$1" in
- -s) s=1 ; shift ;;
- *) name=$1 ; shift ;;
- esac
- done
- nameextract $name R > $name.rarelist
- nameextract $name M > $name.mrarelist
- nameextract $name U > $name.uncommonlist
- nameextract $name C > $name.commonlist
- rsum=0
- for i in $(seq 1 $(linecount $name.rarelist))
- do
- [ ! -n "$s" ] && echo $(head -n $i $name.rarelist | tail -n 1) $(pricecheck "$(head -n $i $name.rarelist | tail -n 1)")
- rsum=$(echo "scale=5; $rsum + 7/8*$(pricecheck "$(head -n $i $name.rarelist | tail -n 1)")/$(linecount $name.rarelist)" | bc)
- [ ! -n "$s" ] && echo $rsum
- done
- for i in $(seq 1 $(linecount $name.mrarelist))
- do
- [ ! -n "$s" ] && echo $(head -n $i $name.mrarelist | tail -n 1) $(pricecheck "$(head -n $i $name.mrarelist | tail -n 1)")
- rsum=$(echo "scale=5; $rsum + 1/8*$(pricecheck "$(head -n $i $name.mrarelist | tail -n 1)")/$(linecount $name.mrarelist)" | bc)
- [ ! -n "$s" ] && echo $rsum
- done
- [ ! -n "$s" ] && echo "RARESLOT EV: $rsum"
- csum=0
- for i in $(seq 1 $(linecount $name.commonlist))
- do
- [ ! -n "$s" ] && echo $(head -n $i $name.commonlist | tail -n 1) $(pricecheck "$(head -n $i $name.commonlist | tail -n 1)")
- csum=$(echo "scale=5; $csum + $(pricecheck "$(head -n $i $name.commonlist | tail -n 1)")/$(linecount $name.commonlist)" | bc)
- [ ! -n "$s" ] && echo $csum
- done
- [ ! -n "$s" ] && echo "COMMONSLOT EV: $csum"
- usum=0
- for i in $(seq 1 $(linecount $name.uncommonlist))
- do
- [ ! -n "$s" ] && echo $(head -n $i $name.uncommonlist | tail -n 1) $(pricecheck "$(head -n $i $name.uncommonlist | tail -n 1)")
- usum=$(echo "scale=5; $usum + $(pricecheck "$(head -n $i $name.uncommonlist | tail -n 1)")/$(linecount $name.uncommonlist)" | bc)
- [ ! -n "$s" ] && echo $usum
- done
- [ ! -n "$s" ] && echo "UNCOMMONSLOT EV: $usum"
- [ ! -n "$s" ] && echo "$csum $usum $rsum"
- [ ! -n "$s" ] && echo "PACK VALUE: $(echo "scale=5; 11*$csum + 3*$usum + $rsum" | bc)" || echo "$(echo "scale=5; 11*$csum + 3*$usum + $rsum" | bc)"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement