summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/UnibytesCom.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hoster/UnibytesCom.py')
-rw-r--r--module/plugins/hoster/UnibytesCom.py60
1 files changed, 28 insertions, 32 deletions
diff --git a/module/plugins/hoster/UnibytesCom.py b/module/plugins/hoster/UnibytesCom.py
index 50e4c32d0..16b1f82ab 100644
--- a/module/plugins/hoster/UnibytesCom.py
+++ b/module/plugins/hoster/UnibytesCom.py
@@ -1,49 +1,43 @@
# -*- 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.
+import re
- You should have received a copy of the GNU General Public License
- along with this program; if not, see <http://www.gnu.org/licenses/>.
-"""
+from urlparse import urljoin
-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"
+ __name__ = "UnibytesCom"
+ __type__ = "hoster"
+ __version__ = "0.12"
+
+ __pattern__ = r'https?://(?:www\.)?unibytes\.com/[\w .-]{11}B'
+
__description__ = """UniBytes.com hoster plugin"""
- __author_name__ = "zoidberg"
- __author_mail__ = "zoidberg@mujmail.cz"
+ __license__ = "GPLv3"
+ __authors__ = [("zoidberg", "zoidberg@mujmail.cz")]
- FILE_INFO_PATTERN = r'<span[^>]*?id="fileName"[^>]*>(?P<N>[^>]+)</span>\s*\((?P<S>\d.*?)\)'
- HOSTER_NAME = "unibytes.com"
+ HOSTER_DOMAIN = "unibytes.com"
+
+ 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_PATTERN = r'<a href="([^"]+)">Download</a>'
+ LINK_FREE_PATTERN = r'<a href="([^"]+)">Download</a>'
- def handleFree(self):
- domain = "http://www." + self.HOSTER_NAME
+ 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)
- for _ in xrange(8):
+ for _i in xrange(8):
self.logDebug(action, post_data)
- self.html = self.load(domain + action, post=post_data)
+ self.html = self.load(urljoin(domain, action), post=post_data)
m = re.search(r'location:\s*(\S+)', self.req.http.header, re.I)
if m:
@@ -55,7 +49,7 @@ class UnibytesCom(SimpleHoster):
self.retry()
if post_data['step'] == 'last':
- m = re.search(self.LINK_PATTERN, self.html)
+ m = re.search(self.LINK_FREE_PATTERN, self.html)
if m:
url = m.group(1)
self.correctCaptcha()
@@ -68,14 +62,16 @@ 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(domain + '/captcha.jpg')
+ post_data['captcha'] = self.decryptCaptcha(urljoin(domain, "/captcha.jpg"))
+
else:
- self.fail("No valid captcha code entered")
+ self.fail(_("No valid captcha code entered"))
- self.logDebug('Download link: ' + url)
self.req.http.c.setopt(FOLLOWLOCATION, 1)
+
self.download(url)