diff options
Diffstat (limited to 'module/plugins/hoster/UploadStationCom.py')
| -rw-r--r-- | module/plugins/hoster/UploadStationCom.py | 146 | 
1 files changed, 13 insertions, 133 deletions
| diff --git a/module/plugins/hoster/UploadStationCom.py b/module/plugins/hoster/UploadStationCom.py index fea5f4245..ede176e1f 100644 --- a/module/plugins/hoster/UploadStationCom.py +++ b/module/plugins/hoster/UploadStationCom.py @@ -1,141 +1,21 @@  # -*- coding: utf-8 -*-
 -from __future__ import with_statement
 -
 -from module.network.RequestFactory import getURL
 -from module.plugins.Hoster import Hoster
 -from module.plugins.ReCaptcha import ReCaptcha
 -
  import re
 +from module.plugins.hoster.FileserveCom import FileserveCom, checkFile
 -def getInfo(urls):
 -    yield [(url, 0, 1, url) for url in urls]
 -
 -class UploadStationCom(Hoster):
 +class UploadStationCom(FileserveCom):
      __name__ = "UploadStationCom"
      __type__ = "hoster"
 -    __pattern__ = r"http://(www\.)?uploadstation\.com/file/(?P<id>[A-Za-z0-9]+)"
 -    __version__ = "0.33"
 +    __pattern__ = r"http://(?:www\.)?uploadstation\.com/file/(?P<id>[A-Za-z0-9]+)"
 +    __version__ = "0.5"
      __description__ = """UploadStation.Com File Download Hoster"""
 -    __author_name__ = ("fragonib")
 -    __author_mail__ = ("fragonib[AT]yahoo[DOT]es")
 -    
 -    FILE_OFFLINE_PATTERN = r'''<h1>File not available</h1>|<h1>File is not available</h1>'''
 -    FILE_TITLE_PATTERN = r'''<div class=\"download_item\">(.*?)</div>'''
 -    FILE_SIZE_PATTERN = r'''<div><span>File size: <b>(.*?) (KB|MB|GB)</b>'''
 -    CAPTCHA_PRESENT_TOKEN = '<div class="speedBox" id="showCaptcha" style="display:none;">'
 -    CAPTCHA_KEY_PATTERN = r"var reCAPTCHA_publickey='(.*?)';"
 -    CAPTCHA_WRONG_TOKEN = 'incorrect-captcha-sol'
 -    WAITING_PATTERN = r".*?(\d+).*?"
 -    TIME_LIMIT_TOKEN = '"fail":"timeLimit"'
 -    TIME_LIMIT_WAIT_PATTERN = r"You need to wait (\d+) seconds to download next file."
 -    DOWNLOAD_RESTRICTION_TOKEN = '"To remove download restriction, please choose your suitable plan as below</h1>"'
 -        
 -    def setup(self):
 -        self.multiDL = False
 -        self.fileId = ''
 -        self.html = ''
 -
 -    def process(self, pyfile):
 -        
 -	self.fail("Hoster not longer available")
 -        
 -        # Get URL
 -        self.html = self.load(self.pyfile.url, ref=False, decode=True)
 -
 -        # Is offline?
 -        m = re.search(UploadStationCom.FILE_OFFLINE_PATTERN, self.html) 
 -        if m is not None:
 -            self.offline()
 -
 -        # Id & Title
 -        self.fileId = re.search(self.__pattern__, self.pyfile.url).group('id')
 -        self.pyfile.name = re.search(UploadStationCom.FILE_TITLE_PATTERN, self.html).group(1)         
 -
 -        # 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"}, decode=True)
 -        self.logDebug("Checking download, response [%s]" % response.encode('ascii', 'ignore'))
 -        self.handleErrors(response)
 -        
 -        # We got a captcha?
 -        if UploadStationCom.CAPTCHA_PRESENT_TOKEN in self.html:
 -            id = re.search(UploadStationCom.CAPTCHA_KEY_PATTERN, self.html).group(1)
 -            self.logDebug("Resolving ReCaptcha with key [%s]" % id)
 -            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})
 -            self.logDebug("Result of captcha resolving [%s]" % response.encode('ascii', 'ignore'))
 -            self.handleCaptchaErrors(response)
 -
 -        # Process waiting
 -        response = self.load(self.pyfile.url, post={"downloadLink" : "wait"})
 -        m = re.search(UploadStationCom.WAITING_PATTERN, response)
 -        if m is not None:
 -            wait = int(m.group(1))
 -            if wait == 404:
 -                self.logDebug("No wait time returned")
 -                self.fail("No wait time returned")
 -
 -            self.logDebug("Waiting %d seconds." % wait)
 -            self.setWait(wait + 3)
 -            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
 -        self.logDebug("Downloading file.")
 -        dl = self.download(self.pyfile.url, post={"download" : "normal"})
 -        self.handleDownloadedFile()
 -        
 -    def handleErrors(self, response):
 -        
 -        if UploadStationCom.TIME_LIMIT_TOKEN in response:
 -            wait = 300
 -            html = self.load(self.pyfile.url, post={"checkDownload" : "showError", "errorType" : "timeLimit"})
 -            m = re.search(UploadStationCom.TIME_LIMIT_WAIT_PATTERN, html)
 -            if m is not None:
 -                wait = int(m.group(1))
 -
 -            self.logInfo("Time limit reached, waiting %d seconds." % wait)
 -            self.setWait(wait, True)
 -            self.wait()
 -            self.retry()
 -            
 -        if UploadStationCom.DOWNLOAD_RESTRICTION_TOKEN in response:
 -            wait = 720
 -            self.logInfo("Free account time limit reached, waiting %d seconds." % wait)
 -            self.setWait(wait, True)
 -            self.wait()
 -            self.retry()
 +    __author_name__ = ("fragonib", "zoidberg")
 +    __author_mail__ = ("fragonib[AT]yahoo[DOT]es", "zoidberg@mujmail.cz")
 -    def handleCaptchaErrors(self, response):
 -        if UploadStationCom.CAPTCHA_WRONG_TOKEN in response:
 -            self.logInfo("Invalid captcha response, retrying.")
 -            self.invalidCaptcha()
 -            self.retry()
 -        else:
 -            self.correctCaptcha()
 +    URLS = ['http://www.uploadstation.com/file/', 'http://www.uploadstation.com/check-links.php', 'http://www.uploadstation.com/checkReCaptcha.php']
 +    LINKCHECK_TR = r'<div class="details (?:white|grey)">(.*?)\t{9}</div>'
 +    LINKCHECK_TD = r'<div class="(?:col )?col\d">(?:<[^>]*>| )*([^<]*)'
 +    
 +    LONG_WAIT_PATTERN = r'<h1>You have to wait (\d+) (\w+) to download the next file\.</h1>'
 -    def handleDownloadedFile(self):
 -        check = self.checkDownload({"wait": re.compile(UploadStationCom.TIME_LIMIT_WAIT_PATTERN)})
 -        if check == "wait":
 -            wait = 720
 -            if self.lastCheck is not None:
 -                wait = int(self.lastCheck.group(1))
 -            self.logDebug("Failed, you need to wait %d seconds for another download." % wait)
 -            self.setWait(wait + 3, True)
 -            self.wait()
 -            self.retry()
 +def getInfo(urls):    
 +    yield checkFile(UploadStationCom, urls) 
\ No newline at end of file | 
