I have managed my own script in python for downloading files from rapidshare without premium account, but it was little buggy.
Some of my friends told me about some other project writed in bash that is using wget. It could be also easy implemented into current Download station - but when it's not... here is a simple HOWTO use it using QNAP box and shell.
Installation tutorial:
1. Download and install Optware in QPKG section (administration panel) and than Enable it!
- we will need it later for one thing
2. Logon to Your QNAP box using SSH or Telnet (eg. using PuTTY)
3. Now it's time to create a file... Just follow instructions:
In a console enter this:
- Code: Select all
# cd ..
# cd /share/Qdownload
It's time to create file called 'rapid.sh':
- Code: Select all
# vi rapid.sh
Put "i" on a keyboard - now You'll be able to write text in file...
Just select code bellowe and copy it to clipboard:
- Code: Select all
#!/bin/sh
#
# Download files from Rapidshare using free access (NOT premium accounts).
# Output files downloaded to standard output (one per line).
#
# Dependencies: sed, sleep, expr, wget.
#
# Web: http://code.google.com/p/megaupload-dl/wiki/RapidShare
# Contact: Arnau Sanchez <tokland@gmail.com>.
#
# License: GNU GPL v3.0: http://www.gnu.org/licenses/gpl-3.0-standalone.html
#
set -e
# Echo text to standard error.
#
debug() { echo "$@" >&2; }
# Get first line that matches a regular expression and extract string from it.
#
# $1: POSIX-regexp to filter (get only the first matching line).
# $2: POSIX-regexp to match (use parentheses) on the matched line.
#
parse() { sed -n "/$1/ s/^.*$2.*$/\1/p" | head -n1; }
# Check if a string ($2) matchs a regexp ($1)
#
match() { grep -q "$1" <<< "$2"; }
# Output a rapidshare file download URL given its rapidshare URL
#
# $1: A rapidshare URL
#
get_rapidshare_file_url() {
URL=$1
while true; do
WAIT_URL=$(wget -O - "$URL" | parse '<form' 'action="\(.*\)"')
test "$WAIT_URL" || { debug "can't get wait-page URL"; return 2; }
DATA=$(wget -O - --post-data="dl.start=Free" "$WAIT_URL")
test "$DATA" || { debug "can't get wait URL contents"; return 2; }
LIMIT=$(echo "$DATA" | parse "try again" "\([[:digit:]]\+\) minutes")
test -z "$LIMIT" && break
debug "download limit reached: waiting $LIMIT minutes"
sleep $((LIMIT*60))
done
FILE_URL=$(echo "$DATA" | parse "<form " 'action="\([^\"]*\)"')
SLEEP=$(echo "$DATA" | parse "^var c=" "c=\([[:digit:]]\+\);")
test "$FILE_URL" || { debug "can't get file URL"; return 2; }
debug "URL File: $FILE_URL"
test "$SLEEP" || { debug "can't get sleep time"; SLEEP=100; }
debug "Waiting $SLEEP seconds"
sleep $(($SLEEP + 1))
echo $FILE_URL
}
# Guess is item is a rapidshare URL, a generic URL (try bulk download)
# or a file with links
#
process_item() {
ITEM=$1
BASEURL="\(http://\)\?\(www\.\)\?rapidshare.com"
if match "^$BASEURL/" "$ITEM"; then
# Rapidshare URL
echo "$ITEM"
elif match "^\(http://\)" "$ITEM"; then
# Non-rapidshare URL, extract RS links (highly fallible!) and download
wget -O - "$ITEM" | tr -d '\r' | grep -o "$BASEURL/[^\"<>]\+" | uniq
else
# Assume it's a file and read links (discard comments and empty lines)
grep -v "^[[:space:]]*\(#\|$\)" -- "$ITEM"
fi
}
# Don't run main code on testing
#
test "$TESTMODE" = "1" && return
# Main
#
if test $# -eq 0; then
debug "usage: $(basename $0) URL|FILE [URL|FILE ...]"
exit 1
fi
for ITEM in "$@"; do
process_item "$ITEM" | while read URL; do
debug "start download: $URL"
FILE_URL=$(get_rapidshare_file_url "$URL") &&
wget "$FILE_URL" && echo $(basename "$FILE_URL") ||
debug "could not download: $URL"
done
done
Now You'll need to paste it into console and You can do this by clicking right mouse button on console (using PuTTY). - put Your mouse on a black screen of console and just click right mouse button.
Now using keyboard put this keys:
ENTER
ESC
SHIFT+Z
and than Z key
4. Now we will need to set permissions for this file.
- Code: Select all
# chmod 755 rapid.sh
5. It's time to install screen through ipkg from optware
- Code: Select all
# ipkg update
# ipkg install screen
Script installed
So always before using script it's better to go to the directory where it is saved:
- Code: Select all
# cd ..
# cd /share/Qdownload
~~ Rapidshare links You can add by 3 ways: ~~
A) Using file which containt rapidshare links (all links should be seperated by enter)
- Code: Select all
# ./rapid.sh urls.txt
B) Using direct link
- Code: Select all
# ./rapid.sh http://server.com/page-with-rapidshare-links.html
C) Entering multiple links
- Code: Select all
# ./rapid.sh rapidshare.com/link1 rapidshare.com/link2 rapidshare.com/link3 [...]
Now using 'screen':
- Do this:
- Code: Select all
# screen -a
# cd /share/Qdownload
# ./rapid.sh [options]
- If You want to leave console and keep downloading rapidshare, put CTRL+A+D
- If You want go back to the screen and take a look on download progress, just enter this:
- Code: Select all
# screen -r
- If You are on a screen and You wanna open new session (eg. for next download) put CTRL+A+C combination
- When You are on screen and You have multiple opened screens, You can switch between them using these combinations: CTRL+A+N (- mean next) or CTRL+A+P (- mean previous).
- If You wanna break working script, put CTRL+C keyboard combination.
Source: http://code.google.com/p/megaupload-dl/wiki/RapidShare
Script writed by: Arnau Sanchez. Licence: GNU GPL v3.0 .
Original polish version: http://www.qnapclub.pl/viewtopic.php?f= ... 2355#p2355
Tutorial writed by: hypnosiss(QNAPClub moderator)
Translation: SiLAS(QNAPClub Head Admin)



News