lunes, 18 de agosto de 2008

Script Rapidshare.

A dia de hoy funciona, aunque a nada que cambien la web dejará de hacerlo y no creo que lo actualice:
http://www.unsec.net/rapid.sh




#!/bin/bash
if [ -z $1 ]; then echo "$0 [url|file]";exit; fi
if [ -f $1 ]; then file=$1; else url=$1; fi

function dwn() {
echo -e "\nDownloading ($n/$total): $url"
html_n1=`curl -s $url`
url_n1=`echo "$html_n1"|grep 'id="ff"'|sed -e 's/.*action="\(.*\)" m.*/\1/'`
if [[ "$html_n1" == *"could not be found"* ]]; then
echo "Error: File not found"; exit
fi
html_n2=`curl -s -d "dl.start=Free" $url_n1`
nsleep=`echo "$html_n2" | grep 'var c'|sed -e 's/var c=\(.*\);.*/\1/'`
if [[ "$html_n2" == *"is already downloading a file"* ]]; then
echo "Error: already downloading a file"; exit
fi
if [ -n $nsleep ]; then
url_n2=`echo "$html_n2"|grep "var tt"|sed -e 's/.*action="\(.*\)" m.*/\1/'`
echo "Sleeping: $nsleep secs."
sleep $nsleep
echo "Done. filename: `basename $url`"
curl -d "mirror=on&x=30&y=32" $url_n2 -O
else
echo "Error. Try later"
fi
}

if [ -f $1 ]; then
total=`cat $file|wc -l`
n=0
for url in `cat $file`; do
n=$(( $n + 1 ))
dwn $url $n
done
else
total=1; n=1; dwn $url
fi