This topic is a follow on from
http://www.markontech.com/2006/12/22/do ... -and-bash/
that describes how to download links to files found on rapidshare.com
environment: 1) Sitting behind my Dell M70 at mercedes bodyshop manufacturing facility
in south africa, Ease London (New C-Class Merc) thinking about how i
can improve the cycle time on my KUKA robot cell (B-Pillar)
time: 1) 2 hrs... ok so im no guru globber, at least it works
Requirements: 1) An all spectacular standard gentoo/linux system (also works
on CYGWIN or any other linux box)
2) latest version of wget (beowu1f system= GNU Wget 1.10.2 )
3) An active rapidshare.com account with username and password
4) Direct Downloads option set to ON in rapidshare.com options menu
5) A never ending curiosity of how things work!
Changes: 1) Support for getopts is included [getopt(1) is now
deprecated]
2) This script also works in CYGWIN since CYGWIN does
not include getopt(1) at all!
3) GNU Wget 1.10.2 has a new --no-check-certificate option
that must be passed in order to gain access to rapidshare.com
and download the premiumzone.cgi page
4) Have Fun!
The Code: origionally written by Mark Sullivan ( thank you Mark )
1) first (main) BASH script
BashGet.sh
#!/bin/bash
# File Name: BashGet.sh
# Author: Mark Sullivan
# Edited by beowu1f: 1) Support for getopts is included [getopt(1) is now
# deprecated]
# 2) This script also works in CYGWIN since CYGWIN does
# not include getopt(1) at all!
# 3) GNU Wget 1.10.2 has a new --no-check-certificate option
# that must be passed in order to gain access to rapidshare.com
# and download the premiumzone.cgi page
# 4) Have Fun!
while getopts u:p:l: choice
do
case "$choice" in
u) user="$OPTARG";;
p) pass="$OPTARG";;
l) url="$OPTARG";;
[?]) echo; echo "Usage: $0 -u <username> -p <password> -l <URL> --> terminating..."; \
echo >&2; exit 1;;
esac
done
UserData=$(echo "-u " $user "-p " $pass "-u " $url)
#colour definitions
RED='\e[1;31m';CYAN='\e[1;36m';NC='\e[0m';BL='\e[1;34m';GR='\e[0;32m';YEL='\e[1;33m';DG='\e[1;30m'
echo
echo -e ${RED}
echo "****************************************************************************" >&2
echo "***Remember to turn on 'Direct Downloads' in rapidshare.com online setup!***" >&2
echo -e "****************************************************************************" >&2
echo -e ${NC}
echo
echo "<>-- your user data entered --<>"
echo $UserData
echo
echo -e ${CYAN}real URL:${NC}$url
fileName=`basename $url`
echo -e ${CYAN}Filename:${NC}$fileName
cookie=cookie
## LOGIN and save cookie ##
wget --save-cookies=$cookie -q --post-data="login=$user&password=$pass" \
https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi --no-check-certificate
echo
rm premiumzone.cgi
echo -e "${CYAN}downloading: ${BL}$fileName${NC} ..."
wget --load-cookies=$cookie -q $url -O ./downloads/$fileName --no-check-certificate
if [ $? == 0 ]
then
echo -e ${DG} "downloading complete! ${BL} [${GR} OK ${BL}]" >&2
else
echo -e ${RED} "wget did not complete. downloading failed!" ${NC} >&2; exit 1
fi
##############################################################################
My main reason for implementing getopts was for CYGWIN support. where ever i travel
i need to connect to my winblows machine at home and download various items.
2) then create this second script...RapDownload.sh
#!/bin/bash
# File Name: RapDownload.sh
# Author: Mark Sullivan
# Edited by beowu1f
# NOTE: change <username> to your rapidshare.com username
# change <password> to your rapidshare.com password
for url in `cat $1`
do
./BashGet.sh -u <username> -p <password> -l $url
done
##############################################################################
3) Be sure to change your username & password as indicated in the above script
4) Now make sure both scripts are executable by issueing:
$ chmod +x BashGet.sh RapDownload.sh
5) Next place all the links your interested in downloading from rapidshare.com
into any text file. (eg. vim files)
Mine looks something like this:
http://rapidshare.com/files/26270733/It ... t.pdf.html
6) make sure you have a downloads directory inside the current directory your
newly created scripts are in. Issue the command
$ mkdir downloads
7) You're now ready to try out your script. Issue the script command
$ ./RapDownload.sh files
and away you go! pretty colours and all!
Hope this has helped you on your journey to downloading from rapidshare.com
Once again thanks goes to Mark for all your support and good globbing!
beowu1f
[/b][/post]
