From 40cbbfb334c83f61f26b9ec0f4487347754ca7a9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 27 Dec 2014 21:11:12 +0100 Subject: [ZippyshareCom] Fix get_checksum routine --- module/plugins/hoster/ZippyshareCom.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'module/plugins/hoster/ZippyshareCom.py') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index 67b384c5f..b8ad9b6cb 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -10,7 +10,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" __type__ = "hoster" - __version__ = "0.63" + __version__ = "0.64" __pattern__ = r'(?Phttp://www\d{0,2}\.zippyshare\.com)/v(?:/|iew\.jsp.*key=)(?P\d+)' @@ -43,15 +43,16 @@ class ZippyshareCom(SimpleHoster): m = re.search(r'\+[ ]*\((\d+)[ ]*\%[ ]*(\d+)[ ]*\+[ ]*(\d+)[ ]*\%[ ]*(\d+)\)[ ]*\+', self.html) if m: a1, a2, c1, c2 = map(int, m.groups()) + res = (a1 % a2) + (c1 % c2) else: a1, a2 = map(int, re.search(r'\(\'downloadB\'\).omg = (\d+)%(\d+)', self.html).groups()) c1, c2 = map(int, re.search(r'\(\'downloadB\'\).omg\) \* \((\d+)%(\d+)', self.html).groups()) - - b = (a1 % a2) * (c1 % c2) + b = (a1 % a2) * (c1 % c2) + res += 18 except: self.error(_("Unable to calculate checksum")) else: - return b + 18 + return res def get_link(self): -- cgit v1.2.3 From f6ff07af7da9abcb5af541d186572ca4539662e3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 28 Dec 2014 02:35:39 +0100 Subject: [ZippyshareCom] Typo --- module/plugins/hoster/ZippyshareCom.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'module/plugins/hoster/ZippyshareCom.py') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index b8ad9b6cb..73dd1f22d 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -10,7 +10,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" __type__ = "hoster" - __version__ = "0.64" + __version__ = "0.65" __pattern__ = r'(?Phttp://www\d{0,2}\.zippyshare\.com)/v(?:/|iew\.jsp.*key=)(?P\d+)' @@ -28,8 +28,8 @@ class ZippyshareCom(SimpleHoster): def setup(self): - self.multiDL = True - self.chunkLimit = -1 + self.multiDL = True + self.chunkLimit = -1 self.resumeDownload = True @@ -43,16 +43,17 @@ class ZippyshareCom(SimpleHoster): m = re.search(r'\+[ ]*\((\d+)[ ]*\%[ ]*(\d+)[ ]*\+[ ]*(\d+)[ ]*\%[ ]*(\d+)\)[ ]*\+', self.html) if m: a1, a2, c1, c2 = map(int, m.groups()) - res = (a1 % a2) + (c1 % c2) + b = (a1 % a2) + (c1 % c2) else: - a1, a2 = map(int, re.search(r'\(\'downloadB\'\).omg = (\d+)%(\d+)', self.html).groups()) + a1, a2 = map(int, re.search(r'\(\'downloadB\'\).omg = (\d+)%(\d+)' , self.html).groups()) c1, c2 = map(int, re.search(r'\(\'downloadB\'\).omg\) \* \((\d+)%(\d+)', self.html).groups()) - b = (a1 % a2) * (c1 % c2) - res += 18 - except: - self.error(_("Unable to calculate checksum")) + b = (a1 % a2) * (c1 % c2) + 18 + + except Exception, e: + self.error(_("Unable to calculate checksum"), e) + else: - return res + return b def get_link(self): -- cgit v1.2.3 From fd105f8e51768ec1943cda2375bdfdbe5b0a3951 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 9 Jan 2015 00:35:51 +0100 Subject: "New Year" Update: hoster plugins --- module/plugins/hoster/ZippyshareCom.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'module/plugins/hoster/ZippyshareCom.py') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index 73dd1f22d..2648f532f 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -10,7 +10,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" __type__ = "hoster" - __version__ = "0.65" + __version__ = "0.66" __pattern__ = r'(?Phttp://www\d{0,2}\.zippyshare\.com)/v(?:/|iew\.jsp.*key=)(?P\d+)' @@ -33,9 +33,11 @@ class ZippyshareCom(SimpleHoster): self.resumeDownload = True - def handleFree(self): - url = self.get_link() - self.download(url) + def handleFree(self, pyfile): + checksum = self.get_checksum() + p_url = '/'.join(("d", self.info['pattern']['KEY'], str(checksum), self.pyfile.name)) + + self.link = urljoin(self.info['pattern']['HOST'], p_url) def get_checksum(self): @@ -56,11 +58,4 @@ class ZippyshareCom(SimpleHoster): return b - def get_link(self): - checksum = self.get_checksum() - p_url = '/'.join(("d", self.info['pattern']['KEY'], str(checksum), self.pyfile.name)) - dl_link = urljoin(self.info['pattern']['HOST'], p_url) - return dl_link - - getInfo = create_getInfo(ZippyshareCom) -- cgit v1.2.3 From 56cb56814116f1df232e86b9659e54f11c438f64 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 16 Jan 2015 15:37:53 +0100 Subject: [ZippyshareCom] Fix https://github.com/pyload/pyload/issues/1049 --- module/plugins/hoster/ZippyshareCom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/ZippyshareCom.py') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index 2648f532f..39c8d36d6 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -10,9 +10,9 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" __type__ = "hoster" - __version__ = "0.66" + __version__ = "0.67" - __pattern__ = r'(?Phttp://www\d{0,2}\.zippyshare\.com)/v(?:/|iew\.jsp.*key=)(?P\d+)' + __pattern__ = r'(?Phttp://www\d{0,2}\.zippyshare\.com)/v(?:/|iew\.jsp.*key=)(?P[\w^_]+)' __description__ = """Zippyshare.com hoster plugin""" __license__ = "GPLv3" -- cgit v1.2.3 From 5f132e5d5c97f2f3e9ce2c532ce61cb87734f545 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 22 Jan 2015 21:04:09 +0100 Subject: [ZippyshareCom] Fix https://github.com/pyload/pyload/issues/1060 --- module/plugins/hoster/ZippyshareCom.py | 37 +++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'module/plugins/hoster/ZippyshareCom.py') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index 39c8d36d6..f32c5877f 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -2,42 +2,51 @@ import re -from urlparse import urljoin - +from module.plugins.internal.CaptchaService import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" __type__ = "hoster" - __version__ = "0.67" + __version__ = "0.68" - __pattern__ = r'(?Phttp://www\d{0,2}\.zippyshare\.com)/v(?:/|iew\.jsp.*key=)(?P[\w^_]+)' + __pattern__ = r'http://www\d{0,2}\.zippyshare\.com/v(/|iew\.jsp.*key=)(?P[\w^_]+)' __description__ = """Zippyshare.com hoster plugin""" __license__ = "GPLv3" __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - NAME_PATTERN = r'("\d{6,}/"[ ]*\+.+?"/|Zippyshare.com - )(?P<N>.+?)("|)' - SIZE_PATTERN = r'>Size:.+?">(?P[\d.,]+) (?P[\w^_]+)' + COOKIES = [("zippyshare.com", "ziplocale", "en")] - OFFLINE_PATTERN = r'>File does not exist on this server<' + NAME_PATTERN = r'("\d{6,}/"[ ]*\+.+?"/|Zippyshare.com - )(?P<N>.+?)("|)' + SIZE_PATTERN = r'>Size:.+?">(?P[\d.,]+) (?P[\w^_]+)' + OFFLINE_PATTERN = r'>File does not exist on this server' - COOKIES = [("zippyshare.com", "ziplocale", "en")] + LINK_PREMIUM_PATTERN = r'document.location = \'(.+?)\'' def setup(self): - self.multiDL = True self.chunkLimit = -1 + self.multiDL = True self.resumeDownload = True def handleFree(self, pyfile): - checksum = self.get_checksum() - p_url = '/'.join(("d", self.info['pattern']['KEY'], str(checksum), self.pyfile.name)) + recaptcha = ReCaptcha(self) + captcha_key = recaptcha.detect_key() + + if captcha_key: + try: + self.link = re.search(self.LINK_PREMIUM_PATTERN, self.html) + recaptcha.challenge() - self.link = urljoin(self.info['pattern']['HOST'], p_url) + except Exception, e: + self.error(e) + + else: + self.link = '/'.join(("d", self.info['pattern']['KEY'], str(self.get_checksum()), self.pyfile.name)) def get_checksum(self): @@ -51,8 +60,8 @@ class ZippyshareCom(SimpleHoster): c1, c2 = map(int, re.search(r'\(\'downloadB\'\).omg\) \* \((\d+)%(\d+)', self.html).groups()) b = (a1 % a2) * (c1 % c2) + 18 - except Exception, e: - self.error(_("Unable to calculate checksum"), e) + except Exception: + self.error(_("Unable to calculate checksum")) else: return b -- cgit v1.2.3 From 2f52964b45248e32cddcef0ac2f09477bec6c690 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 7 Feb 2015 22:04:19 +0100 Subject: [ZippyshareCom] Fix https://github.com/pyload/pyload/issues/1150 --- module/plugins/hoster/ZippyshareCom.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'module/plugins/hoster/ZippyshareCom.py') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index f32c5877f..ad4b49b44 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -9,7 +9,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" __type__ = "hoster" - __version__ = "0.68" + __version__ = "0.69" __pattern__ = r'http://www\d{0,2}\.zippyshare\.com/v(/|iew\.jsp.*key=)(?P[\w^_]+)' @@ -51,20 +51,17 @@ class ZippyshareCom(SimpleHoster): def get_checksum(self): try: - m = re.search(r'\+[ ]*\((\d+)[ ]*\%[ ]*(\d+)[ ]*\+[ ]*(\d+)[ ]*\%[ ]*(\d+)\)[ ]*\+', self.html) - if m: - a1, a2, c1, c2 = map(int, m.groups()) - b = (a1 % a2) + (c1 % c2) - else: - a1, a2 = map(int, re.search(r'\(\'downloadB\'\).omg = (\d+)%(\d+)' , self.html).groups()) - c1, c2 = map(int, re.search(r'\(\'downloadB\'\).omg\) \* \((\d+)%(\d+)', self.html).groups()) - b = (a1 % a2) * (c1 % c2) + 18 + z = re.search(r'var z = (\d+)', self.html).group(1) + n = (z - 3) % 2 + b = (z - 3) % 3 + + checksum = n + b + z - 3 except Exception: self.error(_("Unable to calculate checksum")) else: - return b + return checksum getInfo = create_getInfo(ZippyshareCom) -- cgit v1.2.3 From 30f247b9bb25cc6cc049a87c9525b7981e5673ea Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 8 Feb 2015 02:07:14 +0100 Subject: [ZippyshareCom] Typo --- module/plugins/hoster/ZippyshareCom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/ZippyshareCom.py') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index ad4b49b44..ac5e744a7 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -9,7 +9,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" __type__ = "hoster" - __version__ = "0.69" + __version__ = "0.70" __pattern__ = r'http://www\d{0,2}\.zippyshare\.com/v(/|iew\.jsp.*key=)(?P[\w^_]+)' @@ -51,7 +51,7 @@ class ZippyshareCom(SimpleHoster): def get_checksum(self): try: - z = re.search(r'var z = (\d+)', self.html).group(1) + z = int(re.search(r'var z = (\d+)', self.html).group(1)) n = (z - 3) % 2 b = (z - 3) % 3 -- cgit v1.2.3 From f90475a3a0c74c87109157dd42e85c9010010168 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 11 Feb 2015 03:45:15 +0100 Subject: [ZippyshareCom] Update get_checksum --- module/plugins/hoster/ZippyshareCom.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'module/plugins/hoster/ZippyshareCom.py') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index ac5e744a7..47a4acd03 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -9,7 +9,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" __type__ = "hoster" - __version__ = "0.70" + __version__ = "0.71" __pattern__ = r'http://www\d{0,2}\.zippyshare\.com/v(/|iew\.jsp.*key=)(?P[\w^_]+)' @@ -51,11 +51,9 @@ class ZippyshareCom(SimpleHoster): def get_checksum(self): try: - z = int(re.search(r'var z = (\d+)', self.html).group(1)) - n = (z - 3) % 2 - b = (z - 3) % 3 - - checksum = n + b + z - 3 + m = re.search(r'\+[ ]*\((\d+)[ ]*\%[ ]*(\d+)[ ]*\+[ ]*(\d+)[ ]*\%[ ]*(\d+)\)[ ]*\+', self.html) + a1, a2, c1, c2 = map(int, m.groups()) + checksum = (a1 % a2) + (c1 % c2) except Exception: self.error(_("Unable to calculate checksum")) -- cgit v1.2.3 From 4de9ef03e364c432ead17e8d866569e1053d84ff Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 15 Feb 2015 02:10:10 +0100 Subject: [ZippyshareCom] Update get_checksum --- module/plugins/hoster/ZippyshareCom.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hoster/ZippyshareCom.py') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index 47a4acd03..a43f70cbd 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -9,7 +9,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" __type__ = "hoster" - __version__ = "0.71" + __version__ = "0.72" __pattern__ = r'http://www\d{0,2}\.zippyshare\.com/v(/|iew\.jsp.*key=)(?P[\w^_]+)' @@ -51,9 +51,9 @@ class ZippyshareCom(SimpleHoster): def get_checksum(self): try: - m = re.search(r'\+[ ]*\((\d+)[ ]*\%[ ]*(\d+)[ ]*\+[ ]*(\d+)[ ]*\%[ ]*(\d+)\)[ ]*\+', self.html) - a1, a2, c1, c2 = map(int, m.groups()) - checksum = (a1 % a2) + (c1 % c2) + n = 2 + b = int(re.search(r'var b = (\d+)', self.html).group(1)) + checksum = int("%d3" % (n + n * 2 + b)) except Exception: self.error(_("Unable to calculate checksum")) -- cgit v1.2.3 From b6e0ba974abe0d6bf712ecf5c0d116804050c9e3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 19 Feb 2015 00:55:28 +0100 Subject: [ZippyshareCom] Update get_checksum --- module/plugins/hoster/ZippyshareCom.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hoster/ZippyshareCom.py') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index a43f70cbd..615559989 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -9,7 +9,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" __type__ = "hoster" - __version__ = "0.72" + __version__ = "0.73" __pattern__ = r'http://www\d{0,2}\.zippyshare\.com/v(/|iew\.jsp.*key=)(?P[\w^_]+)' @@ -51,9 +51,9 @@ class ZippyshareCom(SimpleHoster): def get_checksum(self): try: - n = 2 - b = int(re.search(r'var b = (\d+)', self.html).group(1)) - checksum = int("%d3" % (n + n * 2 + b)) + b1 = eval(re.search(r'\.omg = (.+?);', self.html).group(1)) + b2 = eval(re.search(r'\* \((.+?)\)', self.html).group(1)) + checksum = b1 * b2 + 18 except Exception: self.error(_("Unable to calculate checksum")) -- cgit v1.2.3 From 9599ff3a6217aeb38c7d9d4c4257106c1ff79f1b Mon Sep 17 00:00:00 2001 From: sebdelsol Date: Mon, 23 Feb 2015 14:18:42 +0100 Subject: Zippyshare bug #1191 correction This version use the internal `Beatifulsoup`. When you decide to get rid of it I suggest to add a dependency to `lxml`. I've found a way to handle deliberate errors in the JS scripts without relying on PyV8: I've added JS `try/catch` statements around zippyshare scripts. --- module/plugins/hoster/ZippyshareCom.py | 49 +++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 13 deletions(-) (limited to 'module/plugins/hoster/ZippyshareCom.py') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index 615559989..ad4688bac 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -5,17 +5,18 @@ import re from module.plugins.internal.CaptchaService import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.lib.BeautifulSoup import BeautifulSoup class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" __type__ = "hoster" - __version__ = "0.73" + __version__ = "0.74" __pattern__ = r'http://www\d{0,2}\.zippyshare\.com/v(/|iew\.jsp.*key=)(?P[\w^_]+)' __description__ = """Zippyshare.com hoster plugin""" __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("Walter Purcaro", "vuolter@gmail.com", "sebdelsol")] COOKIES = [("zippyshare.com", "ziplocale", "en")] @@ -46,20 +47,42 @@ class ZippyshareCom(SimpleHoster): self.error(e) else: - self.link = '/'.join(("d", self.info['pattern']['KEY'], str(self.get_checksum()), self.pyfile.name)) + self.link = self.get_link() - - def get_checksum(self): + def get_link(self): try: - b1 = eval(re.search(r'\.omg = (.+?);', self.html).group(1)) - b2 = eval(re.search(r'\* \((.+?)\)', self.html).group(1)) - checksum = b1 * b2 + 18 + # get all the scripts inside the html body + soup = BeautifulSoup(self.html) + scripts = (s.getText() for s in soup.body.findAll('script', type='text/javascript')) + + # meant to be populated with the initialization of all the DOM elements found in the scripts + initScripts = set() + + def replElementById(element): + id, attr = element.group(1), element.group(4) # attr might be None + + varName = '%s_%s' %(id, attr) + + initValues = (elt.get(attr, None) for elt in soup.findAll(id=id)) + initValues = [v for v in initValues if v is not None] + initValue = '"%s"' %initValues[-1] if initValues else 'null' + + initScripts.add('var %s = %s;' %(varName, initValue)) + return varName + + # handle all getElementById + reVar = r'document.getElementById\([\'"](\w+)[\'"]\)(\.)?(getAttribute\([\'"])?(\w+)?([\'"]\))?' + scripts = [re.sub(reVar, replElementById, script) for script in scripts] + + # add try/catch in JS to handle deliberate errors + tryJS, catchJS = u'try{', u'} catch(err){}' # '', '' to see where the script fails + scripts = ['\n'.join((tryJS, script, catchJS)) for script in scripts if script.strip()] + + # get the file's url by evaluating all the scripts + scripts = '\n'.join(list(initScripts) + scripts + ['dlbutton_href']) + return self.js.eval(scripts) except Exception: - self.error(_("Unable to calculate checksum")) - - else: - return checksum - + self.error(_("Unable to calculate the link")) getInfo = create_getInfo(ZippyshareCom) -- cgit v1.2.3 From baecc72778bac0e0076d30d0459a65abe8dc076c Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 24 Feb 2015 22:08:30 +0100 Subject: [ZippyshareCom] Cleanup --- module/plugins/hoster/ZippyshareCom.py | 72 +++++++++++++++++----------------- 1 file changed, 35 insertions(+), 37 deletions(-) (limited to 'module/plugins/hoster/ZippyshareCom.py') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index ad4688bac..c7a568e79 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -2,10 +2,11 @@ import re +from module.lib.BeautifulSoup import BeautifulSoup + from module.plugins.internal.CaptchaService import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -from module.lib.BeautifulSoup import BeautifulSoup class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" @@ -16,7 +17,8 @@ class ZippyshareCom(SimpleHoster): __description__ = """Zippyshare.com hoster plugin""" __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com", "sebdelsol")] + __authors__ = [("Walter Purcaro", "vuolter@gmail.com"), + ("sebdelsol", "seb.morin@gmail.com")] COOKIES = [("zippyshare.com", "ziplocale", "en")] @@ -25,7 +27,7 @@ class ZippyshareCom(SimpleHoster): SIZE_PATTERN = r'>Size:.+?">(?P[\d.,]+) (?P[\w^_]+)' OFFLINE_PATTERN = r'>File does not exist on this server' - LINK_PREMIUM_PATTERN = r'document.location = \'(.+?)\'' + LINK_PREMIUM_PATTERN = r"document.location = '(.+?)'" def setup(self): @@ -49,40 +51,36 @@ class ZippyshareCom(SimpleHoster): else: self.link = self.get_link() + def get_link(self): - try: - # get all the scripts inside the html body - soup = BeautifulSoup(self.html) - scripts = (s.getText() for s in soup.body.findAll('script', type='text/javascript')) - - # meant to be populated with the initialization of all the DOM elements found in the scripts - initScripts = set() - - def replElementById(element): - id, attr = element.group(1), element.group(4) # attr might be None - - varName = '%s_%s' %(id, attr) - - initValues = (elt.get(attr, None) for elt in soup.findAll(id=id)) - initValues = [v for v in initValues if v is not None] - initValue = '"%s"' %initValues[-1] if initValues else 'null' - - initScripts.add('var %s = %s;' %(varName, initValue)) - return varName - - # handle all getElementById - reVar = r'document.getElementById\([\'"](\w+)[\'"]\)(\.)?(getAttribute\([\'"])?(\w+)?([\'"]\))?' - scripts = [re.sub(reVar, replElementById, script) for script in scripts] - - # add try/catch in JS to handle deliberate errors - tryJS, catchJS = u'try{', u'} catch(err){}' # '', '' to see where the script fails - scripts = ['\n'.join((tryJS, script, catchJS)) for script in scripts if script.strip()] - - # get the file's url by evaluating all the scripts - scripts = '\n'.join(list(initScripts) + scripts + ['dlbutton_href']) - return self.js.eval(scripts) - - except Exception: - self.error(_("Unable to calculate the link")) + # get all the scripts inside the html body + soup = BeautifulSoup(self.html) + scripts = (s.getText() for s in soup.body.findAll('script', type='text/javascript')) + + # meant to be populated with the initialization of all the DOM elements found in the scripts + initScripts = set() + + def replElementById(element): + id = element.group(1) + attr = element.group(4) #: attr might be None + + varName = '%s_%s' % (id, attr) + initValues = filter(None, [elt.get(attr, None) for elt in soup.findAll(id=id)]) + initValue = '"%s"' % initValues[-1] if initValues else 'null' + + initScripts.add('var %s = %s;' % (varName, initValue)) + return varName + + # handle all getElementById + reVar = r'document.getElementById\([\'"](\w+)[\'"]\)(\.)?(getAttribute\([\'"])?(\w+)?([\'"]\))?' + scripts = [re.sub(reVar, replElementById, script) for script in scripts] + + # add try/catch in JS to handle deliberate errors + scripts = ["\n".join(("try{", script, "} catch(err){}")) for script in scripts if script.strip()] + + # get the file's url by evaluating all the scripts + scripts = "\n".join(list(initScripts) + scripts + ['dlbutton_href']) + return self.js.eval(scripts) + getInfo = create_getInfo(ZippyshareCom) -- cgit v1.2.3 From 6cf515ec73eefe0859a31f6b254de9ae54fc17ae Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 8 Mar 2015 20:39:55 +0100 Subject: [ZippyshareCom] Better lib import --- module/plugins/hoster/ZippyshareCom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/ZippyshareCom.py') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index c7a568e79..9d7c6949f 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -2,7 +2,7 @@ import re -from module.lib.BeautifulSoup import BeautifulSoup +from BeautifulSoup import BeautifulSoup from module.plugins.internal.CaptchaService import ReCaptcha from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -- cgit v1.2.3 From 678f488777a94522ce8ba68f106428eefa037f50 Mon Sep 17 00:00:00 2001 From: sebdelsol Date: Mon, 9 Mar 2015 21:42:19 +0100 Subject: [ZippyShare] Bug #1238 correction * remove non ascii character from the id part in the js variable name. * change the RE so that it works for any character in the id name --- module/plugins/hoster/ZippyshareCom.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hoster/ZippyshareCom.py') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index 9d7c6949f..f2c99de7b 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -11,7 +11,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" __type__ = "hoster" - __version__ = "0.74" + __version__ = "0.75" __pattern__ = r'http://www\d{0,2}\.zippyshare\.com/v(/|iew\.jsp.*key=)(?P[\w^_]+)' @@ -64,7 +64,7 @@ class ZippyshareCom(SimpleHoster): id = element.group(1) attr = element.group(4) #: attr might be None - varName = '%s_%s' % (id, attr) + varName = '%s_%s' % (re.sub(r'\W', '', id), attr) initValues = filter(None, [elt.get(attr, None) for elt in soup.findAll(id=id)]) initValue = '"%s"' % initValues[-1] if initValues else 'null' @@ -72,7 +72,7 @@ class ZippyshareCom(SimpleHoster): return varName # handle all getElementById - reVar = r'document.getElementById\([\'"](\w+)[\'"]\)(\.)?(getAttribute\([\'"])?(\w+)?([\'"]\))?' + reVar = r'document.getElementById\([\'"](.+)[\'"]\)(\.)?(getAttribute\([\'"])?(\w+)?([\'"]\))?' scripts = [re.sub(reVar, replElementById, script) for script in scripts] # add try/catch in JS to handle deliberate errors -- cgit v1.2.3 From 879348c7244fb512b3ddd67f0c313baef82ea854 Mon Sep 17 00:00:00 2001 From: sebdelsol Date: Wed, 11 Mar 2015 00:44:13 +0100 Subject: [zippyshare] bug correction #1246 Handle funky introspection like : ```javascript test = { test: function(x, y) { document.getElementById(x).href = y; } test.test('dlbutton', "http:\\ZippyshareIsFullOfTrickster.com"); ``` --- module/plugins/hoster/ZippyshareCom.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'module/plugins/hoster/ZippyshareCom.py') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index f2c99de7b..d9d1db1be 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -11,7 +11,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" __type__ = "hoster" - __version__ = "0.75" + __version__ = "0.76" __pattern__ = r'http://www\d{0,2}\.zippyshare\.com/v(/|iew\.jsp.*key=)(?P[\w^_]+)' @@ -55,32 +55,35 @@ class ZippyshareCom(SimpleHoster): def get_link(self): # get all the scripts inside the html body soup = BeautifulSoup(self.html) - scripts = (s.getText() for s in soup.body.findAll('script', type='text/javascript')) + scripts = (s.getText().strip() for s in soup.body.findAll('script', type='text/javascript')) # meant to be populated with the initialization of all the DOM elements found in the scripts initScripts = set() def replElementById(element): - id = element.group(1) - attr = element.group(4) #: attr might be None - - varName = '%s_%s' % (re.sub(r'\W', '', id), attr) - initValues = filter(None, [elt.get(attr, None) for elt in soup.findAll(id=id)]) - initValue = '"%s"' % initValues[-1] if initValues else 'null' - - initScripts.add('var %s = %s;' % (varName, initValue)) + id = element.group(1) # id might be either 'x' (a real id) or x (a variable) + attr = element.group(4) # attr might be None + + varName = re.sub(r'-', '', 'GVAR[%s+"_%s"]' %(id, attr)) + + realid = id.strip('"\'') + if id != realid: #id is not a variable, so look for realid.attr in the html + initValues = filter(None, [elt.get(attr, None) for elt in soup.findAll(id=realid)]) + initValue = '"%s"' % initValues[-1] if initValues else 'null' + initScripts.add('%s = %s;' % (varName, initValue)) + return varName # handle all getElementById - reVar = r'document.getElementById\([\'"](.+)[\'"]\)(\.)?(getAttribute\([\'"])?(\w+)?([\'"]\))?' - scripts = [re.sub(reVar, replElementById, script) for script in scripts] + reVar = r'document.getElementById\(([\'"\w-]+)\)(\.)?(getAttribute\([\'"])?(\w+)?([\'"]\))?' + scripts = [re.sub(reVar, replElementById, script) for script in scripts if script] # add try/catch in JS to handle deliberate errors - scripts = ["\n".join(("try{", script, "} catch(err){}")) for script in scripts if script.strip()] + scripts = ['\n'.join(('try{', script, '} catch(err){}')) for script in scripts] # get the file's url by evaluating all the scripts - scripts = "\n".join(list(initScripts) + scripts + ['dlbutton_href']) - return self.js.eval(scripts) + scripts = ['var GVAR = {}'] + list(initScripts) + scripts + ['GVAR["dlbutton_href"]'] + return self.js.eval('\n'.join(scripts)) getInfo = create_getInfo(ZippyshareCom) -- cgit v1.2.3 From e65d19ee3a1e435bf2896ed829e5581eeef92dd2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 14 Mar 2015 11:07:54 +0100 Subject: Import cleanup for datetime and time modules --- module/plugins/hoster/ZippyshareCom.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hoster/ZippyshareCom.py') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index d9d1db1be..f9e112aed 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -63,15 +63,15 @@ class ZippyshareCom(SimpleHoster): def replElementById(element): id = element.group(1) # id might be either 'x' (a real id) or x (a variable) attr = element.group(4) # attr might be None - + varName = re.sub(r'-', '', 'GVAR[%s+"_%s"]' %(id, attr)) - + realid = id.strip('"\'') - if id != realid: #id is not a variable, so look for realid.attr in the html + if id != realid: #id is not a variable, so look for realid.attr in the html initValues = filter(None, [elt.get(attr, None) for elt in soup.findAll(id=realid)]) initValue = '"%s"' % initValues[-1] if initValues else 'null' initScripts.add('%s = %s;' % (varName, initValue)) - + return varName # handle all getElementById -- cgit v1.2.3 From 53eeea26ed000ef294b8e382e0541c0665870999 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 18 Mar 2015 22:09:57 +0100 Subject: [ZippyshareCom] Fix https://github.com/pyload/pyload/issues/1262 --- module/plugins/hoster/ZippyshareCom.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hoster/ZippyshareCom.py') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index f9e112aed..8da0f4942 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -11,7 +11,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" __type__ = "hoster" - __version__ = "0.76" + __version__ = "0.77" __pattern__ = r'http://www\d{0,2}\.zippyshare\.com/v(/|iew\.jsp.*key=)(?P[\w^_]+)' @@ -23,9 +23,9 @@ class ZippyshareCom(SimpleHoster): COOKIES = [("zippyshare.com", "ziplocale", "en")] - NAME_PATTERN = r'("\d{6,}/"[ ]*\+.+?"/|Zippyshare.com - )(?P<N>.+?)("|)' + NAME_PATTERN = r'("/|Zippyshare.com - )(?P<N>[^/]+?)("\);|)' SIZE_PATTERN = r'>Size:.+?">(?P[\d.,]+) (?P[\w^_]+)' - OFFLINE_PATTERN = r'>File does not exist on this server' + OFFLINE_PATTERN = r'does not exist (anymore )?on this server<' LINK_PREMIUM_PATTERN = r"document.location = '(.+?)'" -- cgit v1.2.3 From 7d90803262ccbb4fc5296a4dc3ce30fe98f55631 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 25 Mar 2015 23:10:07 +0100 Subject: __config__ cosmetics --- module/plugins/hoster/ZippyshareCom.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/hoster/ZippyshareCom.py') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index 8da0f4942..3f392133a 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -14,6 +14,7 @@ class ZippyshareCom(SimpleHoster): __version__ = "0.77" __pattern__ = r'http://www\d{0,2}\.zippyshare\.com/v(/|iew\.jsp.*key=)(?P[\w^_]+)' + __config__ = [("use_premium", "bool", "Use premium account if available", True)] __description__ = """Zippyshare.com hoster plugin""" __license__ = "GPLv3" -- cgit v1.2.3 From 40add66d77e0eeb1f0f709ad07ecba553123bba1 Mon Sep 17 00:00:00 2001 From: sebdelsol Date: Sat, 4 Apr 2015 21:15:35 +0200 Subject: [zippyshare] fix bug #1311 Zippyshare sometimes encode file name with an image. In this case, use the file link to get the file name. (it's probably a bad hack. I don't know nothing about pyload Core). --- module/plugins/hoster/ZippyshareCom.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'module/plugins/hoster/ZippyshareCom.py') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index 3f392133a..27ec598e1 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import re +from urllib import unquote from BeautifulSoup import BeautifulSoup @@ -52,6 +53,9 @@ class ZippyshareCom(SimpleHoster): else: self.link = self.get_link() + if pyfile.name == 'file.html' and self.link: + pyfile.name = unquote(self.link.split('/')[-1]) + def get_link(self): # get all the scripts inside the html body -- cgit v1.2.3 From e5ab79dc23dd5a50a4b4a3d5a51427eed55dcad5 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 8 Apr 2015 23:19:29 +0200 Subject: [ZippyshareCom] Fix https://github.com/pyload/pyload/issues/1311 --- module/plugins/hoster/ZippyshareCom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/ZippyshareCom.py') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index 3f392133a..7af2c3370 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -11,7 +11,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" __type__ = "hoster" - __version__ = "0.77" + __version__ = "0.78" __pattern__ = r'http://www\d{0,2}\.zippyshare\.com/v(/|iew\.jsp.*key=)(?P[\w^_]+)' __config__ = [("use_premium", "bool", "Use premium account if available", True)] @@ -24,7 +24,7 @@ class ZippyshareCom(SimpleHoster): COOKIES = [("zippyshare.com", "ziplocale", "en")] - NAME_PATTERN = r'("/|Zippyshare.com - )(?P<N>[^/]+?)("\);|)' + NAME_PATTERN = r'(Zippyshare.com - |"/)(?P<N>[^/]+)(|";)' SIZE_PATTERN = r'>Size:.+?">(?P[\d.,]+) (?P[\w^_]+)' OFFLINE_PATTERN = r'does not exist (anymore )?on this server<' -- cgit v1.2.3 From 73f99ea811d01a2e113a882fe5ab86b0aa9c4f4c Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 9 Apr 2015 00:22:51 +0200 Subject: [SimpleHoster] Improve file name handling --- module/plugins/hoster/ZippyshareCom.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hoster/ZippyshareCom.py') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index cdb37a18c..fbac432cd 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- import re -from urllib import unquote +import urllib from BeautifulSoup import BeautifulSoup @@ -53,8 +53,8 @@ class ZippyshareCom(SimpleHoster): else: self.link = self.get_link() - if pyfile.name == 'file.html' and self.link: - pyfile.name = unquote(self.link.split('/')[-1]) + if self.link and pyfile.name == 'file.html': + pyfile.name = urllib.unquote(self.link.split('/')[-1]) def get_link(self): -- cgit v1.2.3 From 55717d96c0ef590f9c224741415447b8adb12f95 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 4 May 2015 21:30:39 +0200 Subject: [SizedriveCom] Cleanup --- module/plugins/hoster/ZippyshareCom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/ZippyshareCom.py') diff --git a/module/plugins/hoster/ZippyshareCom.py b/module/plugins/hoster/ZippyshareCom.py index fbac432cd..c47ac4fe1 100644 --- a/module/plugins/hoster/ZippyshareCom.py +++ b/module/plugins/hoster/ZippyshareCom.py @@ -66,7 +66,7 @@ class ZippyshareCom(SimpleHoster): initScripts = set() def replElementById(element): - id = element.group(1) # id might be either 'x' (a real id) or x (a variable) + id = element.group(1) # id might be either 'x' (a real id) or x (a variable) attr = element.group(4) # attr might be None varName = re.sub(r'-', '', 'GVAR[%s+"_%s"]' %(id, attr)) -- cgit v1.2.3