diff options
author | Walter Purcaro <vuolter@gmail.com> | 2015-02-03 16:42:23 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2015-02-03 16:42:23 +0100 |
commit | 80f03e5c1dbb0bc6d4c20995f3a2d467dcab82c0 (patch) | |
tree | 463ba95be0c7620acab293e2920f1e49b5d1634f /module/plugins | |
parent | Merge pull request #1139 from zapp-brannigan/patch-1 (diff) | |
download | pyload-80f03e5c1dbb0bc6d4c20995f3a2d467dcab82c0.tar.xz |
[GoogledriveCom] Cleanup
Diffstat (limited to 'module/plugins')
-rw-r--r-- | module/plugins/hoster/GoogledriveCom.py | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/module/plugins/hoster/GoogledriveCom.py b/module/plugins/hoster/GoogledriveCom.py index d3736f219..1feb8132e 100644 --- a/module/plugins/hoster/GoogledriveCom.py +++ b/module/plugins/hoster/GoogledriveCom.py @@ -4,9 +4,9 @@ # https://drive.google.com/file/d/0B6RNTe4ygItBQm15RnJiTmMyckU/view?pli=1 import re -import HTMLParser from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.utils import html_unescape class GoogledriveCom(SimpleHoster): @@ -14,16 +14,14 @@ class GoogledriveCom(SimpleHoster): __type__ = "hoster" __version__ = "0.01" - __pattern__ = r'https?://(?:www\.)?drive.google.com/file/.*' + __pattern__ = r'https?://(?:www\.)?drive\.google\.com/file/.+' - __description__ = """drive.google.com hoster plugin""" + __description__ = """Drive.google.com hoster plugin""" __license__ = "GPLv3" __authors__ = [("zapp-brannigan", "fuerst.reinje@web.de")] NAME_PATTERN = r'"og:title" content="(?P<N>.*?)">' - SIZE_PATTERN = r'^unmatchable$' # NOTE: There is no filesize on the website - OFFLINE_PATTERN = r'align="center"><p class="errorMessage"' @@ -32,23 +30,34 @@ class GoogledriveCom(SimpleHoster): self.resumeDownload = True self.chunkLimit = 1 + def handleFree(self, pyfile): - link1 = re.search(r'"(https://docs.google.com/uc\?id.*?export=download)",', self.html.decode('unicode-escape')) - if not link1: + try: + link1 = re.search(r'"(https://docs.google.com/uc\?id.*?export=download)",', + self.html.decode('unicode-escape')).group(1) + + except AttributeError: self.error(_("Hop #1 not found")) - self.logDebug("Next hop: %s" % link1.group(1)) - - html = self.load(link1.group(1)).decode('unicode-escape') - link2 = re.search(r'href="(/uc\?export=download.*?)">',html) - if not link2: + + else: + self.logDebug("Next hop: %s" % link1)) + + self.html = self.load(link1).decode('unicode-escape') + + try: + link2 = html_unescape(re.search(r'href="(/uc\?export=download.*?)">', + self.html).group(1)) + + except AttributeError: self.error(_("Hop #2 not found")) - link2 = HTMLParser.HTMLParser().unescape(link2.group(1)) - self.logDebug("Next hop: %s" % link2) - + + else: + self.logDebug("Next hop: %s" % link2) + link3 = self.load("https://docs.google.com" + link2, just_header=True) self.logDebug("DL-Link: %s" % link3['location']) - self.download(link3['location']) # NOTE: I don't use disposition=True because it breaks the filename. - - + self.link = link3['location'] #@NOTE: I don't use disposition=True because it breaks the filename. + + getInfo = create_getInfo(GoogledriveCom) |