diff options
Diffstat (limited to 'module/plugins/hoster/ShareonlineBiz.py')
| -rw-r--r-- | module/plugins/hoster/ShareonlineBiz.py | 53 | 
1 files changed, 25 insertions, 28 deletions
| diff --git a/module/plugins/hoster/ShareonlineBiz.py b/module/plugins/hoster/ShareonlineBiz.py index 636e5824d..64a490993 100644 --- a/module/plugins/hoster/ShareonlineBiz.py +++ b/module/plugins/hoster/ShareonlineBiz.py @@ -1,22 +1,22 @@  # -*- coding: utf-8 -*-  import re - -from time import time -from urllib import unquote -from urlparse import urlparse +import time +import urllib +import urlparse  from module.network.RequestFactory import getURL -from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.ReCaptcha import ReCaptcha  from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo  class ShareonlineBiz(SimpleHoster):      __name__    = "ShareonlineBiz"      __type__    = "hoster" -    __version__ = "0.47" +    __version__ = "0.51"      __pattern__ = r'https?://(?:www\.)?(share-online\.biz|egoshare\.com)/(download\.php\?id=|dl/)(?P<ID>\w+)' +    __config__  = [("use_premium", "bool", "Use premium account if available", True)]      __description__ = """Shareonline.biz hoster plugin"""      __license__     = "GPLv3" @@ -36,17 +36,15 @@ class ShareonlineBiz(SimpleHoster):      @classmethod -    def getInfo(cls, url="", html=""): -        info = {'name': urlparse(unquote(url)).path.split('/')[-1] or _("Unknown"), 'size': 0, 'status': 3 if url else 1, 'url': url} - -        if url: -            info['pattern'] = re.match(cls.__pattern__, url).groupdict() +    def apiInfo(cls, url): +        info = super(ShareonlineBiz, cls).apiInfo(url) -            field = getURL("http://api.share-online.biz/linkcheck.php", -                           get={'md5': "1"}, -                           post={'links': info['pattern']['ID']}, -                           decode=True).split(";") +        field = getURL("http://api.share-online.biz/linkcheck.php", +                       get={'md5'  : "1", +                            'links': re.match(cls.__pattern__, url).group("ID")}, +                       decode=True).split(";") +        try:              if field[1] == "OK":                  info['fileid']   = field[0]                  info['status']   = 2 @@ -57,6 +55,9 @@ class ShareonlineBiz(SimpleHoster):              elif field[1] in ("DELETED", "NOT FOUND"):                  info['status'] = 1 +        except IndexError: +            pass +          return info @@ -69,12 +70,12 @@ class ShareonlineBiz(SimpleHoster):          recaptcha = ReCaptcha(self)          for _i in xrange(5): -            challenge, response = recaptcha.challenge(self.RECAPTCHA_KEY) +            response, challenge = recaptcha.challenge(self.RECAPTCHA_KEY)              m = re.search(r'var wait=(\d+);', self.html)              self.setWait(int(m.group(1)) if m else 30) -            res = self.load("%s/free/captcha/%d" % (self.pyfile.url, int(time() * 1000)), +            res = self.load("%s/free/captcha/%d" % (self.pyfile.url, int(time.time() * 1000)),                              post={'dl_free'                  : "1",                                    'recaptcha_challenge_field': challenge,                                    'recaptcha_response_field' : response}) @@ -98,18 +99,15 @@ class ShareonlineBiz(SimpleHoster):          self.checkErrors()          res = self.handleCaptcha() +        self.link = res.decode('base64') -        download_url = res.decode("base64") - -        if not download_url.startswith("http://"): +        if not self.link.startswith("http://"):              self.error(_("Wrong download url"))          self.wait() -        self.download(download_url) - -    def checkFile(self): +    def checkFile(self, rules={}):          check = self.checkDownload({'cookie': re.compile(r'<div id="dl_failure"'),                                      'fail'  : re.compile(r"<title>Share-Online")}) @@ -121,7 +119,7 @@ class ShareonlineBiz(SimpleHoster):              self.invalidCaptcha()              self.retry(5, 5 * 60, _("Download failed")) -        return super(ShareonlineBiz, self).checkFile() +        return super(ShareonlineBiz, self).checkFile(rules)      def handlePremium(self, pyfile):  #: should be working better loading (account) api internally @@ -145,13 +143,12 @@ class ShareonlineBiz(SimpleHoster):              pyfile.name = dlinfo['name']              pyfile.size = int(dlinfo['size']) -            dlLink = dlinfo['url'] +            self.link = dlinfo['url'] -            if dlLink == "server_under_maintenance": +            if self.link == "server_under_maintenance":                  self.tempOffline()              else:                  self.multiDL = True -                self.download(dlLink)      def checkErrors(self): @@ -164,7 +161,7 @@ class ShareonlineBiz(SimpleHoster):          try:              self.logError(errmsg, re.search(self.ERROR_PATTERN, self.html).group(1)) -        except: +        except Exception:              self.logError("Unknown error occurred", errmsg)          if errmsg is "invalid": | 
