#!/bin/bash ################################################################################ ################################################################################ export LANG="C" function exitcode() { trap '' 1 2 3 6 9 15 if [ $# -gt 0 ];then local ec="$1" ; else local ec=0 ; fi rm -rf "$tmpdir" trap - 1 2 3 6 9 15 exit $ec } function readcaptcha() { if [ $# -eq 0 ];then code="-";return;fi local img="$1" shift if [ $# -gt 0 ];then local codetitle="\\n($2)" ; fi if [ -n "$img" ];then wgetcmd -nv -O "$captmp" "$img" echo "+++ CAPTCHA local: $captmp [ $( file --mime-type -b "$captmp" ) ]" case "$showcaptcha" in "x" ) if [ -n "$DISPLAY" ];then if [ -n "$gqview" ];then gqview "$captmp" >/dev/null 2>&1 & local pid="$!" elif [ -n "$cacaview" ];then echo "+++ gqview not found, but cacaview found - using cacaview to show captcha" else echo "+++ neither gqview nor cacaview found - not showing captcha" fi else if [ -n "$cacaview" ];then echo "+++ XDISPLAY not found, using cacaview to show captcha" DISPLAY="" cacaview "$captmp" else echo "+++ cacaview not found - not showing captcha" fi fi ;; "c" ) if [ -n "$cacaview" ];then DISPLAY="" cacaview "$captmp" ; else echo "+++ cacaview not found - not showing captcha" ; fi ;; "0" ) echo "+++ not showing captcha as requested" ;; esac code="" while [ -z "$code" ];do if [ -n "$DISPLAY" ] && [ $console -eq 0 ];then code="$( Xdialog --no-cancel --title "$captmp" --screen-center --stdout --inputbox "Enter the CAPTCHA code${codetitle}" 14 40 )" if [ $? -eq 1 ];then code="-";fi else read -p "Code ($codetitle) ['-' for stop]: " code fi done if [ "$showcaptcha" = "x" ] && [ -n "$DISPLAY" ];then kill "$pid" ; fi rm -f "$captmp" else code="*" fi } function delaytime() { if [ $# -eq 0 ];then return 0 ; fi local delay="$1" shift if [ $# -gt 0 ];then local delaystart="$1" else local delaystart="$( date +"%s" )" fi if [ -n "$delay" ]; then realdelay="$(( $( date +"%s" ) - ( $delaystart + $delay ) ))" if [ $( date +"%s" ) -le $(( $delaystart + $delay )) ] ; then while [ $( date +"%s" ) -le $(( $delaystart + $delay )) ];do echo -en "+++ delaying $delay seconds [ $(( $delaystart + $delay - $( date +"%s" ) )) ] \r" sleep 1 done echo fi fi } function wgetcmd() { LANG="C" wget $rate -U "$agent" --save-cookies "$cookies" --keep-session-cookies --load-cookies "$cookies" "$@" } ################################################################################ function downrapid() { local id="rapidshare.com" if [ $# -eq 0 ];then return 1;fi local url="$1" echo "*** $id URL: $url" local output1="$( wgetcmd -nv -O - "$url" )" local url1="$( echo "$output1" | perl -e ' undef $/;$a=;print sprintf("%s",$url) if ((($tag)=($a=~m,(]*id="ff"[^>]*>),is)) and (($url)=($tag=~m,action="([^"]+)",is))); ')" echo "*** $id URL1: $url1" local output2="$( wgetcmd -nv -O - --post-data="dl.start=Free" "$url1" )" local data="$( echo "$output2" | perl -e ' undef $/; $a=; ($delay)=($a=~m,var\s+c\s*=\s*(\d+)\s*;,is); ($wait)=($a=~m,(?:wait|try\s+again\s+in\s+(?:about)?)\s+(\d+\s+minutes?),is); (($img)=($a=~m,; while (($u)=($a=~m,document\.dlf\.action=\\\x27([^\x27]+)\\\x27;,is)) { $a=~s,document\.dlf\.action=\\\x27([^\x27]+)\\\x27;,,is; print "$u\n" unless $u=~m,http://rs\d+tl\d*\.,i; }; ' )" echo "*** $id URL2: $url2" echo "*** $id DELAY: $delay" echo "*** $id WAIT: $wait" echo "*** $id CAPTCHA: $img" echo "*** $id CODETITLE: $codetitle" echo "*** $id HAPPYHOUR: $happyhour" echo "*** $id FILE: $file" if [ -n "$file" ] && [ -n "$url2" ];then if [ $happyhour -eq 0 ];then local delaystart="$( date +"%s" )" readcaptcha "$img" "$codetitle" if [ "$code" = "-" ];then return 3 else delaytime "$delay" "$delaystart" fi fi echo "$url2" | while read url3;do if [ "$code" = "*" ] || [ $happyhour -eq 1 ];then codetxt="" else codetxt="&accesscode=$code" fi actionstring="actionstring=1" if wgetcmd -c -O "$file" --post-data="${actionstring}${codetxt}" "$url3"; then break;fi done if [ -e "$file" ] && [ $( stat -c '%s' "$file" ) -gt 1000 ];then return 0;fi elif [ -n "$wait" ];then echo "--- $id Wait $wait" return 2 else echo "--- $id Unable to download" return 3 fi } ############################## function downsuborysk() { local id="subory.sk" if [ $# -eq 0 ];then return 1;fi local url="$1" echo "*** $id URL: $url" local output1="$( wgetcmd -O - -q "$url" )" local data="$( echo "$output1" | perl -e ' undef $/; $a=; ($delay)=($a=~m,^\bcislo\s*=\s*(\d+)\s*;,im); (($form)=($a=~m,(]*name=captchaform[^>]*>.*?),is)) and ((($img)=($form=~m,]*src="(/captcha3/captcha\.php\?id=[^"]+)"[^>]*>,is)) or 1) and (($url)=($form=~m,]*action="([^"]+)",is)); print "$delay\n$img\n$url\n"; ' )" echo "*** $id DATA: $data" local baseurl="${url%/download/*}" local delay="$( echo "$data" | sed -n -e '1p;' )" local captchaimgpath="$( echo "$data" | sed -n -e '2p;' )" local path="$( echo "$data" | sed -n -e '3p;' )" captchaimg="$baseurl$captchaimgpath" local url1="$baseurl$path" echo "*** $id URL1: $url1" echo "*** $id CAPTCHA: $captchaimg" echo "*** $id DELAY: $delay" if [ -n "$path" ] && [ -n "$captchaimgpath" ];then local delaystart="$( date +"%s" )" readcaptcha "$captchaimg" if [ "$code" = "-" ];then return 3 else delaytime "$delay" "$delaystart" postdata="submitted=1&str=$code" wgetcmd -c --post-data="$postdata" --referer="$url" "$url1" fi else echo "--- $id Unable to download" return 3 fi } ############################## function downuloziskosk() { local id="ulozisko.sk" if [ $# -eq 0 ];then return 1;fi local url="$1" echo "*** $id URL: $url" local output1="$( wget -O - -q --keep-session-cookies --save-cookies="$tmpdir/cookies" "$url" )" local data="$( echo "$output1" | perl -e ' undef $/; $a=; ($form)=($a=~m,(]*name\s*=\s*"formular"[^>]*>.*?),is); ($delay)=($form=~m,function\s+set\s*\(\s*\)\s*\{\s*cas_\d+\s*=\s*(\d+)\s*;\s*\},is); ($img)=($form=~m,]*src="(/obrazky/obrazky\.php\?[^"]+)"[^>]*>,is); ($url)=($form=~m,]*action\s*=\s*"([^"]+)",is); while (($hidden)=($form=~m,(]*type\s*=\s*"hidden"[^>]*>),is)) { $form=~s,(]*type\s*=\s*"hidden"[^>]*>),,is; ($name)=($hidden=~m,name\s*=\s*"([^"]+)",is); ($val)=($hidden=~m,value\s*=\s*"([^"]+)",is); $file=$val if ($name eq "name"); $val=unpack("H*",$val); $val=~s/(..)/%$1/g; push @hidden,sprintf("%s=%s",$name,$val); } print sprintf("%s\n%s\n%s\n%s\n%s",$delay,$img,$url,join("&",@hidden),$file); ' )" local baseurl="http://www.ulozisko.sk" local delay="$( echo "$data" | sed -n -e '1p;' )" local captchaimgpath="$( echo "$data" | sed -n -e '2p;' )" local captchaimg="$baseurl$captchaimgpath" local url1path="$( echo "$data" | sed -n -e '3p;' )" local url1="$baseurl$url1path" local postdata="$( echo "$data" | sed -n -e '4p;' )" local filename="$( echo "$data" | sed -n -e '5p;' )" echo "*** $id URL1: $url1" echo "*** $id CAPTCHA: $captchaimg" echo "*** $id DELAY: $delay" echo "*** $id FILE: $filename" if [ -n "$url1path" ] && [ -n "$captchaimgpath" ];then local delaystart="$( date +"%s" )" readcaptcha "$captchaimg" if [ "$code" = "-" ];then return 3 else delaytime "$delay" "$delaystart" postdata="$postdata&antispam=$code" wgetcmd -c --post-data="$postdata" --referer="$url" "$url1" fi else echo "--- $id Unable to download" return 3 fi } ############################## function downmegaupload() { local id="megaupload.com" if [ $# -eq 0 ];then return 1;fi local url="$1" echo "*** $id URL: $url" local output1="$( wgetcmd -nv -O - "$url" )" local data="$( echo "$output1" | perl -e ' undef $/; $a=; ($captcha)=($a=~m#]*src=["\x27]([^"\x27]+/gencap\.php[^"\x27]+)["\x27]#i); @fields=(); while (($t1)=($a=~m/(]*type=["\x27]hidden["\x27][^>]*>)/i)) { if ((($field)=($a=~m/name=["\x27](captchacode|megavar)["\x27]/i)) and (($val)=($a=~m/value=["\x27]([^"\x27]*)["\x27]/i))) { $val=~s/(.)/"%".unpack("H2",$1)/ge; push @fields,sprintf("%s=%s",$field,$val); } $a=~s/]*type=["\x27]hidden["\x27][^>]*>//i } print "$captcha\n"; print join("&",@fields)."\n"; ' )" local url1="$url" local captchaimg="$( echo "$data" | sed -n -e '1p;' )" local postdata="$( echo "$data" | sed -n -e '2p;' )" echo "*** $id URL: $url1" echo "*** $id CAPTCHA: $captchaimg" if [ -n "$captchaimg" ] && [ -n "$url1" ];then readcaptcha "$captchaimg" if [ "$code" = "-" ];then return 3 else local output2="$( wgetcmd --post-data="$postdata&captcha=$code" --referer="$url" -O - -nv "$url1" )" local data="$( echo "$output2" | perl -e ' undef $/; $a=; ($delay)=($a=~/count\s*=\s*(\d+)\s*;/); ($t1)=($a=~m#]*id="downloadlink"[^>]*>(.*?)#) and ($url)=($t1=~m#]*href=[\x27"]([^\x27"]+)[\x27"]#); print "$delay\n$url\n"; ' )" local delay="$( echo "$data" | sed -n -e '1p;' )" local url2="$( echo "$data" | sed -n -e '2p;' )" echo "*** $id URL2: $url2" echo "*** $id DELAY: $delay" if [ -n "$url2" ];then delaytime "$delay" wgetcmd -c "$url2" else echo "--- $id Unable to download" return 3 fi fi else echo "--- $id Unable to download" return 3 fi } ############################## function downbagruj() { local id="bagruj.cz" if [ $# -eq 0 ];then return 1;fi local url="$1" echo "*** $id URL: $url" local output1="$( wgetcmd -nv -O - "$url" )" local data="$( echo "$output1" | perl -e ' undef $/; $a=; if (($b)=($a=~m,]*name="f1"[^>]*>(.+?),is)) { @inputs=(); while ((($input)=($b=~m,(]*type="hidden"[^>]*>),is)) and (($name)=($input=~/name="([^"]+)"/is)) and (($value)=($input=~/value="([^"]*)"/is))) { $value=unpack("H*",$value); $value=~s/(..)/%$1/g; push @inputs,sprintf("%s=%s",$name,$value); $b=~s,(]*type="hidden"[^>]*>),,is; } $postdata=join("&",@inputs); $captcha=$t1 if (($t1)=($b=~m,]*src="(http://bagruj.cz/captchas/[^.]+.jpg)"[^>]*>,is)); $delay=$t1 if (($t1)=($b=~m,]*id="countdown"[^>]*>(\d+)]*>,is)); print "$captcha\n$delay\n$postdata\n"; }; ' )" local captchaimg="$( echo "$data" | sed -n -e '1p;' )" local delay="$( echo "$data" | sed -n -e '2p;' )" local postdata="$( echo "$data" | sed -n -e '3p;' )" echo "*** $id CAPTCHA: $captchaimg" echo "*** $id DELAY: $delay" if [ -n "$captchaimg" ] ;then local delaystart="$( date +"%s" )" readcaptcha "$captchaimg" if [ "$code" = "-" ];then return 3 else delaytime "$delay" "$delaystart" local url1="$( wgetcmd -O - -q --post-data="$postdata&code=$code" "$url" | perl -e 'undef $/;$a=;print "$b" if (($b)=($a=~m,\1,is));' )" echo "*** $id URL1: $url1" if [ -z "$url1" ]; then return 1 ; fi wgetcmd -c "$url1" fi else echo "--- $id Unable to download" return 3 fi } function downiskladka() { local id="iskladka.cz" if [ $# -eq 0 ];then return 1;fi local url="$1" echo "*** $id URL: $url" local output1="$( wgetcmd -nv -O - "$url" )" local url1="$( dirname "$url" )/$( echo "$output1" | perl -e ' undef $/; $a=; if ((($url)=($a=~m,]*src="(iCopy/index.php[^"]+)",is)) and (($path,$param)=($url=~m,^(.*)\?file=(.*)$,i))) { $param=unpack("H*",$param); $param=~s/(..)/%$1/g; print sprintf("%s?file=%s",$path,$param); }; ' )" echo "*** $id URL1: $url1" local output2="$( wgetcmd -O - -q --referer "$url" "$url1" )" local data="$( echo "$output2" | perl -e ' undef $/; $a=; ($file)=($a=~m,var\s+downloadCounterLink\s*=\s*[\x27"]([^\x27"]+)[\x27"]\s*;,is); ($delay)=($a=~m,var\s+downloadCounter\s*=\s*(\d+)\s*;,is); if (($url)=($a=~m,^\s*document\.getelementbyid\("downloadstatus"\)\.innerhtml\s*=\s*"\s*]*src=\x27(http.*/icopy/downloadbalancer[^\x27]+)\x27,im)) { $url=~s,"\+downloadCounterLink\+",$file,is; } $file=~tr/+/ /; $file=~s/%(..)/chr(hex($1))/ge; print sprintf("%s\n%s\n%s\n",$url,$file,$delay); ' )" local url2="$( echo "$data" | sed -n -e '1p;' )" local file="$( echo "$data" | sed -n -e '2p;' )" local delay="$( echo "$data" | sed -n -e '3p;' )" if [ -e "$file" ] ; then file="$file.$( date +"%Y%m%d-%H%M%S" ).$$" ; fi echo "*** $id URL2: $url2" echo "*** $id FILE: $file" echo "*** $id DELAY: $delay" if [ -n "$url2" ] && [ -n "$file" ];then if [ -n "$delay" ];then delaytime "$delay" ; fi wgetcmd -O "$file" --referer="$url1" "$url2" else echo "--- $id Unable to download" return 3 fi } function downleteckaposta() { local id="leteckaposta.cz" if [ $# -eq 0 ];then return 1;fi local url="$1" echo "*** $id URL: $url" local output1="$( wgetcmd -nv -O - "$url" )" local data="$( echo -e "<<$url>>\n$output1" | perl -e ' undef $/; $a=; ($burl)=($a=~m,<<(https?://[^/]+)/.*?>>,i); (($t,$file)=($a=~m,(]*class=["\x27]download-link["\x27][^>]*>)([^<]+),is)) and (($path)=($t=~m,href=["\x27](/file/[^"\x27]+)["\x27],is)); print "$burl\n$path\n$file\n"; ' )" local baseurl="$( echo "$data" | sed -n -e '1p;' )" local urlpath="$( echo "$data" | sed -n -e '2p;' )" local file="$( echo "$data" | sed -n -e '3p;' )" local url1="$baseurl$urlpath" if [ -e "$file" ] ; then file="$file.$( date +"%Y%m%d-%H%M%S" ).$$" ; fi echo "*** $id URL1: $url1" echo "*** $id FILE: $file" if [ -n "$file" ] && [ -n "$urlpath" ];then wgetcmd -O "$file" --referer="$url1" "$url1" else echo "--- $id Unable to download" return 3 fi } function downulozto() { ## http://uloz.to/1617316/Heroes.S03E23.HDTV.XviD-LOL.avi local id="uloz.to" if [ $# -eq 0 ];then return 1;fi local url="$1" echo "*** $id URL: $url" local output1="$( wgetcmd -nv -O - "$url" | perl -e 'undef $/;$_=;print $1 if m;(]*name="dwn".*?);is;' )" local data="$( echo "$output1" | perl -e ' undef $/;$_=; (($f)=(m/(]*name="dwn"[^>]*>)/is)) and (($url)=($f=~m/action="([^"]+)"/is)); (($f)=(m;(]*id="captcha"[^>]*>);is)) and (($captcha)=($f=~m;src="([^"]+)";is)); (($f)=(m;(]*id="captcha_nb"[^>]*>);is)) and (($capctrl)=($f=~m;value="([^"]+)";is)); (($f)=(m;(]*id="download_button"[^>]*>);is)) and (($downbut)=($f=~m;value="([^"]+)";is)) and ($downbut=~s/(.)/sprintf("%%%s",unpack("H",$1))/ge or 1); print "$url\n$captcha\n$capctrl\n$downbut\n"; ' )" local file="$( basename "$url" )" if [ -e "$file" ] ; then file="$file.$( date +"%Y%m%d-%H%M%S" ).$$" ; fi local url1="$( echo "$data" | sed -n -e '1p;' )" local captchaimg="$( echo "$data" | sed -n -e '2p;' )" local captchanb="$( echo "$data" | sed -n -e '3p;' )" local downbut="$( echo "$data" | sed -n -e '4p;' )" echo "*** $id URL1: $url1" echo "*** $id CAPTCHA: $captchaimg" echo "*** $id FILE: $file" if [ -n "$captchaimg" ] && [ -n "$file" ];then readcaptcha "$captchaimg" if [ "$code" = "-" ];then return 3 else postdata="captcha_nb=$captchanb&captcha_user=$code&download=$downbut" wgetcmd -O "$file" --post-data="$postdata" --referer "$url" "$url1" if [ "$( file -b --mime-type "$file" )" = "text/html" ] && iconv -c -f utf-8 -t ascii//translit "$file" | grep -qEi 'Prekrocen[[:space:]]+pocet[[:space:]]+FREE[[:space:]]+slotu';then rm "$file" echo "--- $id No free slots" return 1 fi fi else echo "--- $id Unable to download" return 3 fi } function downulozcz() { local id="uloz.cz" if [ $# -eq 0 ];then return 1;fi local url="$1" echo "*** $id URL: $url" local output1="$( wgetcmd -nv -O - "$url" )" local url1="$( echo "$output1" | perl -e ' undef $/; $a=; ($url)=($a=~m,href=["\x27](http://[^/]*uloz\.cz/auth/[a-f0-9]+/file/[^"\x27]+)["\x27],is); print "$url"; ' )" echo "*** $id URL1: $url1" if [ -n "$url1" ];then wgetcmd -c --referer="$url" "$url1" else echo "--- $id Unable to download" return 3 fi } function downfilefactory() { local id="filefactory.com" if [ $# -eq 0 ];then return 1;fi local url="$1" echo "*** $id URL: $url" local output1="$( wgetcmd -nv -O - "$url" )" if echo "$output" | grep -Eqi 'no free download slots.*try again later' ;then echo "--- $id No free slots" return 1 fi local baseurl="$( echo "$url" | sed -e 's,\([^/]\+://[^/]\+\)/.*$,\1,' )" local path1="$( echo "$output1" | perl -e 'undef $/;$a=; print "$url" if (($t)=($a=~m,(]*class="download"[^>]*>),is)) and (($url)=($t=~m,href="([^"]+)",is));' )" local url1="$baseurl$path1" echo "*** $id URL1: $url1" local output2="$( wgetcmd -nv -O - --referer="$url" "$url1" )" local data1="$( echo "$output2" | perl -e ' undef $/;$a=; (($capid)=($a=~m,(]*id="captchaID"[^>]*>),is)) and (($v)=($t=~m,value="([^"]+)",is)); (($capim)=($a=~m,(]*class="captchaImage"[^>]*>),is)) and (($v)=($t=~m,src="([^"]+)",is)); print "$capid\n$capim\n"; ' )" local postdata="captchaID=$( echo "$data1" | sed -n -e '1p;' )" local captchaimgpath="$( echo "$data1" | sed -n -e '2p;' )" local captchaimg="$baseurl$captchaimgpath" echo "*** $id CAPTCHA: $captchaimgpath" if [ -n "$captchaimgpath" ];then readcaptcha "$captchaimg" if [ "$code" = "-" ];then return 3 else postdata="$postdata&captchaText=$code" local output3="$( wgetcmd -nv -O - --post-data="$postdata" --referer="$url" "$url1" )" local url2="$( echo "$output3" | perl -e ' undef $/;$a=; (($t)=($a=~m,(]*class="download"[^>]*>),is)) and (($url)=($t=~m,href="([^"]+)",is)); print "$url";' )" echo "*** $id URL2: $url2" wgetcmd -c --referer="$url1" "$url2" fi else echo "--- $id Unable to download" return 3 fi return 0 } ################################################################################ ################################################################################ function downnetloadin() { local id="netload.in" ## http://netload.in/dateil4GMY6euLa/heroes.323.hdtv-lol.part4.rar.htm if [ $# -eq 0 ];then return 1;fi local url="$1" echo "*** $id URL: $url" local baseurl="$( echo "$url" | sed -e 's,\([^/]\+://[^/]\+\)/.*$,\1,' )" local output1="$( wgetcmd -nv -O - "$url" )" echo "$output1" > output1 local data1="$( echo "$output1" | perl -e ' undef $/; $a=; (($delay)=($a=~m,var\s+sss\s*=\s*-?\s*(\d+)\s*;,is)); (($curl)=($a=~m,]*class="dl_first_link2"[^>]*>\s*]*class="Free_dl"[^>]*>\s*]*href="([^"]+)"[^>]*>,is)) and ($curl=~s/&/\&/g or 1); (($t)=($a=~m,(]*class="download_fast_link"[^>]*>),is)) and (($furl)=($t=~m,href="([^"]+)",is)) and ($furl=~s/&/\&/g or 1); (($fn)=($a=~m,]*class="dl_first_filename"[^>]*>\s*([^<]+)<,is)); print "$delay\n$curl\n$fn\n$furl\n"; ' )" local delay="$( echo "$data1" | sed -n -e '1p;' )" local cpath="$( echo "$data1" | sed -n -e '2p;' )" local file="$( echo "$data1" | sed -n -e '3p;' )" local fpath="$( echo "$data1" | sed -n -e '4p;' )" if [ -e "$file" ] ; then file="$file.$( date +"%Y%m%d-%H%M%S" ).$$" ; fi if [ -z "$cpath" ];then local url1="$baseurl/$fpath" else local url1="$baseurl/$cpath" fi echo "*** $id URL1: $url1" echo "*** $id FILE: $file" echo "*** $id DELAY: $delay" if ( [ -n "$cpath" ] || [ -n "$fpath" ] ) && [ -n "$file" ];then if echo "$url1" | grep -qi 'captcha=1' ; then local output2="$( wgetcmd -O - --referer="$url" "$url1" )" echo "$output2" > output2 echo "captcha" else delaytime "$delay" wgetcmd -O "$file" -c --referer="$url" "$url1" if [ "$( file -b --mime-type "$file" )" = "text/html" ] ; then local wait="$( perl -e 'undef $/;$a=;print $wait/1000 if ($wait)=($a=~/(?:We\s+had\s+a\s+reqeust\s+with\s+the\s+IP.*?)?You\s+could\s+download\s+your\s+next\s+file\s+in.*?countdown\((\d+)/is);' < "$file" )" echo "--- $id WAIT: $wait secs" rm -f "$file" return 1 fi fi else echo "--- $id Unable to download" return 3 fi return 0 } function downuploadedto() { local id="uploaded.to" ## http://uploaded.to/file/4z1nkb/heroes.323.hdtv-lol.part1.rar if [ $# -eq 0 ];then return 1;fi local url="$1" echo "*** $id URL: $url" local baseurl="$( echo "$url" | sed -e 's,\([^/]\+://[^/]\+\)/.*$,\1,' )" local output1="$( wgetcmd -nv -O - "$url" )" local data1="$( echo "$output1" | perl -e ' undef $/; $a=; ($delay)=($a=~m,var\s+secs\s*=\s*?\s*(\d+)\s*;\s*//\s*Wartezeit,is); (($frm)=($a=~m,(]*name="download_form"[^>]*>),is)) and (($url)=($frm=~m,action="([^"]+)",is)); (($fn)=($a=~m,[^<]*]*>\s*Filename:[^<]*]*>[^<]*]*>(.+?)]*>[^<]*]*>,is)) and ($fn=~s,<[^>]+>,,gs or 1) and ($fn=~s/^\s+//s or 1) and ($fn=~s/\s+$//s or 1); ($wait)=($a=~m,Your Free-Traffic is exceeded.*Or wait (\d+\s+(?:minute|second|hour)s?),is); print "$delay\n$url\n$fn\n$wait\n"; ' )" local delay="$( echo "$data1" | sed -n -e '1p;' )" local url1="$( echo "$data1" | sed -n -e '2p;' )" local file="$( echo "$data1" | sed -n -e '3p;' )" local wait="$( echo "$data1" | sed -n -e '4p;' )" if [ -e "$file" ] ; then file="$file.$( date +"%Y%m%d-%H%M%S" ).$$" ; fi echo "*** $id URL1: $url1" echo "*** $id DELAY: $delay" echo "*** $id FILE: $file" echo "*** $id WAIT: $wait" if [ -n "$wait" ];then echo "--- $id Wait $wait" return 2 elif [ -n "$url1" ] && [ -n "$file" ];then delaytime "$delay" wgetcmd -O "$file" -c --referer="$url" "$url1" else echo "--- $id Unable to download" return 3 fi return 0 } ################################################################################ ################################################################################ proxiesfile="$HOME/.download-proxies" if ! [ -f "$proxiesfile" ] || ( [ -L "$proxiesfile" ] && ! [ -f "$( readlink -f "$proxiesfile" )" ] );then echo "Please, create file $proxiesfile" exit fi allproxylist="$( awk -F '|' '{print $2;}' "$proxiesfile" | tr '\n' ' ' )" sshtunnels="$( awk -F '|' '$1~/^.+$/{print " " $1,$2;}' "$proxiesfile" )" sshtunservers="$( awk -F '|' '$1~/^.+$/{print $1;}' "$proxiesfile" | tr '\n' ' ' )" agent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7" console=0 showcaptcha="x" if [ $# -gt 0 ];then i=$# while [ $i -gt 0 ];do case "$1" in -a) if [ $# -gt 1 ];then id="$[$2+1]" proxylist="$proxylist $( echo "$allproxylist" | tr -s '[[:space:]]' '\n' | sed -n "${id}p" )" i=$[$i-1] shift 2 else echo "add proxy: value please" exit fi ;; -d) if [ $# -gt 1 ];then id="$[$2+1]" if [ -z "$proxylist" ] ;then proxylist="$allproxylist";fi proxylist="$( echo "$proxylist" | tr -s '[[:space:]]' '\n' | sed "${id}d" )" i=$[$i-1] shift 2 else echo "remove proxy: value please" exit fi ;; -r) if [ $# -gt 1 ];then rate="--limit-rate=$2" i=$[$i-1] shift 2 else echo "rate limit: value please" exit fi ;; -p) if [ $# -gt 1 ];then proxylist="$proxylist $2" shift 2 i=$[$i-1] else echo "use proxy: value please" exit fi ;; -c) console=1 shift ;; -x) console=0 shift ;; -S ) showcaptcha="0" shift ;; -C ) showcaptcha="c" shift ;; -X ) showcaptcha="x" shift ;; *) v="$1" shift 1 set -- "$@" "$v" ;; esac i=$[$i-1] done gqview="$( type -t gqview )" cacaview="$( type -t cacaview )" if [ -z "$proxylist" ] ;then proxylist="$allproxylist";fi tmpdir="$( mktemp -d )" trap exitcode 1 2 3 6 9 15 echo "=== TMPDIR: $tmpdir" cookies="$tmpdir"/cookies captmp="$tmpdir"/captcha while [ $# -gt 0 ];do url="$1" shift echo "=== Downloading URL: $url" rm -f "$cookies" touch "$cookies" for proxy in $proxylist ;do if [ "$proxy" = "NONE" ];then unset http_proxy else export http_proxy="$proxy" fi echo "=== HTTP PROXY: $http_proxy" if echo "$url" | grep -qEi 'rapidshare\.com/';then downrapid "$url" e=$? case "$e" in 0 ) break ;; 3 ) exitcode 3 ;; 5 ) exit ;; esac elif echo "$url" | grep -qEi 'subory\.sk/';then downsuborysk "$url" e=$? case "$e" in 0 ) break ;; 3 ) exitcode 3 ;; 5 ) exit ;; esac elif echo "$url" | grep -qEi 'ulozisko\.sk/';then downuloziskosk "$url" e=$? case "$e" in 0 ) break ;; 3 ) exitcode 3 ;; 5 ) exit ;; esac elif echo "$url" | grep -qEi 'megaupload\.com/';then downmegaupload "$url" e=$? case "$e" in 0 ) break ;; 3 ) exitcode 3 ;; 5 ) exit ;; esac elif echo "$url" | grep -qEi 'bagruj\.cz/';then downbagruj "$url" e=$? case "$e" in 0 ) break ;; 3 ) exitcode 3 ;; 5 ) exit ;; esac elif echo "$url" | grep -qEi 'filefactory\.com/';then downfilefactory "$url" e=$? case "$e" in 0 ) break ;; 3 ) exitcode 3 ;; 5 ) exit ;; esac elif echo "$url" | grep -qEi 'iskladka\.cz/';then downiskladka "$url" e=$? case "$e" in 0 ) break ;; 3 ) exitcode 3 ;; 5 ) exit ;; esac elif echo "$url" | grep -qEi 'leteckaposta\.cz/';then downleteckaposta "$url" e=$? case "$e" in 0 ) break ;; 3 ) exitcode 3 ;; 5 ) exit ;; esac elif echo "$url" | grep -qEi 'uloz\.to/';then downulozto "$url" e=$? case "$e" in 0 ) break ;; 3 ) exitcode 3 ;; 5 ) exit ;; esac elif echo "$url" | grep -qEi 'uloz\.cz/';then downulozcz "$url" e=$? case "$e" in 0 ) break ;; 3 ) exitcode 3 ;; 5 ) exit ;; esac elif echo "$url" | grep -qEi 'netload\.in/';then downnetloadin "$url" e=$? case "$e" in 0 ) break ;; 3 ) exitcode 3 ;; 5 ) exit ;; esac elif echo "$url" | grep -qEi 'uploaded\.to/';then downuploadedto "$url" e=$? case "$e" in 0 ) break ;; 3 ) exitcode 3 ;; 5 ) exit ;; esac else echo "Unknown URL $url" break fi done done exitcode else cat <