Repository navigation
Expand file tree
/
Copy pathFreakshareCom.py
More file actions
184 lines (131 loc) · 5.63 KB
/
Copy pathFreakshareCom.py
File metadata and controls
184 lines (131 loc) · 5.63 KB
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
# -*- coding: utf-8 -*-
import re
from module.plugins.internal.Hoster import Hoster
from module.plugins.captcha.ReCaptcha import ReCaptcha
from module.plugins.internal.SimpleHoster import seconds_to_midnight
class FreakshareCom(Hoster):
__name__ = "FreakshareCom"
__type__ = "hoster"
__version__ = "0.43"
__status__ = "testing"
__pattern__ = r'http://(?:www\.)?freakshare\.(net|com)/files/\S*?/'
__description__ = """Freakshare.com hoster plugin"""
__license__ = "GPLv3"
__authors__ = [("sitacuisses", "sitacuisses@yahoo.de"),
("spoob", "spoob@pyload.org"),
("mkaay", "mkaay@mkaay.de"),
("Toilal", "toilal.dev@gmail.com")]
def setup(self):
self.multiDL = False
self.req_opts = []
def process(self, pyfile):
self.pyfile = pyfile
pyfile.url = pyfile.url.replace("freakshare.net/", "freakshare.com/")
if self.account:
self.html = self.load(pyfile.url, cookies=False)
pyfile.name = self.get_file_name()
self.download(pyfile.url)
else:
self.prepare()
self.get_file_url()
self.download(pyfile.url, post=self.req_opts)
check = self.check_download({'bad' : "bad try",
'paralell' : "> Sorry, you cant download more then 1 files at time. <",
'empty' : "Warning: Unknown: Filename cannot be empty",
'wrong_captcha' : "Wrong Captcha!",
'downloadserver': "No Downloadserver. Please try again later!"})
if check == "bad":
self.fail(_("Bad Try"))
elif check == "paralell":
self.wait(300, True)
self.retry()
elif check == "empty":
self.fail(_("File not downloadable"))
elif check == "wrong_captcha":
self.captcha.invalid()
self.retry()
elif check == "downloadserver":
self.retry(5, 15 * 60, _("No Download server"))
def prepare(self):
pyfile = self.pyfile
self.download_html()
if not self.file_exists():
self.offline()
self.set_wait(self.get_waiting_time())
pyfile.name = self.get_file_name()
pyfile.size = self.get_file_size()
self.wait()
return True
def download_html(self):
self.load("http://freakshare.com/index.php", {'language': "EN"}) #: Set english language in server session
self.html = self.load(self.pyfile.url)
def get_file_url(self):
"""
Returns the absolute downloadable filepath
"""
if not self.html:
self.download_html()
if not self.wantReconnect:
self.req_opts = self.get_download_options() #: Get the Post options for the Request
# file_url = self.pyfile.url
# return file_url
else:
self.offline()
def get_file_name(self):
if not self.html:
self.download_html()
if not self.wantReconnect:
m = re.search(r"<h1\sclass=\"box_heading\"\sstyle=\"text-align:center;\">([^ ]+)", self.html)
if m:
file_name = m.group(1)
else:
file_name = self.pyfile.url
return file_name
else:
return self.pyfile.url
def get_file_size(self):
size = 0
if not self.html:
self.download_html()
if not self.wantReconnect:
m = re.search(r"<h1\sclass=\"box_heading\"\sstyle=\"text-align:center;\">[^ ]+ - ([^ ]+) (\w\w)yte", self.html)
if m:
units = float(m.group(1).replace(",", ""))
pow = {'KB': 1, 'MB': 2, 'GB': 3}[m.group(2)]
size = int(units * 1024 ** pow)
return size
def get_waiting_time(self):
if not self.html:
self.download_html()
if "Your Traffic is used up for today" in self.html:
self.wantReconnect = True
return seconds_to_midnight(gmt=2)
timestring = re.search('\s*var\s(?:downloadWait|time)\s=\s(\d*)[\d.]*;', self.html)
if timestring:
return int(timestring.group(1))
else:
return 60
def file_exists(self):
"""
Returns True or False
"""
if not self.html:
self.download_html()
if re.search(r"This file does not exist!", self.html):
return False
else:
return True
def get_download_options(self):
re_envelope = re.search(r".*?value=\"Free\sDownload\".*?\n*?(.*?<.*?>\n*)*?\n*\s*?</form>",
self.html).group(0) #: Get the whole request
to_sort = re.findall(r"<input\stype=\"hidden\"\svalue=\"(.*?)\"\sname=\"(.*?)\"\s\/>", re_envelope)
request_options = dict((n, v) for (v, n) in to_sort)
herewego = self.load(self.pyfile.url, None, request_options) #: The actual download-Page
to_sort = re.findall(r"<input\stype=\".*?\"\svalue=\"(\S*?)\".*?name=\"(\S*?)\"\s.*?\/>", herewego)
request_options = dict((n, v) for (v, n) in to_sort)
challenge = re.search(r"http://api\.recaptcha\.net/challenge\?k=(\w+)", herewego)
if challenge:
re_captcha = ReCaptcha(self)
(request_options['recaptcha_challenge_field'],
request_options['recaptcha_response_field']) = re_captcha.challenge(challenge.group(1))
return request_options