Skip to content

Instantly share code, notes, and snippets.

@davidreuss
Created November 6, 2009 19:59
Show Gist options
  • Save davidreuss/228228 to your computer and use it in GitHub Desktop.
Save davidreuss/228228 to your computer and use it in GitHub Desktop.
#!/bin/bash
username=""
password=""
firstbytes=5000
lastbytes=5000
cookie="rapidshare.cookie"
curl -s -k -c "$cookie" -d "login="$username"&password="$password"" https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi &> /dev/null
mkdir -p downloads || {
echo "Could not create download dir"
exit 1
}
[ -f "$cookie" ] || {
echo "Rapid share cookie not found"
exit 1
}
for url in $(cat list.txt); do
echo "Updating url: -> $url"
filename=$(basename $url)
# fetch headers
length=$(curl -s -I "$url" | grep Content-Length | perl -ne '/(\d+)/ and print $1')
if [ "$length" -gt 0 ]; then
# first bytes
#curl -s -L --range 0-5000 --cookie rapidshare.cookie "$url"
curl -s -L --range 0-"$firstbytes" --cookie "$cookie" "$url" > downloads/first_"${filename}"
# last bytes
#curl -s -L --range $(($length-5000))- --cookie rapidshare.cookie "$url"
curl -s -L --range $(($length-$lastbytes))- --cookie "$cookie" "$url" > downloads/last_"${filename}"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment