Материал из wiki.lissyara.su
Перейти к: навигация, поиск

Скрипт для скачивания с rapidshare.com

python version is here: rfetch.py

#! /bin/sh
# usage: rapidfetch.sh [-s sec] url [url...]
# requires: ftp/curl for POST request

usage="usage: ${0##*/} [-s sec] url [url...]
  -s sec - number of seconds to sleep before downloading direct link
  url [url...] - one [or many] urls to download from rapidshare.com"

# sleeping time

# allow option to specify alternative sleeping time
while getopts s: opt; do
    case $opt in
	s)  sleep=$OPTARG
	    shift 2 ;;
	?)  : ${nonexistent:?$usage}

get-throttle-page() {
    # throw url content to pipe
    fetch -qo- $1 |
    # extract "Free" account url from content
    sed -n 's/.*<form[[:space:]]*id="ff"[[:space:]]*action="\([^"]*\)"[[:space:]]*method="post">.*/\1/p' |
    # use curl(1) to get throttle page and throw it to stdout
    xargs -I% curl -sd dl.start=Free %#dlt

show-status() {
    get-throttle-page $1 |
    # extract amount of minutes left to stderr
    sed >&2 -n 's|.*in[[:space:]]*about[[:space:]]\(.*\)\.</p>|\1 left|p'

get-direct-url() {
    # sleep in case we encounter download limit for our IP
    while get-throttle-page $1 | grep -qi "try[[:space:]]*again"; do
	show-status $1
	sleep 60

    # extract url pointing to real file and send it to stdout
    get-throttle-page $1 |
    sed -n 's/.*form[[:space:]]*name="dlf"[[:space:]]*action="\([^\"]*\)".*/\1/p'

download-url() {
    # notify about downloading soon
    echo Sleeping for $sleep seconds before downloading:
    echo ${1:?Error: nothing to fetch}
    sleep $sleep

    # grab the damn thing at last
    fetch -Fr $1 2>&- || fetch -R $1

multi-dl() {
    # apply same function on several arguments
    for arg; {
	download-url $(get-direct-url $arg)

# fire up or print usage string unless at least one argument is specified
multi-dl ${@:?$usage}

Написан "Гостем" форума, на основе обсуждения. Некоторые товарисчи не хотят регистрироваться, по каким-то собственным причинам - это - один из таких =)

External links