forked from mcrapet/plowshare-modules-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
multiupload.sh
184 lines (159 loc) · 6.15 KB
/
multiupload.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# Plowshare multiupload.nl module
# Copyright (c) 2012-2013 Plowshare team
#
# This file is part of Plowshare.
#
# Plowshare is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Plowshare is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Plowshare. If not, see <http://www.gnu.org/licenses/>.
MODULE_MULTIUPLOAD_REGEXP_URL='http://\(www\.\)\?multiupload\.\(com\|nl\)/'
MODULE_MULTIUPLOAD_DOWNLOAD_OPTIONS=""
MODULE_MULTIUPLOAD_DOWNLOAD_RESUME=no
MODULE_MULTIUPLOAD_DOWNLOAD_FINAL_LINK_NEEDS_COOKIE=unused
MODULE_MULTIUPLOAD_DOWNLOAD_SUCCESSIVE_INTERVAL=
MODULE_MULTIUPLOAD_UPLOAD_OPTIONS="
COUNT,,count,n=COUNT,Take COUNT mirrors (hosters) from the available list. Default is 9.
DESCRIPTION,d,description,S=DESCRIPTION,Set file description
FROMEMAIL,,email-from,e=EMAIL,<From> field for notification email
TOEMAIL,,email-to,e=EMAIL,<To> field for notification email"
MODULE_MULTIUPLOAD_UPLOAD_REMOTE_SUPPORT=no
MODULE_MULTIUPLOAD_LIST_OPTIONS=""
MODULE_MULTIUPLOAD_LIST_HAS_SUBFOLDERS=no
# Output a multiupload.nl "direct download" link
# $1: cookie file (unused here)
# $2: multiupload url
# stdout: real file download link
multiupload_download() {
local -r URL=$2
local PAGE FID JSON FILE_URL
PAGE=$(curl -L "$URL" | break_html_lines_alt) || return
# Unfortunately, the link you have clicked is not available.
if match 'is not available' "$PAGE"; then
return $ERR_LINK_DEAD
fi
# <div id="downloadbutton_" style="">
FILE_URL=$(parse_attr_quiet 'id=.dlbutton' href <<< "$PAGE")
if [ -z "$FILE_URL" ]; then
log_error 'Direct download link not available'
return $ERR_FATAL
fi
echo "$FILE_URL"
}
# Upload a file to multiupload.nl
# $1: cookie file (unused here)
# $2: input file (with full path)
# $3: remote filename
# stdout: multiupload.nl download link
multiupload_upload() {
local -r FILE=$2
local -r DESTFILE=$3
local -r BASE_URL='http://multiupload.nl'
local PAGE FORM_HTML FORM_ACTION FORM_U FORM_UID DLID SERVICES LINE N FORM_FIELDS
PAGE=$(curl "$BASE_URL" | break_html_lines_alt) || return
FORM_HTML=$(grep_form_by_id "$PAGE" uploadfrm) || return
FORM_ACTION=$(parse_form_action <<< "$FORM_HTML") || return
FORM_U=$(echo "$FORM_HTML" | parse_form_input_by_name_quiet 'u')
FORM_UID=$(echo "$FORM_HTML" | parse_form_input_by_name 'UPLOAD_IDENTIFIER')
# List:
# service_1 : MU (Megaupload)
# service_5 : RS (Rapidshare)
# service_6 : ZS (Zshare)
# service_7 : DF (DepositFiles)
# service_9 : HF (HotFile)
# service_10 : UP (Uploading.com)
# service_11 : 2S (2Shared.com)
# service_14 : FS (FileServe)
# service_15 : FC (FileSonic)
# service_16 : UK (UploadKing)
# service_17 : UH (UploadHere)
# service_18 : WU (Wupload)
# service_19 : PL (PutLocker)
# service_20 : OR (Oron)
# service_21 : FF (FileFactory)
# service_23 : FS (FreakShare)
# service_24 : TB (TurboBit)
# service_25 : UB (UploadBoost)
# service_26 : BF (Bayfiles)
# service_29 : BS (Bitshare)
# service_30 : CO (Crocko)
# service_31 : UB (Uptobox)
# service_34 : UI (UppIt)
# service_35 : FR (FileRIO)
# service_36 : FS (FileSwap)
#
# Changes:
# - 2011.09.12: MU, UK, DF, UH, HF, UP
# - 2011.10.29: MU, UK, DF, HF, UH, ZS, FC, FS, WU
# - 2012.05.25: DF, 2S, PL, OR, FF, FS, TB, UB, BF
# - 2013.10.01: DF, PL, TB, BS, CO, UB, UI, FR, FS
FORM_FIELDS=''
if [ -n "$COUNT" ]; then
if (( COUNT > 9 )); then
COUNT=9
log_error "Too big integer value for --count, set it to $COUNT"
fi
SERVICES=$(echo "$FORM_HTML" | parse_all_attr '=.sradio_[[:digit:]]\+' name) || return
while read -r LINE; do
(( COUNT-- > 0 )) || break
N=$(echo "$LINE" | parse_quiet . '^service_\([[:digit:]]\+\)')
if [ -n "$N" ]; then
FORM_FIELDS="$FORM_FIELDS -F service_$N=1 -F username_$N= -F password_$N= -F remember_$N="
fi
done <<< "$SERVICES"
else
# Keep default settings
SERVICES=$(echo "$FORM_HTML" | parse_all_attr 'checked>' name) || return
while read -r LINE; do
N=$(echo "$LINE" | parse_quiet . '^service_\([[:digit:]]\+\)')
if [ -n "$N" ]; then
FORM_FIELDS="$FORM_FIELDS -F service_$N=1 -F username_$N= -F password_$N= -F remember_$N="
fi
done <<< "$SERVICES"
fi
# Notes:
# - file0 can go up to file9 (included)
# - fetchfield0 & fetchdesc0 can go up to 9 (not used here)
PAGE=$(curl_with_log \
--form-string "toemail=$TOEMAIL" \
--form-string "fromemail=$FROMEMAIL" \
--form-string "description_0=$DESCRIPTION" \
-F "file_0=@$FILE;filename=$DESTFILE" \
-F "UPLOAD_IDENTIFIER=$FORM_UID" \
$FORM_FIELDS \
-F "u=$FORM_U" "$FORM_ACTION") || return
DLID=$(echo "$PAGE" | parse_json downloadid) || return
echo "$BASE_URL/$DLID"
}
# List links from a multiupload link
# Note: multiupload direct link is not printed
# $1: multiupload link
# $2: recurse subfolders (ignored here)
# stdout: list of links
multiupload_list() {
local URL=$1
local PAGE LINKS FILE_NAME SITE_URL
PAGE=$(curl -L "$URL" | break_html_lines_alt) || return
LINKS=$(echo "$PAGE" | parse_all_attr_quiet '"urlhref' href)
if [ -z "$LINKS" ]; then
return $ERR_LINK_DEAD
fi
FILE_NAME=$(echo "$PAGE" | parse '#666666;' '^\(.*\)[[:space:]]<font')
# Print links (stdout)
while read SITE_URL; do
test "$SITE_URL" || continue
URL=$(curl --head "$SITE_URL" | grep_http_header_location_quiet) || continue
if [ -n "$URL" ]; then
echo "$URL"
echo "$FILE_NAME"
fi
done <<< "$LINKS"
}