Want more features on Pastebin? Sign Up, it's FREE!
Guest

PriceCheck

By: KiteX3 on Jan 13th, 2014  |  syntax: Bash  |  size: 2.82 KB  |  views: 156  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2.  
  3. #function pricecheck {
  4. #pricestr=$(curl -s "http://magictcgprices.appspot.com/api/tcgplayer/price.json?cardname=$(echo $1 | sed 's/ /%20/g')")
  5. #echo $pricestr | sed 's/\[\"$[0-9.]*\", \"$\([0-9.]*\)\", \"$[0-9.]*\"\]/\1/g'
  6. #}
  7.  
  8. function pricecheck {
  9. cat $name | sed 's/<\/TR>/\n/g' | grep "$1" | grep -o '$[0-9,.]*' | tr -d '$,' | awk 'NR==2 {print}'
  10. }
  11.  
  12. function linecount {
  13. wc -l $1 | awk '{print $1}'
  14. }
  15.  
  16. function nameextract {
  17. cat $1 | sed 's/<\/TR>/<\/TR>\n/g' | grep "<td width=30 align=left valign=center><font  class=default_7>&nbsp;$2<\/font><\/td>" | grep -o '<TR height=20><td width=200 align=left valign=center><font  class=default_7>&nbsp;\([a-zA-Z0-9, -]*\)<\/font><\/td>' | sed 's/<TR height=20><td width=200 align=left valign=center><font  class=default_7>&nbsp;\([a-zA-Z0-9, -]*\)<\/font><\/td>/\1/g'
  18. }
  19.  
  20. while [ $# -gt 0 ] ; do
  21.         case "$1" in
  22.                 -s) s=1 ; shift ;;
  23.                 *) name=$1 ; shift ;;
  24.          esac
  25. done
  26.  
  27. nameextract $name R > $name.rarelist
  28. nameextract $name M > $name.mrarelist
  29. nameextract $name U > $name.uncommonlist
  30. nameextract $name C > $name.commonlist
  31.  
  32. rsum=0
  33. for i in $(seq 1 $(linecount $name.rarelist))
  34. do
  35.         [ ! -n "$s" ] && echo $(head -n $i $name.rarelist | tail -n 1) $(pricecheck "$(head -n $i $name.rarelist | tail -n 1)")
  36.         rsum=$(echo "scale=5; $rsum + 7/8*$(pricecheck "$(head -n $i $name.rarelist | tail -n 1)")/$(linecount $name.rarelist)" | bc)
  37.         [ ! -n "$s" ] && echo $rsum
  38. done
  39. for i in $(seq 1 $(linecount $name.mrarelist))
  40. do
  41.         [ ! -n "$s" ] && echo $(head -n $i $name.mrarelist | tail -n 1) $(pricecheck "$(head -n $i $name.mrarelist | tail -n 1)")
  42.         rsum=$(echo "scale=5; $rsum + 1/8*$(pricecheck "$(head -n $i $name.mrarelist | tail -n 1)")/$(linecount $name.mrarelist)" | bc)
  43.         [ ! -n "$s" ] && echo $rsum
  44. done
  45. [ ! -n "$s" ] && echo "RARESLOT EV: $rsum"
  46.  
  47. csum=0
  48. for i in $(seq 1 $(linecount $name.commonlist))
  49. do
  50.         [ ! -n "$s" ] && echo $(head -n $i $name.commonlist | tail -n 1) $(pricecheck "$(head -n $i $name.commonlist | tail -n 1)")
  51.         csum=$(echo "scale=5; $csum + $(pricecheck "$(head -n $i $name.commonlist | tail -n 1)")/$(linecount $name.commonlist)" | bc)
  52.         [ ! -n "$s" ] && echo $csum
  53. done
  54. [ ! -n "$s" ] && echo "COMMONSLOT EV: $csum"
  55.  
  56. usum=0
  57. for i in $(seq 1 $(linecount $name.uncommonlist))
  58. do
  59.         [ ! -n "$s" ] && echo $(head -n $i $name.uncommonlist | tail -n 1) $(pricecheck "$(head -n $i $name.uncommonlist | tail -n 1)")
  60.         usum=$(echo "scale=5; $usum + $(pricecheck "$(head -n $i $name.uncommonlist | tail -n 1)")/$(linecount $name.uncommonlist)" | bc)
  61.         [ ! -n "$s" ] && echo $usum
  62. done
  63. [ ! -n "$s" ] && echo "UNCOMMONSLOT EV: $usum"
  64.  
  65. [ ! -n "$s" ] && echo "$csum $usum $rsum"
  66. [ ! -n "$s" ] && echo "PACK VALUE: $(echo "scale=5; 11*$csum + 3*$usum + $rsum" | bc)" || echo "$(echo "scale=5; 11*$csum + 3*$usum + $rsum" | bc)"
clone this paste RAW Paste Data