diff options
Diffstat (limited to 'pyload/plugin/hoster/DateiTo.py')
-rw-r--r-- | pyload/plugin/hoster/DateiTo.py | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/pyload/plugin/hoster/DateiTo.py b/pyload/plugin/hoster/DateiTo.py new file mode 100644 index 000000000..216a758c8 --- /dev/null +++ b/pyload/plugin/hoster/DateiTo.py @@ -0,0 +1,79 @@ +# -*- coding: utf-8 -*- + +import re + +from pyload.plugin.internal.captcha import ReCaptcha +from pyload.plugin.internal.SimpleHoster import SimpleHoster + + +class DateiTo(SimpleHoster): + __name__ = "DateiTo" + __type__ = "hoster" + __version__ = "0.07" + + __pattern__ = r'http://(?:www\.)?datei\.to/datei/(?P<ID>\w+)\.html' + + __description__ = """Datei.to hoster plugin""" + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + + + NAME_PATTERN = r'Dateiname:</td>\s*<td colspan="2"><strong>(?P<N>.*?)</' + SIZE_PATTERN = r'Dateigröße:</td>\s*<td colspan="2">(?P<S>.*?)</' + OFFLINE_PATTERN = r'>Datei wurde nicht gefunden<|>Bitte wähle deine Datei aus... <' + + WAIT_PATTERN = r'countdown\({seconds: (\d+)' + MULTIDL_PATTERN = r'>Du lädst bereits eine Datei herunter<' + + DATA_PATTERN = r'url: "(.*?)", data: "(.*?)",' + + + def handleFree(self, pyfile): + url = 'http://datei.to/ajax/download.php' + data = {'P': 'I', 'ID': self.info['pattern']['ID']} + recaptcha = ReCaptcha(self) + + for _i in xrange(10): + self.logDebug("URL", url, "POST", data) + self.html = self.load(url, post=data) + self.checkErrors() + + if url.endswith('download.php') and 'P' in data: + if data['P'] == 'I': + self.doWait() + + elif data['P'] == 'IV': + break + + m = re.search(self.DATA_PATTERN, self.html) + if m is None: + self.error(_("data")) + url = 'http://datei.to/' + m.group(1) + data = dict(x.split('=') for x in m.group(2).split('&')) + + if url.endswith('recaptcha.php'): + data['recaptcha_response_field'], data['recaptcha_challenge_field'] = recaptcha.challenge() + else: + self.fail(_("Too bad...")) + + self.download(self.html) + + + def checkErrors(self): + m = re.search(self.MULTIDL_PATTERN, self.html) + if m: + m = re.search(self.WAIT_PATTERN, self.html) + wait_time = int(m.group(1)) if m else 30 + + errmsg = self.info['error'] = _("Parallel downloads") + self.retry(wait_time=wait_time, reason=errmsg) + + self.info.pop('error', None) + + + def doWait(self): + m = re.search(self.WAIT_PATTERN, self.html) + wait_time = int(m.group(1)) if m else 30 + + self.load('http://datei.to/ajax/download.php', post={'P': 'Ads'}) + self.wait(wait_time, False) |