diff options
Diffstat (limited to 'module/plugins/hoster/UnibytesCom.py')
-rw-r--r-- | module/plugins/hoster/UnibytesCom.py | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/module/plugins/hoster/UnibytesCom.py b/module/plugins/hoster/UnibytesCom.py index cd4e506c4..d090c8e7d 100644 --- a/module/plugins/hoster/UnibytesCom.py +++ b/module/plugins/hoster/UnibytesCom.py @@ -1,10 +1,8 @@ # -*- coding: utf-8 -*- +import pycurl import re - -from urlparse import urljoin - -from pycurl import FOLLOWLOCATION +import urlparse from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo @@ -15,6 +13,7 @@ class UnibytesCom(SimpleHoster): __version__ = "0.12" __pattern__ = r'https?://(?:www\.)?unibytes\.com/[\w .-]{11}B' + __config__ = [("use_premium", "bool", "Use premium account if available", True)] __description__ = """UniBytes.com hoster plugin""" __license__ = "GPLv3" @@ -23,25 +22,25 @@ class UnibytesCom(SimpleHoster): HOSTER_DOMAIN = "unibytes.com" - INFO_PATTERN = r'<span[^>]*?id="fileName"[^>]*>(?P<N>[^>]+)</span>\s*\((?P<S>\d.*?)\)' + INFO_PATTERN = r'<span[^>]*?id="fileName".*?>(?P<N>[^>]+)</span>\s*\((?P<S>\d.*?)\)' WAIT_PATTERN = r'Wait for <span id="slowRest">(\d+)</span> sec' - LINK_FREE_PATTERN = r'<a href="([^"]+)">Download</a>' + LINK_FREE_PATTERN = r'<a href="(.+?)">Download</a>' def handleFree(self, pyfile): domain = "http://www.%s/" % self.HOSTER_DOMAIN action, post_data = self.parseHtmlForm('id="startForm"') - self.req.http.c.setopt(FOLLOWLOCATION, 0) + self.req.http.c.setopt(pycurl.FOLLOWLOCATION, 0) for _i in xrange(8): self.logDebug(action, post_data) - self.html = self.load(urljoin(domain, action), post=post_data) + self.html = self.load(urlparse.urljoin(domain, action), post=post_data) m = re.search(r'location:\s*(\S+)', self.req.http.header, re.I) if m: - url = m.group(1) + self.link = m.group(1) break if '>Somebody else is already downloading using your IP-address<' in self.html: @@ -51,7 +50,7 @@ class UnibytesCom(SimpleHoster): if post_data['step'] == 'last': m = re.search(self.LINK_FREE_PATTERN, self.html) if m: - url = m.group(1) + self.link = m.group(1) self.correctCaptcha() break else: @@ -62,17 +61,15 @@ class UnibytesCom(SimpleHoster): if last_step == 'timer': m = re.search(self.WAIT_PATTERN, self.html) - self.wait(int(m.group(1)) if m else 60, False) + self.wait(m.group(1) if m else 60, False) elif last_step in ("captcha", "last"): - post_data['captcha'] = self.decryptCaptcha(urljoin(domain, "/captcha.jpg")) + post_data['captcha'] = self.decryptCaptcha(urlparse.urljoin(domain, "/captcha.jpg")) else: self.fail(_("No valid captcha code entered")) - self.req.http.c.setopt(FOLLOWLOCATION, 1) - - self.download(url) + self.req.http.c.setopt(pycurl.FOLLOWLOCATION, 1) getInfo = create_getInfo(UnibytesCom) |