diff options
| author | 2015-03-11 00:47:34 +0100 | |
|---|---|---|
| committer | 2015-03-11 00:47:34 +0100 | |
| commit | a4afc38411b11228258c7c876450ad32d45601a2 (patch) | |
| tree | aab7aa9b44558c32f477f0de8780fba2598acb7d | |
| parent | [BasePlugin][SimpleHoster] Improve checkDownload rules (diff) | |
| parent | [zippyshare] bug correction #1246 (diff) | |
| download | pyload-a4afc38411b11228258c7c876450ad32d45601a2.tar.xz | |
Merge pull request #1247 from sebdelsol/patch-3
[zippyshare] bug correction #1246
| -rw-r--r-- | module/plugins/hoster/ZippyshareCom.py | 33 | 
1 files changed, 18 insertions, 15 deletions
| 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<KEY>[\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) | 
