-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmediafire.sh
executable file
·73 lines (62 loc) · 1.77 KB
/
mediafire.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
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# README
# Input file: Text file with Mediafire links
# Outcome: Run wget jobs in background
# USAGE: ./mediafire.sh <input file>
# So far this script has yet to encounter captcha
# wget -b command throws download to background
# NOTE:
# Make sure you are using the correct grep
# i.e. the one with the -E option
# Thanks to rctay for regex
# Thanks to benjamin for idea of curl POST-ing
# Thanks to nhahtdh for checking whether wget installed
# Check whether curl is installed
command -v curl >/dev/null 2>&1 || {
echo "$0: curl utility not found." >&2
echo "$0: Please install curl package or check PATH variable." >&2
exit 1
}
# Check whether wget is installed
WGET_INSTALLED=true
command -v wget >/dev/null 2>&1 || {
WGET_INSTALLED=false
}
function help() {
echo -e \
"Usage:\n" \
" $0 INPUT_FILE\n\n" \
" INPUT_FILE\n" \
" A text file containing links to files hosted on Mediafire\n" \
" Each link should be on one line\n" >&2;
}
if [[ -z "$1" ]]; then
help
exit 1;
fi
INPUTFILE=$1
for LINK in $(cat $INPUTFILE)
do
temp1=${LINK/download.php/}
temp=${temp1/file\//\?}
RESULT=$(curl $temp | grep kNO | tr "\"" "\n" | grep -E 'http://([0-9]{1,3}\.){3}([0-9]{1,3})')
if [ -z "$RESULT" ]
then
echo "$temp is password protected"
echo "Please enter password:"
read password
RESULT1=$(curl -d "downloadp=$password" $temp | tr "\'" "\n" | tr "\"" "\n" | grep -E 'http://([0-9]{1,3}\.){3}([0-9]{1,3})')
if $WGET_INSTALLED; then
wget -b --quiet $RESULT1
else
curl -L -O -J $RESULT1 &
fi
else
if $WGET_INSTALLED; then
echo "Down"
wget -b --quiet $RESULT
else
curl -L -O -J $RESULT &
fi
fi
done