From 7e65484b60890bbfa39aa7631343dcfb5c379cf9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 26 May 2015 01:25:05 +0200 Subject: [GoogledriveCom] Fixup --- module/plugins/hoster/GoogledriveCom.py | 47 ++++++++++++++------------------- 1 file changed, 20 insertions(+), 27 deletions(-) (limited to 'module/plugins/hoster') diff --git a/module/plugins/hoster/GoogledriveCom.py b/module/plugins/hoster/GoogledriveCom.py index c7830b734..5a8862e6b 100644 --- a/module/plugins/hoster/GoogledriveCom.py +++ b/module/plugins/hoster/GoogledriveCom.py @@ -13,7 +13,7 @@ from module.utils import html_unescape class GoogledriveCom(SimpleHoster): __name__ = "GoogledriveCom" __type__ = "hoster" - __version__ = "0.09" + __version__ = "0.10" __pattern__ = r'https?://(?:www\.)?(drive|docs)\.google\.com/file/d/\w+' __config__ = [("use_premium", "bool", "Use premium account if available", True)] @@ -28,6 +28,8 @@ class GoogledriveCom(SimpleHoster): NAME_PATTERN = r'"og:title" content="(?P.*?)">' OFFLINE_PATTERN = r'align="center">

', - self.html).group(1)) - - except AttributeError: - self.error(_("Hop #2 not found")) - - else: - self.logDebug("Next hop: %s" % link2) - - link3 = self.load(urlparse.urljoin("https://docs.google.com", link2), just_header=True) - self.logDebug("DL-Link: %s" % link3['location']) - - self.link = link3['location'] + for _i in xrange(2): + m = re.search(self.LINK_FREE_PATTERN, self.html) + + if m is None: + self.error(_("Free download link not found")) + + else: + link = html_unescape(m.group(1).decode('unicode-escape')) + if not urlparse.urlparse(link).scheme: + link = urlparse.urljoin("https://docs.google.com/", link) + + direct_link = self.directLink(link, False) + if not direct_link: + self.html = self.load(link, decode=True) + else: + self.link = direct_link + break getInfo = create_getInfo(GoogledriveCom) -- cgit v1.2.3