diff options
author | Walter Purcaro <vuolter@gmail.com> | 2014-12-02 00:08:42 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2014-12-02 00:08:42 +0100 |
commit | 2a8d0af88b07e62eeb316a8dfbb7cd8d7dbfdcac (patch) | |
tree | 4324ec7c224724156ee9897e8689135f85e2e804 /module/plugins/hoster | |
parent | Merge pull request #920 from chris-19/stable (diff) | |
parent | [SimpleHoster] Force _isDirectLink to old style (diff) | |
download | pyload-2a8d0af88b07e62eeb316a8dfbb7cd8d7dbfdcac.tar.xz |
Merge branch 'stable-next' into stable
Diffstat (limited to 'module/plugins/hoster')
-rw-r--r-- | module/plugins/hoster/BasePlugin.py | 33 | ||||
-rw-r--r-- | module/plugins/hoster/DataHu.py | 7 | ||||
-rw-r--r-- | module/plugins/hoster/DateiTo.py | 4 | ||||
-rw-r--r-- | module/plugins/hoster/FastshareCz.py | 1 | ||||
-rw-r--r-- | module/plugins/hoster/FilecloudIo.py | 8 | ||||
-rw-r--r-- | module/plugins/hoster/FilepostCom.py | 11 | ||||
-rw-r--r-- | module/plugins/hoster/FilerNet.py | 1 | ||||
-rw-r--r-- | module/plugins/hoster/Keep2shareCc.py | 117 | ||||
-rw-r--r-- | module/plugins/hoster/KingfilesNet.py | 6 | ||||
-rw-r--r-- | module/plugins/hoster/LetitbitNet.py | 5 | ||||
-rw-r--r-- | module/plugins/hoster/LuckyShareNet.py | 7 | ||||
-rw-r--r-- | module/plugins/hoster/NowVideoAt.py | 4 | ||||
-rw-r--r-- | module/plugins/hoster/OneFichierCom.py | 4 | ||||
-rw-r--r-- | module/plugins/hoster/PromptfileCom.py | 5 | ||||
-rw-r--r-- | module/plugins/hoster/SafesharingEu.py | 25 | ||||
-rw-r--r-- | module/plugins/hoster/ShareonlineBiz.py | 184 | ||||
-rw-r--r-- | module/plugins/hoster/TurbobitNet.py | 6 | ||||
-rw-r--r-- | module/plugins/hoster/UploadingCom.py | 8 | ||||
-rw-r--r-- | module/plugins/hoster/WebshareCz.py | 7 | ||||
-rw-r--r-- | module/plugins/hoster/ZippyshareCom.py | 15 |
20 files changed, 215 insertions, 243 deletions
diff --git a/module/plugins/hoster/BasePlugin.py b/module/plugins/hoster/BasePlugin.py index 01a234d3b..0b1888e3b 100644 --- a/module/plugins/hoster/BasePlugin.py +++ b/module/plugins/hoster/BasePlugin.py @@ -3,7 +3,7 @@ import re from urllib import unquote -from urlparse import urlparse +from urlparse import urljoin, urlparse from module.network.HTTPRequest import BadHeader from module.plugins.internal.SimpleHoster import create_getInfo @@ -13,7 +13,7 @@ from module.plugins.Hoster import Hoster class BasePlugin(Hoster): __name__ = "BasePlugin" __type__ = "hoster" - __version__ = "0.24" + __version__ = "0.25" __pattern__ = r'^unmatchable$' @@ -25,7 +25,7 @@ class BasePlugin(Hoster): @classmethod def getInfo(cls, url="", html=""): #@TODO: Move to hoster class in 0.4.10 - return {'name': urlparse(url).path.split('/')[-1] or _("Unknown"), 'size': 0, 'status': 3 if url else 1, 'url': url or ""} + return {'name': urlparse(unquote(url)).path.split('/')[-1] or _("Unknown"), 'size': 0, 'status': 3 if url else 1, 'url': unquote(url) or ""} def setup(self): @@ -50,7 +50,7 @@ class BasePlugin(Hoster): self.offline() elif e.code in (401, 403): - self.logDebug("Auth required") + self.logDebug("Auth required", "Received HTTP status code: %d" % e.code) account = self.core.accountManager.getAccountPlugin('Http') servers = [x['login'] for x in account.getAllAccounts()] @@ -65,16 +65,16 @@ class BasePlugin(Hoster): self.req.addAuth(pwd.strip()) break else: - self.fail(_("Authorization required (username:password)")) + self.fail(_("Authorization required")) else: self.fail(e) else: break else: - self.fail(_("No file downloaded")) #@TODO: Move to hoster class (check if self.lastDownload) in 0.4.10 + self.fail(_("No file downloaded")) #@TODO: Move to hoster class in 0.4.10 - # if self.checkDownload({'empty': re.compile(r"^$")}) is "empty": - # self.fail(_("Empty file")) + if self.checkDownload({'empty': re.compile(r"^$")}) is "empty": #@TODO: Move to hoster in 0.4.10 + self.fail(_("Empty file")) def downloadFile(self, pyfile): @@ -85,7 +85,8 @@ class BasePlugin(Hoster): if 'location' not in header or not header['location']: if 'code' in header and header['code'] not in (200, 201, 203, 206): - self.fail(_("File not found"), _("HTTP status code: %d") % header['code']) + self.logDebug("Received HTTP status code: %d" % header['code']) + self.fail(_("File not found")) else: break @@ -93,17 +94,13 @@ class BasePlugin(Hoster): self.logDebug("Redirect #%d to: %s" % (i, location)) - base = re.match(r'https?://[^/]+', url).group(0) - - if location.startswith("http"): + if urlparse(location).scheme: url = location - - elif location.startswith("/"): - url = base + unquote(location) - else: - url = "%s/%s" % (base, unquote(location)) + p = urlparse(url) + base = "%s://%s" % (p.scheme, p.netloc) + url = urljoin(base, location) else: self.fail(_("Too many redirects")) - self.download(url, disposition=True) + self.download(unquote(url), disposition=True) diff --git a/module/plugins/hoster/DataHu.py b/module/plugins/hoster/DataHu.py index fd6a01135..74d631e7b 100644 --- a/module/plugins/hoster/DataHu.py +++ b/module/plugins/hoster/DataHu.py @@ -33,13 +33,10 @@ class DataHu(SimpleHoster): def handleFree(self): m = re.search(self.LINK_PATTERN, self.html) - if m: - url = m.group(1) - self.logDebug("Direct link: " + url) - else: + if m is None: self.error(_("LINK_PATTERN not found")) - self.download(url, disposition=True) + self.download(m.group(1), disposition=True) getInfo = create_getInfo(DataHu) diff --git a/module/plugins/hoster/DateiTo.py b/module/plugins/hoster/DateiTo.py index 9d51b5036..683c6b75d 100644 --- a/module/plugins/hoster/DateiTo.py +++ b/module/plugins/hoster/DateiTo.py @@ -9,7 +9,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class DateiTo(SimpleHoster): __name__ = "DateiTo" __type__ = "hoster" - __version__ = "0.04" + __version__ = "0.05" __pattern__ = r'http://(?:www\.)?datei\.to/datei/(?P<ID>\w+)\.html' @@ -29,7 +29,7 @@ class DateiTo(SimpleHoster): def handleFree(self): url = 'http://datei.to/ajax/download.php' - data = {'P': 'I', 'ID': self.info['ID']} + data = {'P': 'I', 'ID': self.info['pattern']['ID']} recaptcha = ReCaptcha(self) for _i in xrange(10): diff --git a/module/plugins/hoster/FastshareCz.py b/module/plugins/hoster/FastshareCz.py index 1467a0909..14931f681 100644 --- a/module/plugins/hoster/FastshareCz.py +++ b/module/plugins/hoster/FastshareCz.py @@ -75,7 +75,6 @@ class FastshareCz(SimpleHoster): else: self.error(_("PREMIUM_URL_PATTERN not found")) - self.logDebug("PREMIUM URL: " + url) self.download(url, disposition=True) check = self.checkDownload({"credit": re.compile(self.CREDIT_PATTERN)}) diff --git a/module/plugins/hoster/FilecloudIo.py b/module/plugins/hoster/FilecloudIo.py index 819a7faf3..85ea3dae4 100644 --- a/module/plugins/hoster/FilecloudIo.py +++ b/module/plugins/hoster/FilecloudIo.py @@ -10,7 +10,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class FilecloudIo(SimpleHoster): __name__ = "FilecloudIo" __type__ = "hoster" - __version__ = "0.04" + __version__ = "0.05" __pattern__ = r'http://(?:www\.)?(?:filecloud\.io|ifile\.it|mihd\.net)/(?P<ID>\w+).*' @@ -39,7 +39,7 @@ class FilecloudIo(SimpleHoster): def handleFree(self): - data = {"ukey": self.info['ID']} + data = {"ukey": self.info['pattern']['ID']} m = re.search(self.AB1_PATTERN, self.html) if m is None: @@ -94,7 +94,7 @@ class FilecloudIo(SimpleHoster): if res['dl']: self.html = self.load('http://filecloud.io/download.html') - m = re.search(self.LINK_PATTERN % self.info['ID'], self.html) + m = re.search(self.LINK_PATTERN % self.info['pattern']['ID'], self.html) if m is None: self.error(_("LINK_PATTERN not found")) @@ -109,7 +109,7 @@ class FilecloudIo(SimpleHoster): def handlePremium(self): akey = self.account.getAccountData(self.user)['akey'] - ukey = self.info['ID'] + ukey = self.info['pattern']['ID'] self.logDebug("Akey: %s | Ukey: %s" % (akey, ukey)) rep = self.load("http://api.filecloud.io/api-fetch_download_url.api", post={"akey": akey, "ukey": ukey}) diff --git a/module/plugins/hoster/FilepostCom.py b/module/plugins/hoster/FilepostCom.py index 314ad449c..db5ea20d3 100644 --- a/module/plugins/hoster/FilepostCom.py +++ b/module/plugins/hoster/FilepostCom.py @@ -12,9 +12,9 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class FilepostCom(SimpleHoster): __name__ = "FilepostCom" __type__ = "hoster" - __version__ = "0.29" + __version__ = "0.30" - __pattern__ = r'https?://(?:www\.)?(?:filepost\.com/files|fp\.io)/([^/]+).*' + __pattern__ = r'https?://(?:www\.)?(?:filepost\.com/files|fp\.io)/(?P<ID>[^/]+)' __description__ = """Filepost.com hoster plugin""" __license__ = "GPLv3" @@ -30,9 +30,6 @@ class FilepostCom(SimpleHoster): def handleFree(self): - # Find token and captcha key - file_id = re.match(self.__pattern__, self.pyfile.url).group(1) - m = re.search(self.FLP_TOKEN_PATTERN, self.html) if m is None: self.error(_("Token")) @@ -45,13 +42,13 @@ class FilepostCom(SimpleHoster): # Get wait time get_dict = {'SID': self.req.cj.getCookie('SID'), 'JsHttpRequest': str(int(time() * 10000)) + '-xml'} - post_dict = {'action': 'set_download', 'token': flp_token, 'code': file_id} + post_dict = {'action': 'set_download', 'token': flp_token, 'code': self.info['pattern']['ID']} wait_time = int(self.getJsonResponse(get_dict, post_dict, 'wait_time')) if wait_time > 0: self.wait(wait_time) - post_dict = {"token": flp_token, "code": file_id, "file_pass": ''} + post_dict = {"token": flp_token, "code": self.info['pattern']['ID'], "file_pass": ''} if 'var is_pass_exists = true;' in self.html: # Solve password diff --git a/module/plugins/hoster/FilerNet.py b/module/plugins/hoster/FilerNet.py index c91729730..3bfafc675 100644 --- a/module/plugins/hoster/FilerNet.py +++ b/module/plugins/hoster/FilerNet.py @@ -92,7 +92,6 @@ class FilerNet(SimpleHoster): self.error(_("LINK_PATTERN not found")) dl = 'http://filer.net' + m.group(1) - self.logDebug("Direct link: " + dl) self.download(dl, disposition=True) diff --git a/module/plugins/hoster/Keep2shareCc.py b/module/plugins/hoster/Keep2shareCc.py index fd8a5524d..7ca29701a 100644 --- a/module/plugins/hoster/Keep2shareCc.py +++ b/module/plugins/hoster/Keep2shareCc.py @@ -2,16 +2,16 @@ import re -from urlparse import urlparse, urljoin +from urlparse import urljoin, urlparse from module.plugins.internal.CaptchaService import ReCaptcha -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.SimpleHoster import _isDirectLink, SimpleHoster, create_getInfo class Keep2shareCc(SimpleHoster): __name__ = "Keep2shareCc" __type__ = "hoster" - __version__ = "0.15" + __version__ = "0.16" __pattern__ = r'https?://(?:www\.)?(keep2share|k2s|keep2s)\.cc/file/(?P<ID>\w+)' @@ -21,75 +21,98 @@ class Keep2shareCc(SimpleHoster): ("Walter Purcaro", "vuolter@gmail.com")] + URL_REPLACEMENTS = [(__pattern__ + ".*", "http://k2s.cc/file/\g<ID>")] + + CONTENT_DISPOSITION = True + NAME_PATTERN = r'File: <span>(?P<N>.+)</span>' SIZE_PATTERN = r'Size: (?P<S>[^<]+)</div>' - OFFLINE_PATTERN = r'File not found or deleted|Sorry, this file is blocked or deleted|Error 404' - LINK_PATTERN = r'To download this file with slow speed, use <a href="([^"]+)">this link</a>' + OFFLINE_PATTERN = r'File not found or deleted|Sorry, this file is blocked or deleted|Error 404' + TEMP_OFFLINE_PATTERN = r'Downloading blocked due to' + + LINK_FREE_PATTERN = LINK_PREMIUM_PATTERN = r'"([^"]+url.html?file=.+?)"|window\.location\.href = \'(.+?)\';' + CAPTCHA_PATTERN = r'src="(/file/captcha\.html.+?)"' - WAIT_PATTERN = r'Please wait ([\d:]+) to download this file' - MULTIDL_ERROR = r'Free account does not allow to download more than one file at the same time' + WAIT_PATTERN = r'Please wait ([\d:]+) to download this file' + TEMP_ERROR_PATTERN = r'>\s*(Download count files exceed|Traffic limit exceed|Free account does not allow to download more than one file at the same time)' + ERROR_PATTERN = r'>\s*(Free user can\'t download large files|You no can access to this file|This download available only for premium users|This is private file)' - def handleFree(self): - self.sanitize_url() - self.html = self.load(self.pyfile.url) - self.fid = re.search(r'<input type="hidden" name="slow_id" value="([^"]+)">', self.html).group(1) + def checkErrors(self): + m = re.search(self.TEMP_ERROR_PATTERN, self.html) + if m: + self.info['error'] = m.group(1) + self.wantReconnect = True + self.retry(wait_time=30 * 60, reason=m.group(0)) + + m = re.search(self.ERROR_PATTERN, self.html) + if m: + e = self.info['error'] = m.group(1) + self.error(e) + + m = re.search(self.WAIT_PATTERN, self.html) + if m: + self.logDebug("Hoster told us to wait for %s" % m.group(1)) + + # string to time convert courtesy of https://stackoverflow.com/questions/10663720 + ftr = [3600, 60, 1] + wait_time = sum([a * b for a, b in zip(ftr, map(int, m.group(1).split(':')))]) + + self.wantReconnect = True + self.retry(wait_time=wait_time, reason="Please wait to download this file") + + self.info.pop('error', None) + + + def handleFree(self): + self.fid = re.search(r'<input type="hidden" name="slow_id" value="([^"]+)">', self.html).group(1) self.html = self.load(self.pyfile.url, post={'yt0': '', 'slow_id': self.fid}) - if ">Downloading is not possible" in self.html: - self.fail("Free user can't download large files") + self.checkErrors() - m = re.search(r"function download\(\){.*window\.location\.href = '([^']+)';", self.html, re.S) - if m: # Direct mode - self.startDownload(m.group(1)) - else: + m = re.search(self.LINK_FREE_PATTERN, self.html) + + if m is None: self.handleCaptcha() self.wait(30) self.html = self.load(self.pyfile.url, post={'uniqueId': self.fid, 'free': 1}) - m = re.search(self.WAIT_PATTERN, self.html) - if m: - self.logDebug("Hoster told us to wait for %s" % m.group(1)) - # string to time convert courtesy of https://stackoverflow.com/questions/10663720 - ftr = [3600, 60, 1] - wait_time = sum([a * b for a, b in zip(ftr, map(int, m.group(1).split(':')))]) - self.wait(wait_time, True) - self.retry() - - m = re.search(self.MULTIDL_ERROR, self.html) - if m: - # if someone is already downloading on our line, wait 30min and retry - self.logDebug("Already downloading, waiting for 30 minutes") - self.wait(30 * 60, True) - self.retry() + self.checkErrors() - m = re.search(self.LINK_PATTERN, self.html) + m = re.search(self.LINK_FREE_PATTERN, self.html) if m is None: - self.error(_("LINK_PATTERN not found")) - self.startDownload(m.group(1)) + self.error(_("LINK_FREE_PATTERN not found")) + + self.link = self._getDownloadLink(m.group(1)) + + + def handlePremium(self): + super(Keep2shareCc, self).handlePremium() + if self.link: + self.link = self._getDownloadLink(self.link) def handleCaptcha(self): recaptcha = ReCaptcha(self) for _i in xrange(5): - post_data = {'free': 1, + post_data = {'free' : 1, 'freeDownloadRequest': 1, - 'uniqueId': self.fid, - 'yt0': ''} + 'uniqueId' : self.fid, + 'yt0' : ''} m = re.search(self.CAPTCHA_PATTERN, self.html) if m: - captcha_url = urljoin(self.base_url, m.group(1)) + captcha_url = urljoin(self.base, m.group(1)) post_data['CaptchaForm[code]'] = self.decryptCaptcha(captcha_url) else: challenge, response = recaptcha.challenge() post_data.update({'recaptcha_challenge_field': challenge, - 'recaptcha_response_field': response}) + 'recaptcha_response_field' : response}) self.html = self.load(self.pyfile.url, post=post_data) @@ -102,17 +125,11 @@ class Keep2shareCc(SimpleHoster): self.fail(_("All captcha attempts failed")) - def startDownload(self, url): - d = urljoin(self.base_url, url) - self.download(d, disposition=True) - - - def sanitize_url(self): - header = self.load(self.pyfile.url, just_header=True) - if 'location' in header: - self.pyfile.url = header['location'] + def _getDownloadLink(self, url): p = urlparse(self.pyfile.url) - self.base_url = "%s://%s" % (p.scheme, p.hostname) + base = "%s://%s" % (p.scheme, p.netloc) + link = _isDirectLink(self, url, self.premium) + return urljoin(base, link) if link else "" getInfo = create_getInfo(Keep2shareCc) diff --git a/module/plugins/hoster/KingfilesNet.py b/module/plugins/hoster/KingfilesNet.py index ce34da38f..202ab4a77 100644 --- a/module/plugins/hoster/KingfilesNet.py +++ b/module/plugins/hoster/KingfilesNet.py @@ -9,7 +9,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class KingfilesNet(SimpleHoster): __name__ = "KingfilesNet" __type__ = "hoster" - __version__ = "0.04" + __version__ = "0.05" __pattern__ = r'http://(?:www\.)?kingfiles\.net/(?P<ID>\w{12})' @@ -38,7 +38,7 @@ class KingfilesNet(SimpleHoster): # Click the free user button post_data = {'op': "download1", 'usr_login': "", - 'id': self.info['ID'], + 'id': self.info['pattern']['ID'], 'fname': self.pyfile.name, 'referer': "", 'method_free': "+"} @@ -57,7 +57,7 @@ class KingfilesNet(SimpleHoster): self.logDebug("rand = ", rand) post_data = {'op': "download2", - 'id': self.info['ID'], + 'id': self.info['pattern']['ID'], 'rand': rand, 'referer': self.pyfile.url, 'method_free': "+", diff --git a/module/plugins/hoster/LetitbitNet.py b/module/plugins/hoster/LetitbitNet.py index a1a812de4..ed8d4a39d 100644 --- a/module/plugins/hoster/LetitbitNet.py +++ b/module/plugins/hoster/LetitbitNet.py @@ -139,7 +139,4 @@ class LetitbitNet(SimpleHoster): if api_rep['status'] == 'FAIL': self.fail(api_rep['data']) - direct_link = api_rep['data'][0][0] - self.logDebug("Direct Link: " + direct_link) - - self.download(direct_link, disposition=True) + self.download(api_rep['data'][0][0], disposition=True) diff --git a/module/plugins/hoster/LuckyShareNet.py b/module/plugins/hoster/LuckyShareNet.py index aeab46d3d..2c33b57e7 100644 --- a/module/plugins/hoster/LuckyShareNet.py +++ b/module/plugins/hoster/LuckyShareNet.py @@ -11,7 +11,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class LuckyShareNet(SimpleHoster): __name__ = "LuckyShareNet" __type__ = "hoster" - __version__ = "0.03" + __version__ = "0.04" __pattern__ = r'https?://(?:www\.)?luckyshare\.net/(?P<ID>\d{10,})' @@ -42,9 +42,7 @@ class LuckyShareNet(SimpleHoster): # TODO: There should be a filesize limit for free downloads # TODO: Some files could not be downloaded in free mode def handleFree(self): - file_id = re.match(self.__pattern__, self.pyfile.url).group('ID') - self.logDebug("File ID: " + file_id) - rep = self.load(r"http://luckyshare.net/download/request/type/time/file/" + file_id, decode=True) + rep = self.load(r"http://luckyshare.net/download/request/type/time/file/" + self.info['pattern']['ID'], decode=True) self.logDebug("JSON: " + rep) json = self.parseJson(rep) @@ -69,7 +67,6 @@ class LuckyShareNet(SimpleHoster): if not json['link']: self.fail(_("No Download url retrieved/all captcha attempts failed")) - self.logDebug("Direct URL: " + json['link']) self.download(json['link']) diff --git a/module/plugins/hoster/NowVideoAt.py b/module/plugins/hoster/NowVideoAt.py index c0b49c6f4..3d9b706d3 100644 --- a/module/plugins/hoster/NowVideoAt.py +++ b/module/plugins/hoster/NowVideoAt.py @@ -8,7 +8,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class NowVideoAt(SimpleHoster): __name__ = "NowVideoAt" __type__ = "hoster" - __version__ = "0.06" + __version__ = "0.07" __pattern__ = r'http://(?:www\.)?nowvideo\.(at|ch|co|eu|sx)/(video|mobile/#/videos)/(?P<ID>\w+)' @@ -32,7 +32,7 @@ class NowVideoAt(SimpleHoster): def handleFree(self): - self.html = self.load("http://www.nowvideo.at/mobile/video.php", get={'id': self.info['ID']}) + self.html = self.load("http://www.nowvideo.at/mobile/video.php", get={'id': self.info['pattern']['ID']}) m = re.search(self.LINK_FREE_PATTERN, self.html) if m is None: diff --git a/module/plugins/hoster/OneFichierCom.py b/module/plugins/hoster/OneFichierCom.py index 7847a11e9..977d45b6f 100644 --- a/module/plugins/hoster/OneFichierCom.py +++ b/module/plugins/hoster/OneFichierCom.py @@ -8,7 +8,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class OneFichierCom(SimpleHoster): __name__ = "OneFichierCom" __type__ = "hoster" - __version__ = "0.73" + __version__ = "0.74" __pattern__ = r'https?://(?:www\.)?(?:(?P<ID1>\w+)\.)?(?P<HOST>1fichier\.com|alterupload\.com|cjoint\.net|d(es)?fichiers\.com|dl4free\.com|megadl\.fr|mesfichiers\.org|piecejointe\.net|pjointe\.com|tenvoi\.com)(?:/\?(?P<ID2>\w+))?' @@ -46,7 +46,7 @@ class OneFichierCom(SimpleHoster): self.wait(wait_time, reconnect) self.retry(reason="You have to wait been each free download") - id = self.info['ID1'] or self.info['ID2'] + id = self.info['pattern']['ID1'] or self.info['pattern']['ID2'] url, inputs = self.parseHtmlForm('action="https://1fichier.com/\?%s' % id) if not url: diff --git a/module/plugins/hoster/PromptfileCom.py b/module/plugins/hoster/PromptfileCom.py index 22fea09ea..af38c4e15 100644 --- a/module/plugins/hoster/PromptfileCom.py +++ b/module/plugins/hoster/PromptfileCom.py @@ -38,9 +38,8 @@ class PromptfileCom(SimpleHoster): m = re.search(self.LINK_PATTERN, self.html) if m is None: self.error(_("LINK_PATTERN not found")) - direct = m.group(1) - self.logDebug("Found direct link: " + direct) - self.download(direct, disposition=True) + + self.download(m.group(1), disposition=True) getInfo = create_getInfo(PromptfileCom) diff --git a/module/plugins/hoster/SafesharingEu.py b/module/plugins/hoster/SafesharingEu.py index 92a0ff932..f0936b9e8 100644 --- a/module/plugins/hoster/SafesharingEu.py +++ b/module/plugins/hoster/SafesharingEu.py @@ -4,31 +4,20 @@ from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo class SafesharingEu(XFSHoster): - __name__ = "SafesharingEu" - __type__ = "hoster" - __version__ = "0.04" + __name__ = "SafesharingEu" + __type__ = "hoster" + __version__ = "0.05" - __pattern__ = r'https?://(?:\w+\.)?safesharing.eu/\w+' + __pattern__ = r'https?://(?:www\.)?safesharing\.eu/\w{12}' __description__ = """Safesharing.eu hoster plugin""" - __license__ = "GPLv3" - __authors__ = [("zapp-brannigan", "fuerst.reinje@web.de")] + __license__ = "GPLv3" + __authors__ = [("zapp-brannigan", "fuerst.reinje@web.de")] - HOSTER_DOMAIN = "safesharing.eu" - - FILE_NAME_PATTERN = r'Filename:</b></td><td nowrap>(?P<N>.*)</td></tr>' - FILE_SIZE_PATTERN = r'Size:</b></td><td>(?P<S>.*) (?P<U>[kKmMbB]*) <small>' - - FILE_ID_PATTERN = r'<input type="hidden" name="id" value="(.*)">' - OFFLINE_PATTERN = r'<b>File Not Found</b>' - TEMP_OFFLINE_PATTERN = r'This server is in maintenance mode' + HOSTER_DOMAIN = "safesharing.eu" WAIT_PATTERN = r'You have to wait (\d+) minutes' - COUNTDOWN_PATTERN = r'<br><span id="countdown_str">Wait <span id=".*">(\d+)</span> seconds</span>' - - RECAPTCHA_KEY_PATTERN = r'<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge\?k=(.*)"></script>' - RANDOM_STRING_PATTERN = r'<input type="hidden" name="rand" value="(.*)">' ERROR_PATTERN = r'(?:<div class="alert alert-danger">)(.+?)(?:</div>)' diff --git a/module/plugins/hoster/ShareonlineBiz.py b/module/plugins/hoster/ShareonlineBiz.py index 78a27558b..91fc989c9 100644 --- a/module/plugins/hoster/ShareonlineBiz.py +++ b/module/plugins/hoster/ShareonlineBiz.py @@ -3,43 +3,18 @@ import re from time import time +from urllib import unquote +from urlparse import urlparse from module.network.RequestFactory import getURL -from module.plugins.Hoster import Hoster -from module.plugins.Plugin import chunks from module.plugins.internal.CaptchaService import ReCaptcha +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -def getInfo(urls): - api_url_base = "http://api.share-online.biz/linkcheck.php" - - urls = [url.replace("https://", "http://") for url in urls] - - for chunk in chunks(urls, 90): - api_param_file = {"links": "\n".join(x.replace("http://www.share-online.biz/dl/", "").rstrip("/") for x in - chunk)} # api only supports old style links - html = getURL(api_url_base, post=api_param_file, decode=True) - result = [] - for i, res in enumerate(html.split("\n")): - if not res: - continue - fields = res.split(";") - - if fields[1] == "OK": - status = 2 - elif fields[1] in ("DELETED", "NOT FOUND"): - status = 1 - else: - status = 3 - - result.append((fields[2], int(fields[3]), status, chunk[i])) - yield result - - -class ShareonlineBiz(Hoster): +class ShareonlineBiz(SimpleHoster): __name__ = "ShareonlineBiz" __type__ = "hoster" - __version__ = "0.41" + __version__ = "0.42" __pattern__ = r'https?://(?:www\.)?(share-online\.biz|egoshare\.com)/(download\.php\?id=|dl/)(?P<ID>\w+)' @@ -51,110 +26,118 @@ class ShareonlineBiz(Hoster): ("Walter Purcaro", "vuolter@gmail.com")] - ERROR_INFO_PATTERN = r'<p class="b">Information:</p>\s*<div>\s*<strong>(.*?)</strong>' + URL_REPLACEMENTS = [(__pattern__ + ".*", "http://www.share-online.biz/dl/\g<ID>")] + ERROR_INFO_PATTERN = r'<p class="b">Information:</p>\s*<div>\s*<strong>(.*?)</strong>' - def setup(self): - self.file_id = re.match(self.__pattern__, self.pyfile.url).group("ID") - self.pyfile.url = "http://www.share-online.biz/dl/" + self.file_id - self.resumeDownload = self.premium - self.multiDL = False + @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} - self.check_data = None + if url: + info.update(re.match(cls.__pattern__, url).groupdict()) + api_url = "http://api.share-online.biz/linkcheck.php?md5=1" + html = getURL(api_url, cookies=False, post={"links": self.info['pattern']['ID']}, decode=True) + field = html.split(";") - def process(self, pyfile): - if self.premium: - self.handlePremium() - else: - self.handleFree() + if field[1] is "OK": + info['fileid'] = field[0] + info['status'] = 2 + info['filename'] = field[2] + info['size'] = field[3] #: in bytes + info['md5'] = field[4].strip().lower().replace("\n\n", "") #: md5 - if self.api_data: - self.check_data = {"size": int(self.api_data['size']), "md5": self.api_data['md5']} + elif field[1] in ("DELETED", "NOT FOUND"): + info['status'] = 1 + return info - def loadAPIData(self): - api_url_base = "http://api.share-online.biz/linkcheck.php?md5=1" - api_param_file = {"links": self.file_id} #: api only supports old style links - html = self.load(api_url_base, cookies=False, post=api_param_file, decode=True) - - fields = html.split(";") - self.api_data = {"fileid": fields[0], - "status": fields[1]} - if not self.api_data['status'] == "OK": - self.offline() - else: - self.api_data['filename'] = fields[2] - self.api_data['size'] = fields[3] #: in bytes - self.api_data['md5'] = fields[4].strip().lower().replace("\n\n", "") #: md5 + def setup(self): + self.resumeDownload = self.premium + self.multiDL = False - def handleFree(self): - self.loadAPIData() - self.pyfile.name = self.api_data['filename'] - self.pyfile.size = int(self.api_data['size']) - - self.html = self.load(self.pyfile.url, cookies=True) #: refer, stuff - self.setWait(3) - self.wait() - - self.html = self.load("%s/free/" % self.pyfile.url, post={"dl_free": "1", "choice": "free"}, decode=True) - self.checkErrors() - - m = re.search(r'var wait=(\d+);', self.html) + def handleCaptcha(self): recaptcha = ReCaptcha(self) + for _i in xrange(5): - challenge, response = recaptcha.challenge("6LdatrsSAAAAAHZrB70txiV5p-8Iv8BtVxlTtjKX") + challenge, response = recaptcha.challenge() + + 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)), - post={'dl_free': '1', + post={'dl_free' : "1", 'recaptcha_challenge_field': challenge, - 'recaptcha_response_field': response}) - + 'recaptcha_response_field' : response}) if not res == '0': self.correctCaptcha() - break + return res else: self.invalidCaptcha() else: self.invalidCaptcha() self.fail(_("No valid captcha solution received")) + + def handleFree(self): + self.html = self.load(self.pyfile.url, cookies=True) #: refer, stuff + + self.wait(3) + + self.html = self.load("%s/free/" % self.pyfile.url, post={"dl_free": "1", "choice": "free"}, decode=True) + + self.checkErrors() + + res = self.handleCaptcha() + download_url = res.decode("base64") + if not download_url.startswith("http://"): self.error(_("Wrong download url")) self.wait() + self.download(download_url) + + def checkFile(self): # check download check = self.checkDownload({ - "cookie": re.compile(r'<div id="dl_failure"'), - "fail": re.compile(r"<title>Share-Online") + 'empty' : re.compile(r"^$"), + 'cookie': re.compile(r'<div id="dl_failure"'), + 'fail' : re.compile(r"<title>Share-Online") }) - if check == "cookie": + + if check == "empty": + self.fail(_("Empty file")) + + elif check == "cookie": self.invalidCaptcha() - self.retry(5, 60, "Cookie failure") + self.retry(5, 60, _("Cookie failure")) + elif check == "fail": self.invalidCaptcha() - self.retry(5, 5 * 60, "Download failed") - else: - self.correctCaptcha() + self.retry(5, 5 * 60, _("Download failed")) def handlePremium(self): #: should be working better loading (account) api internally self.account.getAccountInfo(self.user, True) + html = self.load("http://api.share-online.biz/account.php", {"username": self.user, "password": self.account.accounts[self.user]['password'], - "act": "download", "lid": self.file_id}) + "act": "download", "lid": self.info['fileid']}) self.api_data = dlinfo = {} + for line in html.splitlines(): key, value = line.split(": ") dlinfo[key.lower()] = value self.logDebug(dlinfo) + if not dlinfo['status'] == "online": self.offline() else: @@ -162,6 +145,7 @@ class ShareonlineBiz(Hoster): self.pyfile.size = int(dlinfo['size']) dlLink = dlinfo['url'] + if dlLink == "server_under_maintenance": self.tempOffline() else: @@ -174,23 +158,29 @@ class ShareonlineBiz(Hoster): if m is None: return - err = m.group(1) + errmsg = m.group(1).lower() + try: - self.logError(err, re.search(self.ERROR_INFO_PATTERN, self.html).group(1)) + self.logError(errmsg, re.search(self.ERROR_INFO_PATTERN, self.html).group(1)) except: - self.logError(err, "Unknown error occurred") + self.logError("Unknown error occurred", errmsg) - if err == "invalid": + if errmsg is "invalid": self.fail(_("File not available")) - elif err in ("freelimit", "size", "proxy"): + + elif errmsg in ("freelimit", "size", "proxy"): self.fail(_("Premium account needed")) + + elif errmsg in ("expired", "server"): + self.retry(wait_time=600, reason=errmsg) + + elif 'slot' in errmsg: + self.wantReconnect = True + self.retry(24, 3600, errmsg) + else: - if err in 'server': - self.setWait(600, False) - elif err in 'expired': - self.setWait(30, False) - else: - self.setWait(300, True) + self.wantReconnect = True + self.retry(wait_time=60, reason=errmsg) + - self.wait() - self.retry(max_tries=25, reason=err) +getInfo = create_getInfo(ShareonlineBiz) diff --git a/module/plugins/hoster/TurbobitNet.py b/module/plugins/hoster/TurbobitNet.py index 7426ea35c..9d7dcc67b 100644 --- a/module/plugins/hoster/TurbobitNet.py +++ b/module/plugins/hoster/TurbobitNet.py @@ -17,7 +17,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, t class TurbobitNet(SimpleHoster): __name__ = "TurbobitNet" __type__ = "hoster" - __version__ = "0.15" + __version__ = "0.16" __pattern__ = r'http://(?:www\.)?turbobit\.net/(?:download/free/)?(?P<ID>\w+)' @@ -42,7 +42,7 @@ class TurbobitNet(SimpleHoster): def handleFree(self): - self.url = "http://turbobit.net/download/free/%s" % self.info['ID'] + self.url = "http://turbobit.net/download/free/%s" % self.info['pattern']['ID'] self.html = self.load(self.url, ref=True, decode=True) rtUpdate = self.getRtUpdate() @@ -130,7 +130,7 @@ class TurbobitNet(SimpleHoster): for b in [1, 3]: self.jscode = "var id = \'%s\';var b = %d;var inn = \'%s\';%sout" % ( - self.info['ID'], b, quote(fun), rtUpdate) + self.info['pattern']['ID'], b, quote(fun), rtUpdate) try: out = self.js.eval(self.jscode) diff --git a/module/plugins/hoster/UploadingCom.py b/module/plugins/hoster/UploadingCom.py index 2b11e3bf4..b163f2252 100644 --- a/module/plugins/hoster/UploadingCom.py +++ b/module/plugins/hoster/UploadingCom.py @@ -11,7 +11,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, t class UploadingCom(SimpleHoster): __name__ = "UploadingCom" __type__ = "hoster" - __version__ = "0.38" + __version__ = "0.39" __pattern__ = r'http://(?:www\.)?uploading\.com/files/(?:get/)?(?P<ID>\w+)' @@ -47,7 +47,7 @@ class UploadingCom(SimpleHoster): def handlePremium(self): postData = {'action': 'get_link', - 'code': self.info['ID'], + 'code': self.info['pattern']['ID'], 'pass': 'undefined'} self.html = self.load('http://uploading.com/files/get/?JsHttpRequest=%d-xml' % timestamp(), post=postData) @@ -70,7 +70,7 @@ class UploadingCom(SimpleHoster): self.req.http.c.setopt(HTTPHEADER, ["X-Requested-With: XMLHttpRequest"]) self.req.http.lastURL = self.pyfile.url - res = json_loads(self.load(ajax_url, post={'action': 'second_page', 'code': self.info['ID']})) + res = json_loads(self.load(ajax_url, post={'action': 'second_page', 'code': self.info['pattern']['ID']})) if 'answer' in res and 'wait_time' in res['answer']: wait_time = int(res['answer']['wait_time']) @@ -79,7 +79,7 @@ class UploadingCom(SimpleHoster): else: self.error(_("No AJAX/WAIT")) - res = json_loads(self.load(ajax_url, post={'action': 'get_link', 'code': self.info['ID'], 'pass': 'false'})) + res = json_loads(self.load(ajax_url, post={'action': 'get_link', 'code': self.info['pattern']['ID'], 'pass': 'false'})) if 'answer' in res and 'link' in res['answer']: url = res['answer']['link'] diff --git a/module/plugins/hoster/WebshareCz.py b/module/plugins/hoster/WebshareCz.py index cd43de2bb..17aaff37c 100644 --- a/module/plugins/hoster/WebshareCz.py +++ b/module/plugins/hoster/WebshareCz.py @@ -35,13 +35,14 @@ class WebshareCz(SimpleHoster): def handleFree(self): api_data = self.load('https://webshare.cz/api/file_link/', post={'ident': self.fid}) + self.logDebug("API data: " + api_data) + m = re.search('<link>(.+)</link>', api_data) if m is None: self.error(_("Unable to detect direct link")) - direct = m.group(1) - self.logDebug("Direct link: " + direct) - self.download(direct, disposition=True) + + self.download(m.group(1), disposition=True) def getFileInfo(self): diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index 8bf5aa942..3edf3c5c1 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -2,8 +2,7 @@ import re -from os import path -from urllib import unquote +from os.path import join from urlparse import urljoin from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo @@ -12,7 +11,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" __type__ = "hoster" - __version__ = "0.60" + __version__ = "0.62" __pattern__ = r'(?P<HOST>http://www\d{0,2}\.zippyshare\.com)/v(?:/|iew\.jsp.*key=)(?P<KEY>\d+)' @@ -40,12 +39,6 @@ class ZippyshareCom(SimpleHoster): self.download(url) - def getFileInfo(self): - info = super(ZippyshareCom, self).getFileInfo() - self.pyfile.name = info['name'] = unquote(info['name']) - return info - - def get_checksum(self): try: m = re.search(r'\+[ ]*\((\d+)[ ]*\%[ ]*(\d+)[ ]*\+[ ]*(\d+)[ ]*\%[ ]*(\d+)\)[ ]*\+', self.html) @@ -64,8 +57,8 @@ class ZippyshareCom(SimpleHoster): def get_link(self): checksum = self.get_checksum() - p_url = path.join("d", self.info['KEY'], str(checksum), self.pyfile.name) - dl_link = urljoin(self.info['HOST'], p_url) + p_url = join("d", self.info['pattern']['KEY'], str(checksum), self.pyfile.name) + dl_link = urljoin(self.info['pattern']['HOST'], p_url) return dl_link |