Thursday, February 11, 2010

Downloading from Rapidshare using WGet

Wget is an extremely powerful command line tool to download files. Apart from the ability to use it to do recursive, relative downloading and thus leech complete websites for certain specific file types, the usage of wget can be customized to achieve various objectives.

When I am on windows, I use a great tool for downloading rapidshare files called the free download manager and this is something i missed in linux. So here it goes.

First you need to save your login information into rapidshare. (yes, a premium account).

#!/bin/sh

wget \

–save-cookies ~/.cookies/rapidshare \

–post-data “login=&password=” \

-O – \

https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi \

> /dev/null



This simple script has to be run once and this will save your account cookie on your computer.

Now, we need the script to download the files using wget into a particular location. Lets assume that location is “/home/bijur/hack/dwnld/”.


#!/bin/sh

cd /home/bijur/hack/dwnld/

if [ -f /home/bijur/hack/dwnld/down ]

then

mv down down_in_progress

wget -b -nd -q -c –load-cookies ~/.cookies/rapidshare -i /home/bijur/hack/dwnld/down_in_progress

echo `date` >>/tmp/down-sh-log.log

echo “Ran and downloaded the following:” >>/tmp/down-sh-log.log

cat /home/bijur/hack/dwnld/down_in_progress >> /tmp/down-sh-log.log

echo “———————————” >>/tmp/down-sh-log.log

fi



Let us save this script as .down.sh. (The . In the beginning of the file makes it a hidden file). The script checks for the existence of a text file “down” in the folder. If it finds one it will launch a wget for all the links in that file.

Third, we do not want to be launching this script every single time. So we can either have this as a nautilus script or a cron. For simplicity (and sticking to concepts already known ;) ), lets use a cron.

On the shell launch the command “crontab -e”. This if launched for the first time will ask you to chose for your favourite editor and launch it. In the crontab file enter the following line:


*/5 * * * * /home/bijur/hack/dwnld/.down.sh

Thats it!! Now everytime you want to download a set of files. Simply create a text file in the directory “/home/bijur/hack/dwnld/” by the name “down”. Within 5 minutes, you should start seeing action!

Note: This script was developed by me about 3 years back and was posted on my blog then. Since then I have lost that blog and have posted this merely as an attempt to save this piece of code.

No comments:

Post a Comment