-
Notifications
You must be signed in to change notification settings - Fork 0
/
hellshare-download.sh
64 lines (56 loc) · 2.09 KB
/
hellshare-download.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
#
# script for downloading from Hellshare (premium only)
#
# by ronnicek
#
# for nice progress bar, thanks to http://fitnr.com/showing-file-download-progress-using-wget.html
if [ -z $1 ]; then
echo "script for downloading from Hellshare (premium only)"
echo "At first, you need to create a cookie, then you can download from Hellshare."
echo ""
echo "USAGE:"
echo "--create-cookie"
echo "--download URL"
echo "--list LIST"
exit
fi
# download function
function download {
url=$1
downloadUrl=`wget -q --load-cookie ~/.hellshare.cookie ${url}?do=fileDownloadButton-showDownloadWindow -O - | grep "http://data" | grep Download | cut -d "'" -f 2`
filename=`wget -q --load-cookie ~/.hellshare.cookie ${url}?do=fileDownloadButton-showDownloadWindow -O - | grep "filename" | grep "class" | cut -d ">" -f 2 | cut -d "<" -f 1`
echo -n "Downloading $filename:"
echo -n " "
wget --load-cookies ~/.hellshare.cookie --progress=dot $downloadUrl -O $filename 2>&1 | grep --line-buffered "%" | \
sed -u -e "s,\.,,g" | awk '{printf("\b\b\b\b%4s", $2)}'
echo -ne "\b\b\b\b"
echo " DONE"
}
# parameters..
if [ "$1" = "--create-cookie" ]; then
echo -n "Username: "
read username
echo -n "Password: "
read -s password
echo ""
echo "Creating cookie under ~/.hellshare.cookie"
wget --save-cookies ~/.hellshare.cookie --post-data "username=${username}&password=${password}&perm_login=1" -O - "http://www.hellshare.com/?do=login-loginBoxForm-submit" &> /dev/null
check=`wget -q --load-cookies ~/.hellshare.cookie http://hellshare.com/ -O - | grep $username| wc -l`
if [ $check = "1" ]; then
echo "Cookie created."
else
echo "Something went wrong.."
fi
fi
if [ "$1" = "--download" ]; then
download $2
fi
if [ "$1" = "--list" ]; then
cat $2 | grep -v '^#' | while read line
do
download $line
sedline=${line//\//\\/}
sed -i "s/$sedline/\#DONE: $sedline/g" $2
done
fi