diff options
Diffstat (limited to 'pyload/plugin/hoster/ZippyshareCom.py')
-rw-r--r-- | pyload/plugin/hoster/ZippyshareCom.py | 55 |
1 files changed, 40 insertions, 15 deletions
diff --git a/pyload/plugin/hoster/ZippyshareCom.py b/pyload/plugin/hoster/ZippyshareCom.py index f52d90b8b..784eccb68 100644 --- a/pyload/plugin/hoster/ZippyshareCom.py +++ b/pyload/plugin/hoster/ZippyshareCom.py @@ -2,6 +2,8 @@ import re +from BeautifulSoup import BeautifulSoup + from pyload.plugin.internal.CaptchaService import ReCaptcha from pyload.plugin.internal.SimpleHoster import SimpleHoster @@ -9,22 +11,24 @@ from pyload.plugin.internal.SimpleHoster import SimpleHoster class ZippyshareCom(SimpleHoster): __name__ = "ZippyshareCom" __type__ = "hoster" - __version__ = "0.73" + __version__ = "0.77" __pattern__ = r'http://www\d{0,2}\.zippyshare\.com/v(/|iew\.jsp.*key=)(?P<KEY>[\w^_]+)' + __config__ = [("use_premium", "bool", "Use premium account if available", True)] __description__ = """Zippyshare.com hoster plugin""" __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + __authors__ = [("Walter Purcaro", "vuolter@gmail.com"), + ("sebdelsol", "seb.morin@gmail.com")] COOKIES = [("zippyshare.com", "ziplocale", "en")] - NAME_PATTERN = r'("\d{6,}/"[ ]*\+.+?"/|<title>Zippyshare.com - )(?P<N>.+?)("|</title>)' + NAME_PATTERN = r'("/|<title>Zippyshare.com - )(?P<N>[^/]+?)("\);|</title>)' SIZE_PATTERN = r'>Size:.+?">(?P<S>[\d.,]+) (?P<U>[\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 = \'(.+?)\'' + LINK_PREMIUM_PATTERN = r"document.location = '(.+?)'" def setup(self): @@ -46,17 +50,38 @@ 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): - try: - b1 = eval(re.search(r'\.omg = (.+?);', self.html).group(1)) - b2 = eval(re.search(r'\* \((.+?)\)', self.html).group(1)) - checksum = b1 * b2 + 18 + def get_link(self): + # get all the scripts inside the html body + soup = BeautifulSoup(self.html) + scripts = (s.getText().strip() for s in soup.body.findAll('script', type='text/javascript')) - except Exception: - self.error(_("Unable to calculate checksum")) + # meant to be populated with the initialization of all the DOM elements found in the scripts + initScripts = set() - else: - return checksum + 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 + 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\(([\'"\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] + + # get the file's url by evaluating all the scripts + scripts = ['var GVAR = {}'] + list(initScripts) + scripts + ['GVAR["dlbutton_href"]'] + return self.js.eval('\n'.join(scripts)) |