Skip to content

Instantly share code, notes, and snippets.

@jjjake
Created October 3, 2012 22:32
Show Gist options
  • Save jjjake/3830314 to your computer and use it in GitHub Desktop.
Save jjjake/3830314 to your computer and use it in GitHub Desktop.
taskid="$1"
log=$(curl -s "http://www-tracey.us.archive.org/log_show.php?task_id=$taskid&full=1")
filepath=$(echo $log | grep -Po '(?<=\[dir\]\ \=\>\ )/14/items/archiveteam-mobileme-hero-9' | head -1)
node=$(echo $log | grep -Po '(?<=\[server).*?(?=.us.archive.org)' | head -1 | grep -Po 'ia6[0-9]{5}')
itemsize_url="http://$node.us.archive.org/item-size.php?path=$filepath"
# Item size in KB
_itemsize=$(curl -s "$itemsize_url" | grep -Po '(?<=\<size\>).*(?=\</size\>)')
# Convert to GB
itemsize=$(echo "$_itemsize/1000000" | bc)
nodespace_url="http://www.us.archive.org/control/shuffle.php?VIEWLOG-COUNT=100&SPECIFIC_NODE=$node"
disk_number=$(echo $filepath | cut -d/ -f2)
# Space left on device in GB
space_on_device=$(curl -sn --cookie "logged-in-sig=$LOGGED_IN_SIG; logged-in-user=$LOGGED_IN_USER" "$nodespace_url" |
grep -Po "(?<=$disk_number\ \=\>).*?(?=\</div\>)" |
sed 's/\ //g')
echo "\ntaskid:\t$taskid\nItemsize:\t$itemsize\nSpace left on device:\t$space_on_device\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment