diff options
author | zoidberg10 <zoidberg@mujmail.cz> | 2012-10-01 23:52:18 +0200 |
---|---|---|
committer | zoidberg10 <zoidberg@mujmail.cz> | 2012-10-01 23:52:18 +0200 |
commit | a3ecb6eaa2b449c15ce6367e21b3744401e5ab18 (patch) | |
tree | 39a6af87f47f7aa8e0af4f58e1aff00bfce2359e | |
parent | filebeer folder crypter, multihoster unload fix (diff) | |
download | pyload-a3ecb6eaa2b449c15ce6367e21b3744401e5ab18.tar.xz |
rapidgator.net premium, novafile.com free, multihoster schedule refresh
-rw-r--r-- | module/plugins/accounts/RapidgatorNet.py | 75 | ||||
-rw-r--r-- | module/plugins/hoster/CzshareCom.py | 5 | ||||
-rw-r--r-- | module/plugins/hoster/EuroshareEu.py | 48 | ||||
-rw-r--r-- | module/plugins/hoster/NovafileCom.py | 24 | ||||
-rw-r--r-- | module/plugins/hoster/RapidgatorNet.py | 81 | ||||
-rw-r--r-- | module/plugins/hoster/XFileSharingPro.py | 11 | ||||
-rw-r--r-- | module/plugins/internal/CaptchaService.py | 79 | ||||
-rw-r--r-- | module/plugins/internal/MultiHoster.py | 73 |
8 files changed, 296 insertions, 100 deletions
diff --git a/module/plugins/accounts/RapidgatorNet.py b/module/plugins/accounts/RapidgatorNet.py new file mode 100644 index 000000000..e88be71ea --- /dev/null +++ b/module/plugins/accounts/RapidgatorNet.py @@ -0,0 +1,75 @@ +# -*- coding: utf-8 -*- + +""" + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, + or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + @author: zoidberg +""" + +import re +from module.plugins.Account import Account +from module.utils import parseFileSize +from module.common.json_layer import json_loads + +class RapidgatorNet(Account): + __name__ = "RapidgatorNet" + __version__ = "0.01" + __type__ = "account" + __description__ = """rapidgator.net account plugin""" + __author_name__ = ("zoidberg") + __author_mail__ = ("zoidberg@mujmail.cz") + + API_URL = 'http://test.rapidgator.net/api/user' + + def loadAccountInfo(self, user, req): + try: + sid = self.getAccountData(user).get('SID') + assert sid + + json = req.load("%s/info?sid=%s" % (self.API_URL, sid)) + self.logDebug("API:USERINFO", json) + json = json_loads(json) + + if json['response_status'] == 200: + if "reset_in" in json['response']: + self.scheduleRefresh(user, json['response']['reset_in']) + + return {"validuntil": json['response']['expire_date'], + "trafficleft": json['response']['traffic_left'] / 1024, + "premium": True} + else: + self.logError(json['response_details']) + except Exception, e: + self.logError(e) + + return {"validuntil": None, "trafficleft": None, "premium": False} + + def login(self, user, data, req): + try: + self.logDebug("DATA", user, data) + json = req.load('%s/login' % self.API_URL, + post = {"username": user, + "password": data['password']}) + self.logDebug("API:LOGIN", json) + json = json_loads(json) + + if json['response_status'] == 200: + data['SID'] = str(json['response']['session_id']) + return + else: + self.logError(json['response_details']) + except Exception, e: + self.logError(e) + + self.wrongPassword()
\ No newline at end of file diff --git a/module/plugins/hoster/CzshareCom.py b/module/plugins/hoster/CzshareCom.py index 356771ce4..8d035b64c 100644 --- a/module/plugins/hoster/CzshareCom.py +++ b/module/plugins/hoster/CzshareCom.py @@ -45,7 +45,7 @@ class CzshareCom(SimpleHoster): __name__ = "CzshareCom" __type__ = "hoster" __pattern__ = r"http://(\w*\.)*czshare\.(com|cz)/(\d+/|download.php\?).*" - __version__ = "0.89" + __version__ = "0.90" __description__ = """CZshare.com""" __author_name__ = ("zoidberg") @@ -142,6 +142,9 @@ class CzshareCom(SimpleHoster): self.html = self.load(parsed_url, cookies=True, post=inputs) + if re.search(self.MULTIDL_PATTERN, self.html): + self.waitForFreeSlot() + found = re.search("countdown_number = (\d+);", self.html) self.setWait(int(found.group(1)) if found else 50) diff --git a/module/plugins/hoster/EuroshareEu.py b/module/plugins/hoster/EuroshareEu.py index a0bfe0ab2..2c356f02a 100644 --- a/module/plugins/hoster/EuroshareEu.py +++ b/module/plugins/hoster/EuroshareEu.py @@ -17,51 +17,31 @@ """ import re -from module.plugins.Hoster import Hoster -from module.network.RequestFactory import getURL +from module.plugins.internal.SimpleHoster import SimpleHoster -def getInfo(urls): - result = [] - - for url in urls: - - html = getURL(url, decode=True) - if re.search(EuroshareEu.FILE_OFFLINE_PATTERN, html): - # File offline - result.append((url, 0, 1, url)) - else: - result.append((url, 0, 2, url)) - yield result - -class EuroshareEu(Hoster): +class EuroshareEu(SimpleHoster): __name__ = "EuroshareEu" __type__ = "hoster" - __pattern__ = r"http://(\w*\.)?euroshare.eu/file/.*" - __version__ = "0.2b" + __pattern__ = r"http://(\w*\.)?euroshare.(eu|sk|cz|hu|pl)/file/.*" + __version__ = "0.21" __description__ = """Euroshare.eu""" __author_name__ = ("zoidberg") - URL_PATTERN = r'<a class="free" href="([^"]+)"></a>' - FILE_OFFLINE_PATTERN = r'<h2>S.bor sa nena.iel</h2>' - ERR_PARDL_PATTERN = r'<h2>Prebieha s.ahovanie</h2>' - - def setup(self): - self.multiDL = False - - def process(self, pyfile): - self.html = self.load(pyfile.url, decode=True) - - if re.search(self.FILE_OFFLINE_PATTERN, self.html) is not None: - self.offline() + FILE_INFO_PATTERN = r'<span style="float: left;"><strong>(?P<N>.+?)</strong> \((?P<S>.+?)\)</span>' + FILE_OFFLINE_PATTERN = ur'<h2>S.bor sa nena.iel</h2>|Požadovaná stránka neexistuje!' + + FREE_URL_PATTERN = r'<a href="(/file/\d+/[^/]*/download/)"><div class="downloadButton"' + ERR_PARDL_PATTERN = r'<h2>Prebieha s.ahovanie</h2>' + def handleFree(self): if re.search(self.ERR_PARDL_PATTERN, self.html) is not None: self.waitForFreeSlot() - found = re.search(self.URL_PATTERN, self.html) + found = re.search(self.FREE_URL_PATTERN, self.html) if found is None: - self.fail("Parse error (URL)") - parsed_url = found.group(1) - + self.parseError("Parse error (URL)") + parsed_url = "http://euroshare.eu%s" % found.group(1) + self.logDebug("URL", parsed_url) self.download(parsed_url, disposition=True) def waitForFreeSlot(self): diff --git a/module/plugins/hoster/NovafileCom.py b/module/plugins/hoster/NovafileCom.py new file mode 100644 index 000000000..dfd18761c --- /dev/null +++ b/module/plugins/hoster/NovafileCom.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from module.plugins.hoster.XFileSharingPro import XFileSharingPro, create_getInfo + +class NovafileCom(XFileSharingPro): + __name__ = "NovafileCom" + __type__ = "hoster" + __pattern__ = r"http://(?:\w*\.)*novafile\.com/\w{12}" + __version__ = "0.01" + __description__ = """novafile.com hoster plugin""" + __author_name__ = ("zoidberg") + __author_mail__ = ("zoidberg@mujmail.cz") + + FILE_SIZE_PATTERN = r'<div class="size">(?P<S>.+?)</div>' + #FILE_OFFLINE_PATTERN = '<b>"File Not Found"</b>|File has been removed due to Copyright Claim' + FORM_PATTERN = r'name="F\d+"' + ERROR_PATTERN = r'class="alert[^"]*alert-separate"[^>]*>\s*(?:<p>)?(.*?)\s*</' + DIRECT_LINK_PATTERN = r'<a href="(http://s\d+\.novafile\.com/.*?)" class="btn btn-green">Download File</a>' + + HOSTER_NAME = "novafile.com" + + def setup(self): + self.multiDL = False + +getInfo = create_getInfo(NovafileCom)
\ No newline at end of file diff --git a/module/plugins/hoster/RapidgatorNet.py b/module/plugins/hoster/RapidgatorNet.py index 678a3d707..291ba4c4b 100644 --- a/module/plugins/hoster/RapidgatorNet.py +++ b/module/plugins/hoster/RapidgatorNet.py @@ -21,55 +21,18 @@ from pycurl import HTTPHEADER from random import random from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.CaptchaServices import ReCaptcha, SolveMedia, AdsCaptcha from module.common.json_layer import json_loads -from module.plugins.ReCaptcha import ReCaptcha - -class AdsCaptcha(): - def __init__(self, plugin): - self.plugin = plugin - - def challenge(self, src): - js = self.plugin.req.load(src, cookies=True) - - try: - challenge = re.search("challenge: '(.*?)',", js).group(1) - server = re.search("server: '(.*?)',", js).group(1) - except: - self.plugin.fail("adscaptcha error") - 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(): - def __init__(self,plugin): - self.plugin = plugin - - def challenge(self, src): - html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.script?k=%s" % src, cookies=True) - try: - ckey = re.search("ckey:.*?'(.*?)',",html).group(1) - html = self.plugin.req.load("http://api.solvemedia.com/papi/_challenge.js?k=%s" % ckey, cookies=True) - challenge = re.search('"chid".*?: "(.*?)"',html).group(1) - except: - self.plugin.fail("solvmedia error") - result = self.result(challenge) - - return challenge, result - - def result(self,challenge): - return self.plugin.decryptCaptcha("http://api.solvemedia.com/papi/media?c=%s" % challenge,imgtype="gif") - class RapidgatorNet(SimpleHoster): __name__ = "RapidgatorNet" __type__ = "hoster" __pattern__ = r"http://(?:www\.)?(rapidgator.net)/file/(\d+)" - __version__ = "0.06" + __version__ = "0.08" __description__ = """rapidgator.net""" __author_name__ = ("zoidberg","chrox") + + API_URL = 'http://test.rapidgator.net/api/file' FILE_INFO_PATTERN = r'Downloading:(\s*<[^>]*>)*\s*(?P<N>.*?)(\s*<[^>]*>)*\s*File size:\s*<strong>(?P<S>.*?)</strong>' FILE_OFFLINE_PATTERN = r'<title>File not found</title>' @@ -79,6 +42,39 @@ class RapidgatorNet(SimpleHoster): RECAPTCHA_KEY_PATTERN = r'"http://api.recaptcha.net/challenge?k=(.*?)"' ADSCAPTCHA_SRC_PATTERN = r'(http://api.adscaptcha.com/Get.aspx[^"\']*)' SOLVEMEDIA_PATTERN = r'http:\/\/api\.solvemedia\.com\/papi\/challenge\.script\?k=(.*?)"' + + def process(self, pyfile): + self.pyfile = pyfile + if self.premium: + self.handlePremium() + else: + self.fail("NO FREE") + + def getAPIResponse(self, cmd): + json = self.load('%s/%s' % (self.API_URL, cmd), + get = {'sid': self.account.getAccountData(self.user).get('SID'), + 'url': self.pyfile.url}) + self.logDebug('API:%s' % cmd, json) + json = json_loads(json) + + status = json['response_status'] + if status == 200: + return json['response'] + elif status == 401: + self.account.relogin(self.user) + self.retry() + elif status == 423: + self.account.empty(self.user) + self.retry() + else: + self.fail(json['response_details']) + + def handlePremium(self): + self.api_data = self.getAPIResponse('info') + self.pyfile.name = self.api_data['filename'] + self.pyfile.size = self.api_data['size'] + url = self.getAPIResponse('download')['url'] + self.download(url) def handleFree(self): if "You can download files up to 500 MB in free mode" in self.html \ @@ -177,5 +173,4 @@ class RapidgatorNet(SimpleHoster): self.logDebug(url, response) return json_loads(response) -getInfo = create_getInfo(RapidgatorNet) - +getInfo = create_getInfo(RapidgatorNet)
\ No newline at end of file diff --git a/module/plugins/hoster/XFileSharingPro.py b/module/plugins/hoster/XFileSharingPro.py index 8e213e9bf..ef559a56f 100644 --- a/module/plugins/hoster/XFileSharingPro.py +++ b/module/plugins/hoster/XFileSharingPro.py @@ -34,7 +34,7 @@ class XFileSharingPro(SimpleHoster): __name__ = "XFileSharingPro" __type__ = "hoster" __pattern__ = r"^unmatchable$" - __version__ = "0.11" + __version__ = "0.12" __description__ = """XFileSharingPro common hoster base""" __author_name__ = ("zoidberg") __author_mail__ = ("zoidberg@mujmail.cz") @@ -51,7 +51,8 @@ class XFileSharingPro(SimpleHoster): CAPTCHA_URL_PATTERN = r'(http://[^"\']+?/captchas?/[^"\']+)' RECAPTCHA_URL_PATTERN = r'http://[^"\']+?recaptcha[^"\']+?\?k=([^"\']+)"' CAPTCHA_DIV_PATTERN = r'<b>Enter code.*?<div.*?>(.*?)</div>' - ERROR_PATTERN = r'class=["\']err["\'][^>]*>(.*?)</' + ERROR_PATTERN = r'class=["\']err["\'][^>]*>(.*?)</' + FORM_PATTERN = 'F1' def setup(self): self.__pattern__ = self.core.pluginManager.hosterPlugins[self.__name__]['pattern'] @@ -153,7 +154,7 @@ class XFileSharingPro(SimpleHoster): self.req.http.c.setopt(LOW_SPEED_TIME, 600) self.html = self.load(action, post = inputs) - action, inputs = self.parseHtmlForm('F1') + action, inputs = self.parseHtmlForm(self.FORM_PATTERN) if not inputs: self.parseError('TEXTAREA') self.logDebug(self.HOSTER_NAME, inputs) if inputs['st'] == 'OK': @@ -190,7 +191,7 @@ class XFileSharingPro(SimpleHoster): self.retry(25) elif 'captcha' in self.errmsg: self.invalidCaptcha() - elif 'countdown' or 'Expired session' in self.errmsg: + elif 'countdown' in self.errmsg or 'Expired session' in self.errmsg: self.retry(3) elif 'maintenance' in self.errmsg: self.tempOffline() @@ -210,7 +211,7 @@ class XFileSharingPro(SimpleHoster): for i in range(3): if not self.errmsg: self.checkErrors() - action, inputs = self.parseHtmlForm('F1') + action, inputs = self.parseHtmlForm(self.FORM_PATTERN) if not inputs: action, inputs = self.parseHtmlForm("action=(''|\"\")") if not inputs: diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py new file mode 100644 index 000000000..8be442d37 --- /dev/null +++ b/module/plugins/internal/CaptchaService.py @@ -0,0 +1,79 @@ +# -*- coding: utf-8 -*- +""" + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, + or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + @author: zoidberg +""" + +import re + +class CaptchaService() + __version__ = "0.01" + + def __init__(self, plugin): + self.plugin = plugin + +class ReCaptcha(): + def __init__(self, plugin): + self.plugin = plugin + + def challenge(self, id): + js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={"k":id}, cookies=True) + + try: + challenge = re.search("challenge : '(.*?)',", js).group(1) + server = re.search("server : '(.*?)',", js).group(1) + except: + self.plugin.fail("recaptcha error") + 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): + def challenge(self, src): + js = self.plugin.req.load(src, cookies=True) + + try: + challenge = re.search("challenge: '(.*?)',", js).group(1) + server = re.search("server: '(.*?)',", js).group(1) + except: + self.plugin.fail("adscaptcha error") + 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): + def __init__(self,plugin): + self.plugin = plugin + + def challenge(self, src): + html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.script?k=%s" % src, cookies=True) + try: + ckey = re.search("ckey:.*?'(.*?)',",html).group(1) + html = self.plugin.req.load("http://api.solvemedia.com/papi/_challenge.js?k=%s" % ckey, cookies=True) + challenge = re.search('"chid".*?: "(.*?)"',html).group(1) + except: + self.plugin.fail("solvmedia error") + result = self.result(challenge) + + return challenge, result + + def result(self,challenge): + return self.plugin.decryptCaptcha("http://api.solvemedia.com/papi/media?c=%s" % challenge,imgtype="gif")
\ No newline at end of file diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py index 04353dcc8..e6dc621b0 100644 --- a/module/plugins/internal/MultiHoster.py +++ b/module/plugins/internal/MultiHoster.py @@ -11,19 +11,30 @@ class MultiHoster(Hook): Generic MultiHoster plugin """ - __version__ = "0.16" + __version__ = "0.17" - interval = 0 replacements = [("2shared.com", "twoshared.com"), ("4shared.com", "fourshared.com"), ("cloudnator.com", "shragle.com"), ("ifile.it", "filecloud.io"), ("easy-share.com","crocko.com"), ("freakshare.net","freakshare.com"), ("hellshare.com", "hellshare.cz"), ("share-rapid.cz","sharerapid.com"), ("sharerapid.cz","sharerapid.com"), - ("ul.to","uploaded.to"), ("uploaded.net","uploaded.to")] + ("ul.to","uploaded.to"), ("uploaded.net","uploaded.to"), ("1fichier.com", "onefichier.com")] ignored = [] + interval = 24 * 60 * 60 def setup(self): self.hosters = [] self.supported = [] self.new_supported = [] + + cfg_interval = self.getConfig("interval", None) # reload interval in hours + if cfg_interval is not None: + self.interval = cfg_interval * 60 * 60 + + def getConfig(self, option, default = ''): + """getConfig with default value - sublass may not implements all config options""" + try: + return self.getConf(option) + except KeyError: + return default def getHosterCached(self): if not self.hosters: @@ -35,9 +46,9 @@ class MultiHoster(Hook): return [] try: - configMode = self.getConfig('hosterListMode') + configMode = self.getConfig('hosterListMode', 'all') if configMode in ("listed", "unlisted"): - configSet = self.toHosterSet(self.getConfig('hosterList').replace('|',',').replace(';',',').split(',')) + configSet = self.toHosterSet(self.getConfig('hosterList', '').replace('|',',').replace(';',',').split(',')) if configMode == "listed": hosterSet &= configSet @@ -68,8 +79,28 @@ class MultiHoster(Hook): :return: List of domain names """ raise NotImplementedError - + def coreReady(self): + if not self.interval: + if self.cb: + self.core.scheduler.removeJob(self.cb) + self.overridePlugins() + + def periodical(self): + """reload hoster list periodically""" + self.logInfo("Reloading supported hoster list") + old_supported = self.supported + self.supported, self.new_supported, self.hosters = [], [], [] + + self.overridePlugins() + + old_supported = [hoster for hoster in old_supported if hoster not in self.supported] + if old_supported: + self.logDebug("UNLOAD", old_supported) + for hoster in old_supported: + self.unloadHoster(hoster) + + def overridePlugins(self): pluginMap = {} for name in self.core.pluginManager.hosterPlugins.keys(): pluginMap[name.lower()] = name @@ -95,8 +126,6 @@ class MultiHoster(Hook): module = self.core.pluginManager.getPlugin(self.__name__) klass = getattr(module, self.__name__) - print module, klass - # inject plugin plugin self.logDebug("Overwritten Hosters: %s" % ", ".join(sorted(self.supported))) for hoster in self.supported: @@ -111,17 +140,16 @@ class MultiHoster(Hook): self.logDebug("New Hosters: %s" % ", ".join(sorted(self.new_supported))) # create new regexp - if not klass.__pattern__: - regexp = r".*(%s).*" % "|".join([x.replace(".", "\\.") for x in new_supported]) - else: - regexp = r"%s|.*(%s).*" % (klass.__pattern__, "|".join([x.replace(".", "\\.") for x in self.new_supported])) + regexp = r".*(%s).*" % "|".join([x.replace(".", "\\.") for x in self.new_supported]) + if hasattr(klass, "__pattern__") and '://' in klass.__pattern__: + regexp = r"%s|%s" % (klass.__pattern__, regexp) + self.logDebug("Regexp: %s" % regexp) dict = self.core.pluginManager.hosterPlugins[self.__name__] dict["pattern"] = regexp dict["re"] = re.compile(regexp) - def unloadHoster(self, hoster): dict = self.core.pluginManager.hosterPlugins[hoster] if "module" in dict: @@ -132,14 +160,25 @@ class MultiHoster(Hook): del dict["new_name"] def unload(self): + """remove override for all hosters""" for hoster in self.supported: - self.unloadHoster(hoster) + self.unloadHoster(hoster) + + # reset pattern + klass = getattr(self.core.pluginManager.getPlugin(self.__name__), self.__name__) + dict = self.core.pluginManager.hosterPlugins[self.__name__] + dict["pattern"] = getattr(klass, '__pattern__', r"^unmatchable$") + dict["re"] = re.compile(dict["pattern"]) + + # remove scheduler job + if self.cb: + self.core.scheduler.removeJob(self.cb) def downloadFailed(self, pyfile): """remove plugin override if download fails but not if file is offline/temp.offline""" - if pyfile.hasStatus("failed"): + if pyfile.hasStatus("failed") and self.getConfig("unloadFailing", True): hdict = self.core.pluginManager.hosterPlugins[pyfile.pluginname] - self.logDebug("Unload MultiHoster", pyfile.pluginname, hdict) - if "new_name" in hdict and hdict['new_name'] == self.__name__: + if "new_name" in hdict and hdict['new_name'] == self.__name__: + self.logDebug("Unload MultiHoster", pyfile.pluginname, hdict) self.unloadHoster(pyfile.pluginname) pyfile.setStatus("queued")
\ No newline at end of file |