diff options
Diffstat (limited to 'module/plugins/hoster/ShareonlineBiz.py')
-rw-r--r-- | module/plugins/hoster/ShareonlineBiz.py | 96 |
1 files changed, 47 insertions, 49 deletions
diff --git a/module/plugins/hoster/ShareonlineBiz.py b/module/plugins/hoster/ShareonlineBiz.py index dc3d5093c..a260f39f7 100644 --- a/module/plugins/hoster/ShareonlineBiz.py +++ b/module/plugins/hoster/ShareonlineBiz.py @@ -1,10 +1,9 @@ # -*- 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 @@ -14,9 +13,10 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class ShareonlineBiz(SimpleHoster): __name__ = "ShareonlineBiz" __type__ = "hoster" - __version__ = "0.45" + __version__ = "0.50" __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" @@ -28,32 +28,36 @@ class ShareonlineBiz(SimpleHoster): URL_REPLACEMENTS = [(__pattern__ + ".*", "http://www.share-online.biz/dl/\g<ID>")] + CHECK_TRAFFIC = True + RECAPTCHA_KEY = "6LdatrsSAAAAAHZrB70txiV5p-8Iv8BtVxlTtjKX" - ERROR_INFO_PATTERN = r'<p class="b">Information:</p>\s*<div>\s*<strong>(.*?)</strong>' + ERROR_PATTERN = r'<p class="b">Information:</p>\s*<div>\s*<strong>(.*?)</strong>' @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} + def apiInfo(cls, url): + info = super(ShareonlineBiz, cls).apiInfo(url) if url: - info['pattern'] = re.match(cls.__pattern__, url).groupdict() - field = getURL("http://api.share-online.biz/linkcheck.php", - get={'md5': "1"}, - post={'links': info['pattern']['ID']}, + get={'md5' : "1", + 'links': re.match(cls.__pattern__, url).group("ID")}, decode=True).split(";") - if field[1] == "OK": - info['fileid'] = field[0] - info['status'] = 2 - info['name'] = field[2] - info['size'] = field[3] #: in bytes - info['md5'] = field[4].strip().lower().replace("\n\n", "") #: md5 + try: + if field[1] == "OK": + info['fileid'] = field[0] + info['status'] = 2 + info['name'] = field[2] + info['size'] = field[3] #: in bytes + info['md5'] = field[4].strip().lower().replace("\n\n", "") #: md5 + + elif field[1] in ("DELETED", "NOT FOUND"): + info['status'] = 1 - elif field[1] in ("DELETED", "NOT FOUND"): - info['status'] = 1 + except IndexError: + pass return info @@ -67,12 +71,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}) @@ -86,34 +90,27 @@ class ShareonlineBiz(SimpleHoster): self.fail(_("No valid captcha solution received")) - def handleFree(self): - self.html = self.load(self.pyfile.url, cookies=True) #: refer, stuff - + def handleFree(self, pyfile): self.wait(3) - self.html = self.load("%s/free/" % self.pyfile.url, post={"dl_free": "1", "choice": "free"}, decode=True) + self.html = self.load("%s/free/" % pyfile.url, + post={'dl_free': "1", 'choice': "free"}, + decode=True) 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): - super(ShareonlineBiz, self).checkFile() - check = self.checkDownload({ - 'cookie': re.compile(r'<div id="dl_failure"'), - 'fail' : re.compile(r"<title>Share-Online") - }) + def checkFile(self, rules={}): + check = self.checkDownload({'cookie': re.compile(r'<div id="dl_failure"'), + 'fail' : re.compile(r"<title>Share-Online")}) if check == "cookie": self.invalidCaptcha() @@ -123,13 +120,15 @@ class ShareonlineBiz(SimpleHoster): self.invalidCaptcha() self.retry(5, 5 * 60, _("Download failed")) + return super(ShareonlineBiz, self).checkFile(rules) - def handlePremium(self): #: should be working better loading (account) api internally - self.account.getAccountInfo(self.user, True) + def handlePremium(self, pyfile): #: should be working better loading (account) api internally html = self.load("http://api.share-online.biz/account.php", - {"username": self.user, "password": self.account.accounts[self.user]['password'], - "act": "download", "lid": self.info['fileid']}) + get={'username': self.user, + 'password': self.account.getAccountData(self.user)['password'], + 'act' : "download", + 'lid' : self.info['fileid']}) self.api_data = dlinfo = {} @@ -142,16 +141,15 @@ class ShareonlineBiz(SimpleHoster): if not dlinfo['status'] == "online": self.offline() else: - self.pyfile.name = dlinfo['name'] - self.pyfile.size = int(dlinfo['size']) + 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): @@ -163,8 +161,8 @@ class ShareonlineBiz(SimpleHoster): errmsg = m.group(1).lower() try: - self.logError(errmsg, re.search(self.ERROR_INFO_PATTERN, self.html).group(1)) - except: + self.logError(errmsg, re.search(self.ERROR_PATTERN, self.html).group(1)) + except Exception: self.logError("Unknown error occurred", errmsg) if errmsg is "invalid": |