summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/DateiTo.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hoster/DateiTo.py')
-rw-r--r--module/plugins/hoster/DateiTo.py96
1 files changed, 41 insertions, 55 deletions
diff --git a/module/plugins/hoster/DateiTo.py b/module/plugins/hoster/DateiTo.py
index 223138592..e4bff8458 100644
--- a/module/plugins/hoster/DateiTo.py
+++ b/module/plugins/hoster/DateiTo.py
@@ -1,52 +1,39 @@
# -*- 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.internal.SimpleHoster import SimpleHoster, create_getInfo
+
from module.plugins.internal.CaptchaService import ReCaptcha
+from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
class DateiTo(SimpleHoster):
- __name__ = "DateiTo"
- __type__ = "hoster"
+ __name__ = "DateiTo"
+ __type__ = "hoster"
+ __version__ = "0.05"
+
__pattern__ = r'http://(?:www\.)?datei\.to/datei/(?P<ID>\w+)\.html'
- __version__ = "0.02"
+
__description__ = """Datei.to hoster plugin"""
- __author_name__ = "zoidberg"
- __author_mail__ = "zoidberg@mujmail.cz"
+ __license__ = "GPLv3"
+ __authors__ = [("zoidberg", "zoidberg@mujmail.cz")]
+
- FILE_NAME_PATTERN = r'Dateiname:</td>\s*<td colspan="2"><strong>(?P<N>.*?)</'
- FILE_SIZE_PATTERN = r'Dateigr&ouml;&szlig;e:</td>\s*<td colspan="2">(?P<S>.*?)</'
- FILE_OFFLINE_PATTERN = r'>Datei wurde nicht gefunden<|>Bitte wähle deine Datei aus... <'
- PARALELL_PATTERN = r'>Du lädst bereits eine Datei herunter<'
+ NAME_PATTERN = r'Dateiname:</td>\s*<td colspan="2"><strong>(?P<N>.*?)</'
+ SIZE_PATTERN = r'Dateigr&ouml;&szlig;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<'
- WAIT_PATTERN = r'countdown\({seconds: (\d+)'
DATA_PATTERN = r'url: "(.*?)", data: "(.*?)",'
- RECAPTCHA_KEY_PATTERN = r'Recaptcha.create\("(.*?)"'
+
def handleFree(self):
url = 'http://datei.to/ajax/download.php'
- data = {'P': 'I', 'ID': self.file_info['ID']}
-
+ data = {'P': 'I', 'ID': self.info['pattern']['ID']}
recaptcha = ReCaptcha(self)
- for _ in xrange(10):
+ for _i in xrange(10):
self.logDebug("URL", url, "POST", data)
self.html = self.load(url, post=data)
self.checkErrors()
@@ -58,39 +45,38 @@ class DateiTo(SimpleHoster):
elif data['P'] == 'IV':
break
- found = re.search(self.DATA_PATTERN, self.html)
- if not found:
- self.parseError('data')
- url = 'http://datei.to/' + found.group(1)
- data = dict(x.split('=') for x in found.group(2).split('&'))
+ 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'):
- found = re.search(self.RECAPTCHA_KEY_PATTERN, self.html)
- recaptcha_key = found.group(1) if found else "6LdBbL8SAAAAAI0vKUo58XRwDd5Tu_Ze1DA7qTao"
-
- data['recaptcha_challenge_field'], data['recaptcha_response_field'] = recaptcha.challenge(recaptcha_key)
-
+ data['recaptcha_challenge_field'], data['recaptcha_response_field'] = recaptcha.challenge()
else:
- self.fail('Too bad...')
+ self.fail(_("Too bad..."))
+
+ self.download(self.html)
- download_url = self.html
- self.logDebug('Download URL', download_url)
- self.download(download_url)
def checkErrors(self):
- found = re.search(self.PARALELL_PATTERN, self.html)
- if found:
- found = re.search(self.WAIT_PATTERN, self.html)
- wait_time = int(found.group(1)) if found else 30
- self.wait(wait_time + 1, False)
- self.retry()
+ 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):
- found = re.search(self.WAIT_PATTERN, self.html)
- wait_time = int(found.group(1)) if found else 30
+ 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 + 1, False)
+ self.wait(wait_time, False)
getInfo = create_getInfo(DateiTo)