diff options
Diffstat (limited to 'module/plugins/hoster/UnibytesCom.py')
-rw-r--r-- | module/plugins/hoster/UnibytesCom.py | 51 |
1 files changed, 20 insertions, 31 deletions
diff --git a/module/plugins/hoster/UnibytesCom.py b/module/plugins/hoster/UnibytesCom.py index 1a64146c4..e936b84b1 100644 --- a/module/plugins/hoster/UnibytesCom.py +++ b/module/plugins/hoster/UnibytesCom.py @@ -1,53 +1,42 @@ # -*- 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 pycurl import FOLLOWLOCATION + from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class UnibytesCom(SimpleHoster): __name__ = "UnibytesCom" __type__ = "hoster" - __pattern__ = r'http://(?:www\.)?unibytes\.com/[a-zA-Z0-9-._ ]{11}B' __version__ = "0.1" + + __pattern__ = r'http://(?:www\.)?unibytes\.com/[a-zA-Z0-9-._ ]{11}B' + __description__ = """UniBytes.com hoster plugin""" __author_name__ = "zoidberg" __author_mail__ = "zoidberg@mujmail.cz" FILE_INFO_PATTERN = r'<span[^>]*?id="fileName"[^>]*>(?P<N>[^>]+)</span>\s*\((?P<S>\d.*?)\)' - DOMAIN = 'http://www.unibytes.com' + HOSTER_NAME = "unibytes.com" WAIT_PATTERN = r'Wait for <span id="slowRest">(\d+)</span> sec' - DOWNLOAD_LINK_PATTERN = r'<a href="([^"]+)">Download</a>' + LINK_PATTERN = r'<a href="([^"]+)">Download</a>' + def handleFree(self): + domain = "http://www." + self.HOSTER_NAME action, post_data = self.parseHtmlForm('id="startForm"') self.req.http.c.setopt(FOLLOWLOCATION, 0) for _ in xrange(8): self.logDebug(action, post_data) - self.html = self.load(self.DOMAIN + action, post=post_data) + self.html = self.load(domain + action, post=post_data) - found = re.search(r'location:\s*(\S+)', self.req.http.header, re.I) - if found: - url = found.group(1) + m = re.search(r'location:\s*(\S+)', self.req.http.header, re.I) + if m: + url = m.group(1) break if '>Somebody else is already downloading using your IP-address<' in self.html: @@ -55,9 +44,9 @@ class UnibytesCom(SimpleHoster): self.retry() if post_data['step'] == 'last': - found = re.search(self.DOWNLOAD_LINK_PATTERN, self.html) - if found: - url = found.group(1) + m = re.search(self.LINK_PATTERN, self.html) + if m: + url = m.group(1) self.correctCaptcha() break else: @@ -67,10 +56,10 @@ class UnibytesCom(SimpleHoster): action, post_data = self.parseHtmlForm('id="stepForm"') if last_step == 'timer': - found = re.search(self.WAIT_PATTERN, self.html) - self.wait(int(found.group(1)) if found else 60, False) - elif last_step in ('captcha', 'last'): - post_data['captcha'] = self.decryptCaptcha(self.DOMAIN + '/captcha.jpg') + m = re.search(self.WAIT_PATTERN, self.html) + self.wait(int(m.group(1)) if m else 60, False) + elif last_step in ("captcha", "last"): + post_data['captcha'] = self.decryptCaptcha(domain + '/captcha.jpg') else: self.fail("No valid captcha code entered") |