|
@@ -18,7 +18,7 @@ function json_post {
|
|
|
echo $2\
|
|
|
| awk -v c=$1 -F'"' '{for(i = 1; i <= NF; i++)
|
|
|
{if($i==c)
|
|
|
- if((c=="t")||(c=="s")||(c=="ts"))
|
|
|
+ if((c=="t")||(c=="s")||(c=="ts"))
|
|
|
{gsub(/[[:punct:]]/,"",$(i+1));print $(i+1);}
|
|
|
else
|
|
|
{print $(i+2);}
|
|
@@ -75,11 +75,11 @@ function file_downdec {
|
|
|
echo $2
|
|
|
echo $3
|
|
|
echo $4
|
|
|
- wget -O "$2".tmp $speed -q --show-progress "$1"
|
|
|
+ wget -O "$2".tmp $speed -q --show-progress "$1"
|
|
|
cat "$2.tmp" \
|
|
|
| openssl enc -d -aes-128-ctr -K $3 -iv $4 \
|
|
|
> "$2"
|
|
|
- rm -f "$2".tmp
|
|
|
+ rm -f "$2".tmp
|
|
|
}
|
|
|
function file_down {
|
|
|
wget -O "$2".tmp $speed -q --show-progress "$1"
|
|
@@ -112,7 +112,7 @@ function mega {
|
|
|
attrs=($(json_post 'a' $response1 ))
|
|
|
sizes=($(json_post 's' $response1 ))
|
|
|
parents=($(json_post 'p' $response1 ))
|
|
|
- for i in $(seq 0 $((${#types[@]}-1)));do
|
|
|
+ for i in $(seq 0 $((${#types[@]}-1)));do
|
|
|
unset path
|
|
|
tree_gen ${parents[i]} $((${#types[@]}-1))
|
|
|
meta_dec_key "$(key_solver $(key_dec $(size ${keys[i]})))"
|
|
@@ -127,7 +127,7 @@ function mega {
|
|
|
sleep .5;mkdir -p "$PWD$path"
|
|
|
elif [ ${types[i]} == 0 ];then
|
|
|
file_url=$(json_post 'g' $(json_req "[{\"a\":\"g\",\"g\":1,\"n\":\"${names[i]}\"}]" "?id=&n=$id"))
|
|
|
- file_downdec $file_url "$file_name" $meta_key $meta_iv
|
|
|
+ file_downdec $file_url "$file_name" $meta_key $meta_iv
|
|
|
sleep .5;mv "$file_name" "$PWD$path"
|
|
|
fi
|
|
|
else
|
|
@@ -141,56 +141,25 @@ function mega {
|
|
|
name_key=$(url_str $(json_post 'at' $(json_req "[{\"a\":\"g\", \"p\":\"$id\"}]" '?id=&ak=')))
|
|
|
file_name="$(json_post 'n' "$(meta_dec $meta_key $(size $name_key))")"
|
|
|
file_url=$(json_post 'g' $(json_req "[{\"a\":\"g\",\"g\":1,\"p\":\"$id\"}]" '?'))
|
|
|
- file_downdec $file_url "$file_name" $meta_key $meta_iv
|
|
|
+ file_downdec $file_url "$file_name" $meta_key $meta_iv
|
|
|
fi
|
|
|
- rm .badown.tmp
|
|
|
-}
|
|
|
-function zippyshare {
|
|
|
- wget -q -O .badown.tmp $1
|
|
|
- var0=$(echo $1 \
|
|
|
- | awk -F".com" '{print $1".com"}')
|
|
|
- var1=( $(cat .badown.tmp \
|
|
|
- | grep -B1 dlbutton \
|
|
|
- | grep href \
|
|
|
- | awk -F'"' '{for(i = 1; i <= NF; i++) {if ($i ~ /\//) {print $i}}}') )
|
|
|
- [ -z "$var1" ] && error "File does not exist here"
|
|
|
- var2=( $(cat .badown.tmp \
|
|
|
- | grep -B1 dlbutton \
|
|
|
- | grep document \
|
|
|
- | awk -F= '{print $2}' \
|
|
|
- | awk -F"[()]" '{print $2}' \
|
|
|
- ))
|
|
|
- file_url=$(echo $var0 ${var1[0]} $(echo 3+$var2^3 | bc) ${var1[1]} | tr -d ' ')
|
|
|
- file_name=$(printf '%b' "$(echo $file_url | awk -F'/' '{gsub("%","\\x");gsub("+"," ");print $NF}')")
|
|
|
- rm .badown.tmp
|
|
|
- file_down $file_url "$file_name"
|
|
|
-}
|
|
|
-function mediafire {
|
|
|
- file_url=$(wget -q -O- $1 \
|
|
|
- | grep :\/\/download \
|
|
|
- | awk -F'"' '{print $2}')
|
|
|
- file_name=$(printf '%b' "$(echo $file_url \
|
|
|
- | awk -F'/' '{gsub("%","\\x");gsub("+"," ");print $NF}')")
|
|
|
- file_down $file_url "$file_name"
|
|
|
+ #rm .badown.tmp
|
|
|
}
|
|
|
function switch {
|
|
|
- if [[ "$1" == *"mega"* ]];then
|
|
|
+ if [[ "$1" == *"mega"* ]]
|
|
|
+ then
|
|
|
mega "$1"
|
|
|
- elif [[ "$1" == *"zippyshare"* ]];then
|
|
|
- zippyshare "$1"
|
|
|
- elif [[ "$1" == *"mediafire"* ]];then
|
|
|
- mediafire "$1"
|
|
|
- else
|
|
|
+ else
|
|
|
showhelp;exit 1
|
|
|
fi
|
|
|
}
|
|
|
function showhelp {
|
|
|
echo -e "badown 0.4"
|
|
|
- echo -e "bash downloader for hostsites like mega, mediafire and zippyshare."
|
|
|
+ echo -e "bash downloader for hostsite mega.io"
|
|
|
echo -e "badown [OPTION] ['URL']"
|
|
|
echo -e "\tOptions:"
|
|
|
- echo -e "\t-s,\t--speed SPEED Download speed limit (integer values: 500B, 70K, 2M)."
|
|
|
- echo -e "\t-h,\t--help Display this help."
|
|
|
+ echo -e "\t-s,\t--speed SPEED Download speed limit (integer values: 500B, 70K, 2M)."
|
|
|
+ echo -e "\t-h,\t--help Display this help."
|
|
|
echo -e ""
|
|
|
echo -e "if you find a bug, contact me @github -stck_lzm"
|
|
|
}
|