The file could not be found\. Please check the download link'''
m = re.search(pattern, self.html)
if m is not None:
self.offline()
# Title
pattern = r'''(.*?)
'''
title = re.search(pattern, self.html).group(1)
self.pyfile.name = unicode2str(title)
# Free account
self.handleFree()
def handleFree(self):
# Not needed yet
#pattern = r'''\"(/landing/.*?/download_captcha\.js)\"'''
#jsPage = re.search(pattern, self.html).group(1)
#self.jsPage = self.load("http://uploadstation.com" + jsPage)
# Check download
response = self.load(self.pyfile.url, post={"checkDownload" : "check"})
if not '"success":"showCaptcha"' in response:
self.handleErrors(response)
# We got a captcha?
if '' in self.html:
id = re.search(r"var reCAPTCHA_publickey='(.*?)';", self.html).group(1)
recaptcha = ReCaptcha(self)
challenge, code = recaptcha.challenge(id)
response = self.load('http://www.uploadstation.com/checkReCaptcha.php',
post={'recaptcha_challenge_field' : challenge,
'recaptcha_response_field' : code,
'recaptcha_shortencode_field' : self.fileId})
if r'incorrect-captcha-sol' in response:
self.handleCaptchaErrors(response)
# Process waiting
response = self.load(self.pyfile.url, post={"downloadLink":"wait"})
m = re.search(r".*?(\d+).*?", response)
if m is not None:
wait = m.group(1)
if wait == "404":
self.log.debug("No wait time returned")
self.fail("No wait time returned")
else:
self.setWait(int(wait))
self.wait()
# Show download link
self.load(self.pyfile.url, post={"downloadLink":"show"})
# This may either download our file or forward us to an error page
dl = self.download(self.pyfile.url, post={"download":"normal"})
self.handleDownloadedFile()
def handleErrors(self, response):
text = '"fail":"timeLimit"'
if text in response:
wait = 300
html = self.load(self.pyfile.url, post={"checkDownload" : "showError", "errorType" : "timeLimit"})
m = re.search(r"You need to wait (\d+) seconds to download next file.", html)
if m is not None:
wait = int(m.group(1))
self.setWait(wait, True)
self.wait()
self.retry()
text = '"To remove download restriction, please choose your suitable plan as below"'
if text in response:
wait = 720
self.setWait(wait, True)
self.wait()
self.retry()
def handleCaptchaErrors(self, response):
self.invalidCaptcha()
self.retry()
def handleDownloadedFile(self):
check = self.checkDownload({"wait": re.compile(r'You need to wait (\d+) seconds to download next file.')})
if check == "wait":
wait_time = 720
if self.lastCheck is not None:
wait_time = int(self.lastCheck.group(1))
self.setWait(wait_time+3)
self.log.debug("%s: You need to wait %d seconds for another download." % (self.__name__, wait_time))
self.wantReconnect = True
self.wait()
self.retry()