summaryrefslogtreecommitdiffstats
path: root/module/plugins/crypter/ShareLinksBiz.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/crypter/ShareLinksBiz.py')
-rw-r--r--module/plugins/crypter/ShareLinksBiz.py39
1 files changed, 27 insertions, 12 deletions
diff --git a/module/plugins/crypter/ShareLinksBiz.py b/module/plugins/crypter/ShareLinksBiz.py
index 6fbe59b38..e372d7c6a 100644
--- a/module/plugins/crypter/ShareLinksBiz.py
+++ b/module/plugins/crypter/ShareLinksBiz.py
@@ -10,7 +10,7 @@ from module.plugins.internal.Crypter import Crypter
class ShareLinksBiz(Crypter):
__name__ = "ShareLinksBiz"
__type__ = "crypter"
- __version__ = "1.16"
+ __version__ = "1.18"
__status__ = "testing"
__pattern__ = r'http://(?:www\.)?(share-links|s2l)\.biz/(?P<ID>_?\w+)'
@@ -66,10 +66,18 @@ class ShareLinksBiz(Crypter):
def init_file(self, pyfile):
url = pyfile.url
+
if 's2l.biz' in url:
url = self.load(url, just_header=True)['location']
- self.base_url = "http://www.%s.biz" % re.match(self.__pattern__, url).group(1)
- self.file_id = re.match(self.__pattern__, url).group('ID')
+
+ if re.match(self.__pattern__, url):
+ self.base_url = "http://www.%s.biz" % re.match(self.__pattern__, url).group(1)
+ self.file_id = re.match(self.__pattern__, url).group('ID')
+
+ else:
+ self.log_debug("Could not initialize, URL [%s] does not match pattern [%s]" % (url, self.__pattern__))
+ self.fail(_("Unsupported download link"))
+
self.package = pyfile.package()
@@ -77,7 +85,8 @@ class ShareLinksBiz(Crypter):
if "No usable content was found" in self.html:
self.log_debug("File not found")
return False
- return True
+ else:
+ return True
def is_password_protected(self):
@@ -114,7 +123,11 @@ class ShareLinksBiz(Crypter):
self.log_debug("Captcha map with [%d] positions" % len(captchaMap.keys()))
#: Request user for captcha coords
- m = re.search(r'<img src="/captcha.gif\?d=(.*?)&amp;PHPSESSID=(.*?)&amp;legend=1"', self.html)
+ m = re.search(r'<img src="/captcha.gif\?d=(.+?)&PHPSESSID=(.+?)&legend=1"', self.html)
+ if not m:
+ self.log_debug("Captcha url data not found, maybe plugin out of date?")
+ self.fail(_("Captcha url data not found"))
+
captchaUrl = self.base_url + '/captcha.gif?d=%s&PHPSESSID=%s' % (m.group(1), m.group(2))
self.log_debug("Waiting user for correct position")
coords = self.captcha.decrypt(captchaUrl, input_type="gif", output_type='positional')
@@ -123,8 +136,8 @@ class ShareLinksBiz(Crypter):
#: Resolve captcha
href = self._resolve_coords(coords, captchaMap)
if href is None:
- self.captcha.invalid()
- self.retry(wait_time=5)
+ self.retry_captcha(wait=5)
+
url = self.base_url + href
self.html = self.load(url)
@@ -148,13 +161,11 @@ class ShareLinksBiz(Crypter):
def handle_errors(self):
if "The inserted password was wrong" in self.html:
- self.log_debug("Incorrect password, please set right password on 'Edit package' form and retry")
- self.fail(_("Incorrect password, please set right password on 'Edit package' form and retry"))
+ self.fail(_("Wrong password"))
if self.captcha:
if "Your choice was wrong" in self.html:
- self.captcha.invalid()
- self.retry(wait_time=5)
+ self.retry_captcha(wait=5)
else:
self.captcha.correct()
@@ -165,7 +176,7 @@ class ShareLinksBiz(Crypter):
#: Extract from web package header
title_re = r'<h2><img.*?/>(.*)</h2>'
m = re.search(title_re, self.html, re.S)
- if m:
+ if m is not None:
title = m.group(1).strip()
if 'unnamed' not in title:
name = folder = title
@@ -209,8 +220,10 @@ class ShareLinksBiz(Crypter):
self.log_debug("JsEngine returns value [%s] for redirection link" % dlLink)
package_links.append(dlLink)
+
except Exception, detail:
self.log_debug("Error decrypting Web link [%s], %s" % (ID, detail))
+
return package_links
@@ -235,8 +248,10 @@ class ShareLinksBiz(Crypter):
try:
(crypted, jk) = self._get_cipher_params()
package_links.extend(self._get_links(crypted, jk))
+
except Exception:
self.fail(_("Unable to decrypt CNL2 links"))
+
return package_links