diff options
author | Walter Purcaro <vuolter@gmail.com> | 2014-11-13 23:47:36 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2014-11-13 23:47:36 +0100 |
commit | bdfa8104065831bf0eb2f6a022552e8de725ed47 (patch) | |
tree | 4a43864e1bb257c7737a765d62899244b825a859 /module/plugins/internal | |
parent | [themes] Tiny code cosmetics (diff) | |
parent | [Plugin] Some fixes by rlindner81 (diff) | |
download | pyload-bdfa8104065831bf0eb2f6a022552e8de725ed47.tar.xz |
Merge branch 'stable' into 0.4.10
Conflicts:
module/plugins/accounts/MegaRapidCz.py
module/plugins/accounts/ShareRapidCom.py
module/plugins/crypter/HotfileComFolder.py
module/plugins/crypter/HotfileFolderCom.py
module/plugins/hoster/Keep2shareCC.py
module/plugins/hoster/Keep2shareCc.py
module/plugins/hoster/MegaCoNz.py
module/plugins/hoster/MegaNz.py
module/plugins/hoster/MegaRapidCz.py
module/plugins/hoster/ShareRapidCom.py
module/plugins/internal/CaptchaService.py
pyload/api/__init__.py
pyload/manager/AccountManager.py
pyload/manager/PluginManager.py
pyload/manager/thread/PluginThread.py
pyload/network/HTTPRequest.py
pyload/network/XDCCRequest.py
pyload/plugins/Plugin.py
pyload/plugins/account/BillionuploadsCom.py
pyload/plugins/account/CramitIn.py
pyload/plugins/account/EasybytezCom.py
pyload/plugins/account/FastshareCz.py
pyload/plugins/account/File4safeCom.py
pyload/plugins/account/FileParadoxIn.py
pyload/plugins/account/FileomCom.py
pyload/plugins/account/FilerNet.py
pyload/plugins/account/FilerioCom.py
pyload/plugins/account/FourSharedCom.py
pyload/plugins/account/Ftp.py
pyload/plugins/account/Http.py
pyload/plugins/account/HugefilesNet.py
pyload/plugins/account/HundredEightyUploadCom.py
pyload/plugins/account/LomafileCom.py
pyload/plugins/account/MovReelCom.py
pyload/plugins/account/MultishareCz.py
pyload/plugins/account/MyfastfileCom.py
pyload/plugins/account/NosuploadCom.py
pyload/plugins/account/NovafileCom.py
pyload/plugins/account/QuickshareCz.py
pyload/plugins/account/RarefileNet.py
pyload/plugins/account/RyushareCom.py
pyload/plugins/account/SecureUploadEu.py
pyload/plugins/account/SendmywayCom.py
pyload/plugins/account/ShareRapidCom.py
pyload/plugins/account/StahnuTo.py
pyload/plugins/account/StreamcloudEu.py
pyload/plugins/account/TusfilesNet.py
pyload/plugins/account/UploadingCom.py
pyload/plugins/account/UptoboxCom.py
pyload/plugins/account/VidPlayNet.py
pyload/plugins/addon/Checksum.py
pyload/plugins/addon/ClickAndLoad.py
pyload/plugins/addon/DeleteFinished.py
pyload/plugins/addon/DownloadScheduler.py
pyload/plugins/addon/ExternalScripts.py
pyload/plugins/addon/ExtractArchive.py
pyload/plugins/addon/HotFolder.py
pyload/plugins/addon/IRCInterface.py
pyload/plugins/addon/MergeFiles.py
pyload/plugins/addon/MultiHome.py
pyload/plugins/addon/RestartFailed.py
pyload/plugins/addon/UnSkipOnFail.py
pyload/plugins/addon/WindowsPhoneToastNotify.py
pyload/plugins/addon/XMPPInterface.py
pyload/plugins/base/Container.py
pyload/plugins/base/Crypter.py
pyload/plugins/base/Hook.py
pyload/plugins/base/OCR.py
pyload/plugins/container/RSDF.py
pyload/plugins/crypter/DuploadOrgFolder.py
pyload/plugins/crypter/EasybytezComFolder.py
pyload/plugins/crypter/FiredriveComFolder.py
pyload/plugins/crypter/HotfileFolderCom.py
pyload/plugins/crypter/LinkSaveIn.py
pyload/plugins/crypter/MultiuploadCom.py
pyload/plugins/crypter/ShareRapidComFolder.py
pyload/plugins/crypter/TusfilesNetFolder.py
pyload/plugins/crypter/UploadableChFolder.py
pyload/plugins/crypter/UploadedToFolder.py
pyload/plugins/hook/Captcha9kw.py
pyload/plugins/hook/MyfastfileCom.py
pyload/plugins/hoster/BillionuploadsCom.py
pyload/plugins/hoster/CramitIn.py
pyload/plugins/hoster/EasybytezCom.py
pyload/plugins/hoster/File4safeCom.py
pyload/plugins/hoster/FileParadoxIn.py
pyload/plugins/hoster/FilefactoryCom.py
pyload/plugins/hoster/FileomCom.py
pyload/plugins/hoster/FilerioCom.py
pyload/plugins/hoster/FileshareInUa.py
pyload/plugins/hoster/FiredriveCom.py
pyload/plugins/hoster/Ftp.py
pyload/plugins/hoster/HugefilesNet.py
pyload/plugins/hoster/HundredEightyUploadCom.py
pyload/plugins/hoster/Keep2shareCC.py
pyload/plugins/hoster/LoadTo.py
pyload/plugins/hoster/LomafileCom.py
pyload/plugins/hoster/MegaNz.py
pyload/plugins/hoster/MegacrypterCom.py
pyload/plugins/hoster/MovReelCom.py
pyload/plugins/hoster/MyvideoDe.py
pyload/plugins/hoster/NosuploadCom.py
pyload/plugins/hoster/NovafileCom.py
pyload/plugins/hoster/PandaPlaNet.py
pyload/plugins/hoster/PremiumTo.py
pyload/plugins/hoster/RarefileNet.py
pyload/plugins/hoster/RyushareCom.py
pyload/plugins/hoster/SecureUploadEu.py
pyload/plugins/hoster/SendmywayCom.py
pyload/plugins/hoster/ShareRapidCom.py
pyload/plugins/hoster/SockshareCom.py
pyload/plugins/hoster/StreamcloudEu.py
pyload/plugins/hoster/TurbobitNet.py
pyload/plugins/hoster/TusfilesNet.py
pyload/plugins/hoster/UptoboxCom.py
pyload/plugins/hoster/VidPlayNet.py
pyload/plugins/hoster/WebshareCz.py
pyload/plugins/internal/DeadCrypter.py
pyload/plugins/internal/DeadHoster.py
pyload/plugins/internal/MultiHoster.py
pyload/plugins/internal/SimpleCrypter.py
pyload/plugins/internal/SimpleHoster.py
pyload/plugins/internal/UpdateManager.py
pyload/plugins/internal/XFSPAccount.py
pyload/plugins/internal/XFSPHoster.py
pyload/utils/__init__.py
pyload/utils/packagetools.py
pyload/webui/app/cnl.py
Diffstat (limited to 'module/plugins/internal')
-rw-r--r-- | module/plugins/internal/CaptchaService.py | 209 | ||||
-rw-r--r-- | module/plugins/internal/XFSAccount.py | 122 | ||||
-rw-r--r-- | module/plugins/internal/XFSCrypter.py | 29 | ||||
-rw-r--r-- | module/plugins/internal/XFSHoster.py | 345 |
4 files changed, 705 insertions, 0 deletions
diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py new file mode 100644 index 000000000..38775f519 --- /dev/null +++ b/module/plugins/internal/CaptchaService.py @@ -0,0 +1,209 @@ +# -*- coding: utf-8 -*- + +import re + +from random import random + + +class CaptchaService: + __name__ = "CaptchaService" + __version__ = "0.14" + + __description__ = """Base captcha service plugin""" + __license__ = "GPLv3" + __authors__ = [("pyLoad Team", "admin@pyload.org")] + + + KEY_PATTERN = None + + key = None #: last key detected + + + def __init__(self, plugin): + self.plugin = plugin + + + def detect_key(self, html=None): + if not html: + if hasattr(self.plugin, "html") and self.plugin.html: + html = self.plugin.html + else: + errmsg = _("%s html not found") % self.__name__ + self.plugin.fail(errmsg) #@TODO: replace all plugin.fail(errmsg) with plugin.error(errmsg) in 0.4.10 + raise TypeError(errmsg) + + m = re.search(self.KEY_PATTERN, html) + if m: + self.key = m.group("KEY") + self.plugin.logDebug("%s key: %s" % (self.__name__, self.key)) + return self.key + else: + self.plugin.logDebug("%s key not found" % self.__name__) + return None + + + def challenge(self, key=None): + raise NotImplementedError + + + def result(self, server, challenge): + raise NotImplementedError + + +class ReCaptcha(CaptchaService): + __name__ = "ReCaptcha" + __version__ = "0.07" + + __description__ = """ReCaptcha captcha service plugin""" + __license__ = "GPLv3" + __authors__ = [("pyLoad Team", "admin@pyload.org")] + + + KEY_PATTERN = r'recaptcha(/api|\.net)/(challenge|noscript)\?k=(?P<KEY>[\w-]+)' + KEY_AJAX_PATTERN = r'Recaptcha\.create\s*\(\s*["\'](?P<KEY>[\w-]+)' + + + def detect_key(self, html=None): + if not html: + if hasattr(self.plugin, "html") and self.plugin.html: + html = self.plugin.html + else: + errmsg = _("ReCaptcha html not found") + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + m = re.search(self.KEY_PATTERN, html) or re.search(self.KEY_AJAX_PATTERN, html) + if m: + self.key = m.group("KEY") + self.plugin.logDebug("ReCaptcha key: %s" % self.key) + return self.key + else: + self.plugin.logDebug("ReCaptcha key not found") + return None + + + def challenge(self, key=None): + if not key: + if self.detect_key(): + key = self.key + else: + errmsg = _("ReCaptcha key not found") + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={'k': key}) + + try: + challenge = re.search("challenge : '(.+?)',", js).group(1) + server = re.search("server : '(.+?)',", js).group(1) + except: + self.plugin.error("ReCaptcha challenge pattern not found") + + result = self.result(server, challenge) + + return challenge, result + + + def result(self, server, challenge): + return self.plugin.decryptCaptcha("%simage" % server, get={'c': challenge}, + cookies=True, forceUser=True, imgtype="jpg") + + +class AdsCaptcha(CaptchaService): + __name__ = "AdsCaptcha" + __version__ = "0.04" + + __description__ = """AdsCaptcha captcha service plugin""" + __license__ = "GPLv3" + __authors__ = [("pyLoad Team", "admin@pyload.org")] + + + ID_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*CaptchaId=(?P<ID>\d+)' + KEY_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*PublicKey=(?P<KEY>[\w-]+)' + + + def detect_key(self, html=None): + if not html: + if hasattr(self.plugin, "html") and self.plugin.html: + html = self.plugin.html + else: + errmsg = _("AdsCaptcha html not found") + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + m = re.search(self.ID_PATTERN, html) + n = re.search(self.KEY_PATTERN, html) + if m and n: + self.key = (m.group("ID"), m.group("KEY")) + self.plugin.logDebug("AdsCaptcha id|key: %s | %s" % self.key) + return self.key + else: + self.plugin.logDebug("AdsCaptcha id or key not found") + return None + + + def challenge(self, key=None): #: key is a tuple(CaptchaId, PublicKey) + if not key: + if self.detect_key(): + key = self.key + else: + errmsg = _("AdsCaptcha key not found") + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + CaptchaId, PublicKey = key + + js = self.plugin.req.load("http://api.adscaptcha.com/Get.aspx", get={'CaptchaId': CaptchaId, 'PublicKey': PublicKey}) + + try: + challenge = re.search("challenge: '(.+?)',", js).group(1) + server = re.search("server: '(.+?)',", js).group(1) + except: + self.plugin.error("AdsCaptcha challenge pattern not found") + + result = self.result(server, challenge) + + return challenge, result + + + def result(self, server, challenge): + return self.plugin.decryptCaptcha("%sChallenge.aspx" % server, get={'cid': challenge, 'dummy': random()}, + cookies=True, imgtype="jpg") + + +class SolveMedia(CaptchaService): + __name__ = "SolveMedia" + __version__ = "0.05" + + __description__ = """SolveMedia captcha service plugin""" + __license__ = "GPLv3" + __authors__ = [("pyLoad Team", "admin@pyload.org")] + + + KEY_PATTERN = r'api\.solvemedia\.com/papi/challenge\.(no)?script\?k=(?P<KEY>.+?)["\']' + + + def challenge(self, key=None): + if not key: + if self.detect_key(): + key = self.key + else: + errmsg = _("SolveMedia key not found") + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.noscript", get={'k': key}) + try: + challenge = re.search(r'<input type=hidden name="adcopy_challenge" id="adcopy_challenge" value="([^"]+)">', + html).group(1) + server = "http://api.solvemedia.com/papi/media" + except: + self.plugin.error("SolveMedia challenge pattern not found") + + result = self.result(server, challenge) + + return challenge, result + + + def result(self, server, challenge): + return self.plugin.decryptCaptcha(server, get={'c': challenge}, imgtype="gif") diff --git a/module/plugins/internal/XFSAccount.py b/module/plugins/internal/XFSAccount.py new file mode 100644 index 000000000..ba2c00ec9 --- /dev/null +++ b/module/plugins/internal/XFSAccount.py @@ -0,0 +1,122 @@ +# -*- coding: utf-8 -*- + +import re + +from time import gmtime, mktime, strptime +from urlparse import urljoin + +from module.plugins.Account import Account +from module.plugins.internal.SimpleHoster import parseHtmlForm, set_cookies + + +class XFSAccount(Account): + __name__ = "XFSAccount" + __type__ = "account" + __version__ = "0.25" + + __description__ = """XFileSharing account plugin""" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_DOMAIN = None + HOSTER_URL = None + + COOKIES = [(HOSTER_DOMAIN, "lang", "english")] + + PREMIUM_PATTERN = r'\(Premium only\)' + + VALID_UNTIL_PATTERN = r'>Premium.[Aa]ccount expire:.*?(\d{1,2} [\w^_]+ \d{4})' + + TRAFFIC_LEFT_PATTERN = r'>Traffic available today:.*?<b>\s*(?P<S>[\d.,]+|[Uu]nlimited)\s*(?:(?P<U>[\w^_]+)\s*)?</b>' + TRAFFIC_LEFT_UNIT = "MB" #: used only if no group <U> was found + + LOGIN_FAIL_PATTERN = r'>(Incorrect Login or Password|Error<)' + + + def __init__(self, manager, accounts): #@TODO: remove in 0.4.10 + self.init() + return super(XFSAccount, self).__init__(manager, accounts) + + + def init(self): + # if not self.HOSTER_DOMAIN: + # self.fail(_("Missing HOSTER_DOMAIN")) + + if not self.HOSTER_URL: + self.HOSTER_URL = "http://www.%s/" % self.HOSTER_DOMAIN + + + def loadAccountInfo(self, user, req): + validuntil = None + trafficleft = None + premium = None + + html = req.load(self.HOSTER_URL, get={'op': "my_account"}, decode=True) + + premium = True if re.search(self.PREMIUM_PATTERN, html) else False + + m = re.search(self.VALID_UNTIL_PATTERN, html) + if m: + expiredate = m.group(1).strip() + self.logDebug("Expire date: " + expiredate) + + try: + validuntil = mktime(strptime(expiredate, "%d %B %Y")) + + except Exception, e: + self.logError(e) + + else: + if validuntil > mktime(gmtime()): + premium = True + else: + premium = False + validuntil = None #: registered account type (not premium) + + m = re.search(self.TRAFFIC_LEFT_PATTERN, html) + if m: + try: + traffic = m.groupdict() + size = traffic['S'] + + if "nlimited" in size: + trafficleft = -1 + if validuntil is None: + validuntil = -1 + else: + if 'U' in traffic: + unit = traffic['U'] + elif isinstance(self.TRAFFIC_LEFT_UNIT, basestring): + unit = self.TRAFFIC_LEFT_UNIT + else: + unit = "" + + trafficleft = self.parseTraffic(size + unit) + + except Exception, e: + self.logError(e) + + return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} + + + def login(self, user, data, req): + if isinstance(self.COOKIES, list): + set_cookies(req.cj, self.COOKIES) + + url = urljoin(self.HOSTER_URL, "login.html") + html = req.load(url, decode=True) + + action, inputs = parseHtmlForm('name="FL"', html) + if not inputs: + inputs = {'op': "login", + 'redirect': self.HOSTER_URL} + + inputs.update({'login': user, + 'password': data['password']}) + + html = req.load(self.HOSTER_URL, post=inputs, decode=True) + + if re.search(self.LOGIN_FAIL_PATTERN, html): + self.wrongPassword() diff --git a/module/plugins/internal/XFSCrypter.py b/module/plugins/internal/XFSCrypter.py new file mode 100644 index 000000000..62fd8c017 --- /dev/null +++ b/module/plugins/internal/XFSCrypter.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.SimpleCrypter import SimpleCrypter + + +class XFSCrypter(SimpleCrypter): + __name__ = "XFSCrypter" + __type__ = "crypter" + __version__ = "0.04" + + __pattern__ = r'^unmatchable$' + + __description__ = """XFileSharing decrypter plugin""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_DOMAIN = None + HOSTER_NAME = None + + URL_REPLACEMENTS = [(r'&?per_page=\d+', ""), (r'[?/&]+$', ""), (r'(.+/[^?]+)$', r'\1?'), (r'$', r'&per_page=10000')] + + COOKIES = [(HOSTER_DOMAIN, "lang", "english")] + + LINK_PATTERN = r'<(?:td|TD).*?>\s*<a href="(.+?)".*?>.+?(?:</a>)?\s*</(?:td|TD)>' + NAME_PATTERN = r'<[tT]itle>.*?\: (?P<N>.+) folder</[tT]itle>' + + OFFLINE_PATTERN = r'>\s*\w+ (Not Found|file (was|has been) removed)' + TEMP_OFFLINE_PATTERN = r'>\s*\w+ server (is in )?(maintenance|maintainance)' diff --git a/module/plugins/internal/XFSHoster.py b/module/plugins/internal/XFSHoster.py new file mode 100644 index 000000000..f54bb5e45 --- /dev/null +++ b/module/plugins/internal/XFSHoster.py @@ -0,0 +1,345 @@ +# -*- coding: utf-8 -*- + +import re + +from random import random +from time import sleep + +from pycurl import FOLLOWLOCATION, LOW_SPEED_TIME + +from module.plugins.hoster.UnrestrictLi import secondsToMidnight +from module.plugins.internal.CaptchaService import ReCaptcha, SolveMedia +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.utils import html_unescape + + +class XFSHoster(SimpleHoster): + __name__ = "XFSHoster" + __type__ = "hoster" + __version__ = "0.15" + + __pattern__ = r'^unmatchable$' + + __description__ = """XFileSharing hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_DOMAIN = None + HOSTER_NAME = None + + URL_REPLACEMENTS = [(r'/(?:embed-)?(\w{12}).*', r'/\1')] #: plus support embedded files + + COOKIES = [(HOSTER_DOMAIN, "lang", "english")] + + INFO_PATTERN = r'<tr><td align=right><b>Filename:</b></td><td nowrap>(?P<N>[^<]+)</td></tr>\s*.*?<small>\((?P<S>[^<]+)\)</small>' + NAME_PATTERN = r'<input type="hidden" name="fname" value="(?P<N>[^"]+)"' + SIZE_PATTERN = r'You have requested .*\((?P<S>[\d.,]+) ?(?P<U>[\w^_]+)?\)</font>' + + OFFLINE_PATTERN = r'>\s*\w+ (Not Found|file (was|has been) removed)' + TEMP_OFFLINE_PATTERN = r'>\s*\w+ server (is in )?(maintenance|maintainance)' + + WAIT_PATTERN = r'<span id="countdown_str">.*?>(\d+)</span>' + + OVR_LINK_PATTERN = r'<h2>Download Link</h2>\s*<textarea[^>]*>([^<]+)' + LINK_PATTERN = None #: final download url pattern + + CAPTCHA_PATTERN = r'(http://[^"\']+?/captchas?/[^"\']+)' + CAPTCHA_DIV_PATTERN = r'>Enter code.*?<div.*?>(.+?)</div>' + RECAPTCHA_PATTERN = None + SOLVEMEDIA_PATTERN = None + + ERROR_PATTERN = r'(?:class=["\']err["\'][^>]*>|<[Cc]enter><b>)(.+?)(?:["\']|</)|>\(ERROR:(.+?)\)' + + + def setup(self): + self.chunkLimit = 1 + self.resumeDownload = self.multiDL = self.premium + + + def prepare(self): + """ Initialize important variables """ + if not self.HOSTER_DOMAIN: + self.fail(_("Missing HOSTER_DOMAIN")) + + if not self.HOSTER_NAME: + self.HOSTER_NAME = "".join([str.capitalize() for str in self.HOSTER_DOMAIN.split('.')]) + + if not self.LINK_PATTERN: + pattern = r'(https?://(www\.)?([^/]*?%s|\d+\.\d+\.\d+\.\d+)(\:\d+)?(/d/|(/files)?/\d+/\w+/).+?)["\'<]' + self.LINK_PATTERN = pattern % self.HOSTER_DOMAIN.replace('.', '\.') + + self.captcha = None + self.errmsg = None + self.passwords = self.getPassword().splitlines() + + if (self.__pattern__ != self.core.pluginManager.hosterPlugins[self.__name__]['pattern'] + and re.match(self.__pattern__, self.pyfile.url) is None): + self.logInfo(_("Multi hoster detected")) + if self.premium: + self.logDebug(_("Looking for download link...")) + self.handleOverriden() + else: + self.fail(_("Only premium users can use url leech feature")) + + return super(XFSHoster, self).prepare() + + + def handleFree(self): + link = self.getDownloadLink() + + if link: + if self.captcha: + self.correctCaptcha() + + self.download(link, ref=True, cookies=True, disposition=True) + + elif self.errmsg: + if 'captcha' in self.errmsg: + self.fail(_("No valid captcha code entered")) + else: + self.fail(self.errmsg) + + else: + self.fail(_("Download link not found")) + + + def handlePremium(self): + return self.handleFree() + + + def getDownloadLink(self): + for i in xrange(1, 5): + self.logDebug("Getting download link: #%d" % i) + + self.checkErrors() + + m = re.search(self.LINK_PATTERN, self.html, re.S) + if m: + break + + data = self.getPostParameters() + + # sleep(10) + + self.req.http.c.setopt(FOLLOWLOCATION, 0) + + self.html = self.load(self.pyfile.url, post=data, ref=True, decode=True) + self.header = self.req.http.header + + self.req.http.c.setopt(FOLLOWLOCATION, 1) + + m = re.search(r'Location\s*:\s*(.+)', self.header, re.I) + if m: + break + + m = re.search(self.LINK_PATTERN, self.html, re.S) + if m: + break + else: + return + + self.errmsg = None + + return m.group(1).strip() #@TODO: Remove .strip() in 0.4.10 + + + def handleOverriden(self): + #only tested with easybytez.com + self.html = self.load("http://www.%s/" % self.HOSTER_DOMAIN) + + action, inputs = self.parseHtmlForm('') + + upload_id = "%012d" % int(random() * 10 ** 12) + action += upload_id + "&js_on=1&utype=prem&upload_type=url" + + inputs['tos'] = '1' + inputs['url_mass'] = self.pyfile.url + inputs['up1oad_type'] = 'url' + + self.logDebug(action, inputs) + + self.req.setOption("timeout", 600) #: wait for file to upload to easybytez.com + + self.html = self.load(action, post=inputs) + + self.checkErrors() + + action, inputs = self.parseHtmlForm('F1') + if not inputs: + if self.errmsg: + self.retry(reason=self.errmsg) + else: + self.error(_("TEXTAREA F1 not found")) + + self.logDebug(inputs) + + stmsg = inputs['st'] + + if stmsg == 'OK': + self.html = self.load(action, post=inputs) + + elif 'Can not leech file' in stmsg: + self.retry(20, 3 * 60, _("Can not leech file")) + + elif 'today' in stmsg: + self.retry(wait_time=secondsToMidnight(gmt=2), reason=_("You've used all Leech traffic today")) + + else: + self.fail(stmsg) + + #get easybytez.com link for uploaded file + m = re.search(self.OVR_LINK_PATTERN, self.html) + if m is None: + self.error(_("OVR_LINK_PATTERN not found")) + + header = self.load(m.group(1).strip(), just_header=True, decode=True) #@TODO: Remove .strip() in 0.4.10 + if 'location' in header: #: Direct download link + self.download(header['location'], ref=True, cookies=True, disposition=True) + else: + self.fail(_("Download link not found")) + + + def checkErrors(self): + m = re.search(self.ERROR_PATTERN, self.html) + + if m is None: + self.errmsg = None + else: + self.errmsg = m.group(1) + + self.logWarning(re.sub(r"<.*?>", " ", self.errmsg)) + + if 'wait' in self.errmsg: + wait_time = sum([int(v) * {"hour": 3600, "minute": 60, "second": 1}[u] for v, u in + re.findall(r'(\d+)\s*(hour|minute|second)', self.errmsg)]) + self.wait(wait_time, True) + + elif 'captcha' in self.errmsg: + self.invalidCaptcha() + + elif 'premium' in self.errmsg and 'require' in self.errmsg: + self.fail(_("File can be downloaded by premium users only")) + + elif 'limit' in self.errmsg: + if 'days' in self.errmsg: + delay = secondsToMidnight(gmt=2) + retries = 3 + else: + delay = 1 * 60 * 60 + retries = 25 + + self.wait(delay, True) + self.retry(retries, reason=_("Download limit exceeded")) + + elif 'countdown' in self.errmsg or 'Expired' in self.errmsg: + self.retry(reason=_("Link expired")) + + elif 'maintenance' in self.errmsg or 'maintainance' in self.errmsg: + self.tempOffline() + + elif 'download files up to' in self.errmsg: + self.fail(_("File too large for free download")) + + else: + self.retry(wait_time=60, reason=self.errmsg) + + return self.errmsg + + + def getPostParameters(self): + for _i in xrange(3): + if hasattr(self, "FORM_PATTERN"): + action, inputs = self.parseHtmlForm(self.FORM_PATTERN) + else: + action, inputs = self.parseHtmlForm(input_names={"op": re.compile("^download")}) + + if not inputs: + action, inputs = self.parseHtmlForm('F1') + if not inputs: + if self.errmsg: + self.retry(reason=self.errmsg) + else: + self.error(_("TEXTAREA F1 not found")) + + self.logDebug(inputs) + + if 'op' in inputs and inputs['op'] in ("download2", "download3"): + if "password" in inputs: + if self.passwords: + inputs['password'] = self.passwords.pop(0) + else: + self.fail(_("No or invalid passport")) + + if not self.premium: + m = re.search(self.WAIT_PATTERN, self.html) + if m: + wait_time = int(m.group(1)) + self.setWait(wait_time, False) + else: + wait_time = 0 + + self.captcha = self.handleCaptcha(inputs) + + if wait_time: + self.wait() + + return inputs + else: + inputs['referer'] = self.pyfile.url + + if self.premium: + inputs['method_premium'] = "Premium Download" + if 'method_free' in inputs: + del inputs['method_free'] + else: + inputs['method_free'] = "Free Download" + if 'method_premium' in inputs: + del inputs['method_premium'] + + self.html = self.load(self.pyfile.url, post=inputs, ref=True) + else: + self.error(_("FORM: %s") % (inputs['op'] if 'op' in inputs else _("UNKNOWN"))) + + + def handleCaptcha(self, inputs): + m = re.search(self.CAPTCHA_PATTERN, self.html) + if m: + captcha_url = m.group(1) + inputs['code'] = self.decryptCaptcha(captcha_url) + return 1 + + m = re.search(self.CAPTCHA_DIV_PATTERN, self.html, re.S) + if m: + captcha_div = m.group(1) + self.logDebug(captcha_div) + numerals = re.findall(r'<span.*?padding-left\s*:\s*(\d+).*?>(\d)</span>', html_unescape(captcha_div)) + inputs['code'] = "".join([a[1] for a in sorted(numerals, key=lambda num: int(num[0]))]) + self.logDebug("Captcha code: %s" % inputs['code'], numerals) + return 2 + + recaptcha = ReCaptcha(self) + try: + captcha_key = re.search(self.RECAPTCHA_PATTERN, self.html).group(1) + except: + captcha_key = recaptcha.detect_key() + + if captcha_key: + self.logDebug("ReCaptcha key: %s" % captcha_key) + inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge(captcha_key) + return 3 + + solvemedia = SolveMedia(self) + try: + captcha_key = re.search(self.SOLVEMEDIA_PATTERN, self.html).group(1) + except: + captcha_key = solvemedia.detect_key() + + if captcha_key: + self.logDebug("SolveMedia key: %s" % captcha_key) + inputs['adcopy_challenge'], inputs['adcopy_response'] = solvemedia.challenge(captcha_key) + return 4 + + return 0 |