09.12.2021
TUTORIAL: Using shell terminal (MacOSX,Linux) to DL/UL from Rapidshare Premium with cURL
This guide explains how to use terminal commands to download and upload from rapidshare.com. The utility we will be using is called cURL, an open source command-line HTTP tool. cURL comes standard with MacOSX, and can be installed easily with Linux (for example, to install on a Debian-based OS, like Ubuntu, just type the command sudo apt-get install curl). All these commands are done from the user’s home directory.
Step 1: Logging in to your Rapidshare premium account
curl -k -c /.rapidshare -d ’login=USERID&password=PASSWORD' ‘https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi'
This command will go to the Rapidshare login page and submit your username and password to log in. It will also create a file in your root directory called ‘.rapidshare’. This file contains your login cookie. Once this file is created, you’ll never have to login again. Of course, replace USERID and PASSWORD with your information.
Let me explain the switches used here with the ‘curl’ command. ‘-k’ allows curl to access SSL (https) pages. ‘-c’ writes a cookie file. ‘-d’ sends form data.
Step 2: Downloading from Rapidshare
curl -L -O -b /.rapidshare ‘URL’
This command will access your cookie file and send the data along with the ‘-b’ switch. ‘-L’ follows the url if it forwards (which Rapidshare file urls do). ‘-O’ will write the file to your local disk with the same file name. You can also use a switch to limit your download rate (–limit-rate 100K). Of course, replace URL with your rapidshare file url.
Step 3: Uploading to Rapidshare
curl -k -b /.rapidshare -# https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi |
grep ‘action=“http://rs[0-9]*[a-z]*.rapidshare.com/cgi-bin/upload.cgi?rsuploadid=[0-9]*’ |
sed ’s/<form name=“ul” method=“post” action=”//g’ |
sed “s/” enctype=“multipart.form-data” onsubmit=“document.ul.u.value=‘Uploading…’;
document.ul.u.disabled=true”>//g" |
sed “s/(.*)/–url 1/” |
curl -o /.rapidtemp -F “login=USERID” -F “password=PASSWORD” -F
“filecontent=@NAME_OF_FILE_TO_UPLOAD” –config -
This command will upload a file to your Rapidshare premium account. What it does is access your main premium page to find the upload url, which is dynamic, and parses it out for use in the final command of the pipe, the upload command. Be sure to replace USERID, PASSWORD, and NAME_OF_FILE_TO_UPLOAD. This command creates a temp file called .rapidtemp, because cURL won’t display upload progress in the terminal without writing the output to a file. You may also use –limit-rate in the final command there, to limit your upload rate if necessary.
Step 4: Creating a shell script
To create a shell script to download multiple files, start with a text editor. Your first line should be:
#!/bin/bash
Then put in all your download and/or upload commands. Save the file. Then you must make the file executable in terminal:
chmod +x name_of_shell_script_file
Finally, run the script:
./name_of_shell_script_file
Step 5: Creating a new shell commands
Now, you can create shell scripts that become custom commands for you. For example, I created a file called ‘rapidget’, which contains:
#!/bin/sh rapidurl=$1 curl -L -O -b /.rapidshare $rapidurl
I saved the file, then copied it to /usr/local/bin, and chmodd +x it (You may need root access to do this: try the command ‘sudo su’).
Now I can use this command to download from terminal:
rapidget RAPIDSHARE_FILE_URL
And for for uploading I call this command ‘rapidup’:
#!/bin/sh rapidfile=$1 curl -k -b /.rapidshare -# https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi |
grep ‘action=“http://rs[0-9]*[a-z]*.rapidshare.com/cgi-bin/upload.cgi?rsuploadid=[0-9]*’ |
sed ’s/<form name=“ul” method=“post” action=”//g’ |
sed “s/” enctype=“multipart.form-data” onsubmit=“document.ul.u.value=‘Uploading…’;
document.ul.u.disabled=true”>//g" |
sed “s/(.*)/–url 1/” | curl -o /.rapidtemp -F “login=USERID” -F “password=PASSWORD” -F
“filecontent=@$rapidfile” –config -
To upload, I just navigate to the file’s directory and:
rapidup NAME_OF_FILE.rar