#!/bin/bash
# /usr/local/bin/drobodownload
# http://crystalfaeries.net/posix/bin/drobodownload
# celeste:crystalfaery Thu-Oct-17-20-51-42-UTC-2013
cd /Users/`whoami`/downloads || cd /Users/`whoami`/Downloads || exit 1
let sleep=1
while sleep $sleep
do
let sleep=$sleep+$sleep # Binary BackOff
domain="`head -n 1 ~/documents/playlists/drobo.txt`"
tail -n +2 ~/documents/playlists/drobo.txt > ~/documents/playlists/$$.drobo.txt
mv ~/documents/playlists/$$.drobo.txt ~/documents/playlists/drobo.txt
url="$(echo $domain | sed 's/\/\/www\./\/\//')" # throw away any leading "www."
domain="$(echo $url | sed 's/^http.*:\/\/// ; s/^ftp.*:\/\/// ; s/\/.*$//')" # does any website not alias {www.,}
if [ "X$domain" == "X" ]
then
echo "$url is malformed or edit the seds in $0"
else
mkdir -p "$domain" || exit -1
echo "======= `/usr/local/bin/now` Begin `jobs -l | cut -f 1` Downloading $url =======" | tee -a "$domain"/.wget.txt
wget -m -k -K -E -nv -np -w 60 --random-wait --no-check-certificate "$url" >> "$domain"/.wget.txt 2>&1 &
disown %1 # daemonize in the background
fi
done
syntax highlighted by Code2HTML, v. 0.9.1