diff options
author | zoidberg10 <zoidberg@mujmail.cz> | 2011-11-23 12:20:54 +0100 |
---|---|---|
committer | zoidberg10 <zoidberg@mujmail.cz> | 2011-11-23 12:20:54 +0100 |
commit | ca42a34b0803ca58a68b79ae58fddc0905c5d73a (patch) | |
tree | 63f3cb6c695acf51a6972d1337345757489bb339 /module/plugins/hoster | |
parent | add 2shared.com (diff) | |
download | pyload-ca42a34b0803ca58a68b79ae58fddc0905c5d73a.tar.xz |
fix 4shared, replace easy-share with crocko
Diffstat (limited to 'module/plugins/hoster')
-rw-r--r-- | module/plugins/hoster/CrockoCom.py | 70 | ||||
-rw-r--r-- | module/plugins/hoster/EasyShareCom.py | 72 | ||||
-rw-r--r-- | module/plugins/hoster/FourSharedCom.py | 40 |
3 files changed, 83 insertions, 99 deletions
diff --git a/module/plugins/hoster/CrockoCom.py b/module/plugins/hoster/CrockoCom.py new file mode 100644 index 000000000..7eafa67ed --- /dev/null +++ b/module/plugins/hoster/CrockoCom.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.ReCaptcha import ReCaptcha +import re + +class CrockoCom(SimpleHoster): + __name__ = "CrockoCom" + __type__ = "hoster" + __pattern__ = r"http://(www\.)?(crocko|easy-share).com/.*" + __version__ = "0.10" + __description__ = """Crocko Download Hoster""" + __author_name__ = ("zoidberg") + __author_mail__ = ("zoidberg@mujmail.cz") + + FILE_INFO_PATTERN = r'<strong>(?P<N>.*)\s*<span class="tip1"><span class="inner">(?P<S>[0-9,.]+) (?P<U>[kKMG])i?B</span></span>' + FILE_OFFLINE_PATTERN = r"<h1>Sorry,<br />the page you're looking for <br />isn't here.</h1>" + DOWNLOAD_URL_PATTERN = r"window.location ='([^']+)';" + CAPTCHA_URL_PATTERN = re.compile(r"u='(/file_contents/captcha/\w+)';\s*w='(\d+)';") + CAPTCHA_KEY_PATTERN = re.compile(r'Recaptcha.create\("([^"]+)"') + + FORM_PATTERN = r'<form method="post" action="([^"]+)">(.*?)</form>' + FORM_INPUT_PATTERN = r'<input[^>]* name="?([^" ]+)"? value="?([^" ]+)"?[^>]*>' + + NAME_REPLACEMENTS = [(r'<[^>]*>', '')] + + def handleFree(self): + if "You need Premium membership to download this file." in self.html: + self.fail("You need Premium membership to download this file.") + + url = False + for i in range(5): + found = re.search(self.CAPTCHA_URL_PATTERN, self.html) + if found: + url, wait_time = 'http://crocko.com' + found.group(1), found.group(2) + self.setWait(wait_time) + self.wait() + self.html = self.load(url) + else: + break + + found = re.search(self.CAPTCHA_KEY_PATTERN, self.html) + if not found: self.parseError('Captcha KEY') + captcha_key = found.group(1) + + found = re.search(self.FORM_PATTERN, self.html, re.DOTALL) + if not found: self.parseError('ACTION') + action, form = found.groups() + inputs = dict(re.findall(self.FORM_INPUT_PATTERN, form)) + + recaptcha = ReCaptcha(self) + + for i in range(5): + inputs['recaptcha_challenge_field'], inputs['recaptcha_response_field'] = recaptcha.challenge(captcha_key) + self.download(action, post = inputs) + + check = self.checkDownload({ + "captcha_err": self.CAPTCHA_KEY_PATTERN + }) + + if check == "captcha_err": + self.invalidCaptcha() + else: + break + else: + self.fail('No valid captcha solution received') + +getInfo = create_getInfo(CrockoCom) +
\ No newline at end of file diff --git a/module/plugins/hoster/EasyShareCom.py b/module/plugins/hoster/EasyShareCom.py deleted file mode 100644 index 542b4367f..000000000 --- a/module/plugins/hoster/EasyShareCom.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-import re
-from module.plugins.Hoster import Hoster
-from module.plugins.ReCaptcha import ReCaptcha
-
-class EasyShareCom(Hoster):
- __name__ = "EasyShareCom"
- __type__ = "hoster"
- __pattern__ = r"http://[\w\d\.]*?easy-share\.com/(\d{6}).*"
- __version__ = "0.1"
- __description__ = """easy-share.com One-Klick Hoster"""
- __author_name__ = ("jeix")
- __author_mail__ = ("jeix@hasnomail.de")
-
-
- def setup(self):
- self.multiDL = False
- self.html = None
-
- def process(self, pyfile):
- self.pyfile = pyfile
-
- self.html = self.load(self.pyfile.url)
- if re.search("Die von ihnen angeforderte Datei wurde gel\xc3\xb6scht.", self.html):
- self.offline()
-
- self.pyfile.name = self.getFileName()
-
- self.download(self.getFileUrl())
-
-
- def getFileName(self):
- return re.search(r'requesting:</span>\s*(.*?)<', self.html).group(1)
-
-
- def getFileUrl(self):
-
- if "There is another download in progress from your IP" in self.html:
- self.log.info("%s: IP blocked, retry in 5 minutes." % self.__name__)
- self.setWait(5 * 60)
- self.wait()
- self.retry()
-
- if "You need a premium membership to download this file" in self.html:
- self.fail("You need a premium membership to download this file.")
-
-
- wait = re.search(r"w='(\d+)'", self.html)
- if wait:
- wait = int( wait.group(1).strip() )
- self.log.info("%s: Waiting %d seconds." % (self.__name__, wait))
- self.setWait(wait)
- self.wait()
-
- tempurl = self.pyfile.url
- if not tempurl.endswith("/"):
- tempurl += "/"
- id = re.search(r'http://[\w\d\.]*?easy-share\.com/(\d+)/', tempurl).group(1)
- self.html = self.load("http://www.easy-share.com/file_contents/captcha/" + id)
-
- challenge = re.search(r'Recaptcha\.create\("(.*?)"', self.html).group(1)
- re_captcha = ReCaptcha(self)
- challenge, result = re_captcha.challenge(challenge)
-
- link = re.search(r'<form\s+method="post"\s+action="(http://[\w\d\.]*?easy-share.com/file_contents/.*?)">', self.html).group(1)
- id = re.search(r'file/id/(\d+)/', link)
- self.download( link, post={"id" : id,
- "recaptcha_challenge_field" : challenge,
- "recaptcha_response_field": result} )
-
diff --git a/module/plugins/hoster/FourSharedCom.py b/module/plugins/hoster/FourSharedCom.py index 4680088d9..5d10204a7 100644 --- a/module/plugins/hoster/FourSharedCom.py +++ b/module/plugins/hoster/FourSharedCom.py @@ -1,26 +1,14 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo -from module.network.RequestFactory import getURL +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo import re -def getInfo(urls): - result = [] - - for url in urls: - name, size, status, url = parseFileInfo(FourSharedCom, url, getURL(url, decode=True)) - if status == 2: - name = re.sub(r"&#(\d+).", lambda m: unichr(int(m.group(1))), name) - result.append(name, size, status, url) - - yield result - class FourSharedCom(SimpleHoster): __name__ = "FourSharedCom" __type__ = "hoster" __pattern__ = r"http://[\w\.]*?4shared(-china)?\.com/(account/)?(download|get|file|document|photo|video|audio)/.+?/.*" - __version__ = "0.22" + __version__ = "0.23" __description__ = """4Shared Download Hoster""" __author_name__ = ("jeix", "zoidberg") __author_mail__ = ("jeix@hasnomail.de", "zoidberg@mujmail.cz") @@ -28,28 +16,26 @@ class FourSharedCom(SimpleHoster): FILE_NAME_PATTERN = '<meta name="title" content="(?P<N>[^"]+)" />' FILE_SIZE_PATTERN = '<span title="Size: (?P<S>[0-9,.]+) (?P<U>[kKMG])i?B">' FILE_OFFLINE_PATTERN = 'The file link that you requested is not valid\.|This file was deleted.' - FREE_LINK_PATTERN = '<a href="([^"]+)" class="dbtn"' + DOWNLOAD_BUTTON_PATTERN = '<a href="([^"]+)"\s*class="dbtn' DOWNLOAD_URL_PATTERN = "<div class=\"(?:dl|xxlarge bold)\">\s*<a href='([^']+)'" - - def process(self, pyfile): - self.html = self.load(pyfile.url, decode=True) - self.getFileInfo() - pyfile.name = re.sub(r"&#(\d+).", lambda m: unichr(int(m.group(1))), pyfile.name) - self.handleFree() + + NAME_REPLACEMENTS = [(r"&#(\d+).", lambda m: unichr(int(m.group(1))))] def handleFree(self): - found = re.search(self.FREE_LINK_PATTERN, self.html) - if not found: raise PluginParseError('Free download button') - link = found.group(1) - + found = re.search(self.DOWNLOAD_BUTTON_PATTERN, self.html) + if found: + link = found.group(1) + else: + link = re.sub(r'/(download|get|file|document|photo|video|audio)/', r'/get/', self.pyfile.url) + self.html = self.load(link) found = re.search(self.DOWNLOAD_URL_PATTERN, self.html) - if not found: raise PluginParseError('Download link') + if not found: self.parseError('Download link') link = found.group(1) self.setWait(20) self.wait() self.download(link) -
\ No newline at end of file +getInfo = create_getInfo(FourSharedCom)
\ No newline at end of file |