-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathzippysync_funcs
91 lines (82 loc) · 1.85 KB
/
zippysync_funcs
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# /bin/bash
# Script to Batch Download ZippyShare Links
# Dependancy Check at Include
export DEP_LIST='bc curl wget'
type $DEP_LIST >/dev/null 2>&1
if [[ "$?" == "1" ]]
then
printf "These Functions Require $DEP_LIST & other GNU Core Utils. Please Install Them. Exiting..\n"
unset DEP_LIST
return 1
fi
unset DEP_LIST
# Functions
parse_and_download() {
export ORI=$1
export URL="$(echo $ORI | cut -d "/" -f3)"
export PR_STR="$(echo $ORI | cut -d "/" -f5)"
export ORI_SRC="$(curl -Ss "https://$URL/v/$PR_STR/file.html" | grep dlbutton\'\).href)"
export F_LINK="https://$URL/d/$PR_STR/$(echo "0 $(echo $ORI_SRC | cut -d "\"" -f3) 0" | bc)$(echo $ORI_SRC | cut -d "\"" -f4)"
wget -c "$F_LINK"
export WGET_RET_CODE=$?
unset ORI URL PR_STR ORI_SRC F_LINK
return
}
zippy_link_sync() {
if [[ -z "$1" ]]
then
printf "Command Requires File Links\n"
else
export NUM_LINKS=$#
export NUM_CUR_LINK=1
while true
do
if [[ -z "$1" ]]
then
break
else
if [[ ! -z "$WGET_RET_CODE" ]]
then
unset WGET_RET_CODE
fi
parse_and_download "$1"
if [[ "$WGET_RET_CODE" -gt "3" ]]
then
sleep 120
parse_and_download "$1"
fi
# Retry Only Once
if [[ "$WGET_RET_CODE" -gt "3" ]]
then
printf "\n [$NUM_CUR_LINK/$NUM_LINKS] $1 Failed \n\n"
break
fi
printf "\n [$NUM_CUR_LINK/$NUM_LINKS] $1 Download Complete \n\n"
fi
shift 1
export NUM_CUR_LINK=$(($NUM_CUR_LINK + 1))
done
fi
unset NUM_LINKS NUM_CUR_LINK
return
}
zippy_sync() {
if [[ ! -f "$1" ]]
then
printf "Command Requires A File Containing Links\n"
else
unset LINK_CHAIN
# Parse Links
while IFS='' read -ru 25 ln || [[ -n "$ln" ]]
do
if [[ "$(echo $ln | grep -oe 'zippyshare.com/v/' -oe 'file.html' | wc -l)" == "2" ]]
then
LINK_CHAIN="$LINK_CHAIN $(echo $ln | tr -d [:blank:])"
fi
done 25<$1
# Sync The Files
zippy_link_sync $LINK_CHAIN
unset LINK_CHAIN
fi
return
}