#!/bin/bash # Download files from Rapidshare. # # Dependencies: curl # # Web: http://code.google.com/p/megaupload-dl/wiki/RapidShare # Web: http://code.google.com/p/plowshare # Contact: Arnau Sanchez . # # License: GNU GPL v3.0: http://www.gnu.org/licenses/gpl-3.0-standalone.html set -e # Echo a debug message to stderr. debug() { echo "$@" >&2; } # Echo a error message to stderr. error() { debug "ERROR: $@"; } # Get first line that matches a regular expression ($1) and parse a string ($2) parse() { S=$(sed -n "/$1/ s/^.*$2.*$/\1/p" | head -n1) && test "$S" && echo "$S"; } # Check if a regexp ($1) matches a string ($2) match() { grep -q "$1" <<< "$2"; } # Output the file URL for a Rapidshare link ($1) get_rapidshare_file_url() { URL=$1 while true; do PAGE=$(curl "$URL") || { error "cannot get main page"; return 1; } WAIT_URL=$(echo "$PAGE" | parse '\) minute") || break debug "download limit reached: waiting $WAIT minutes" sleep ${WAIT}m done FILE_URL=$(echo "$DATA" | parse "