summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-05-26 01:25:05 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-05-26 01:27:31 +0200
commit7e65484b60890bbfa39aa7631343dcfb5c379cf9 (patch)
treedc7ca5a9edc93fb4b47738c7da6b070c4c5297ef /module/plugins/hoster
parentMerge pull request #1426 from immenz/dev_nitro (diff)
downloadpyload-7e65484b60890bbfa39aa7631343dcfb5c379cf9.tar.xz
[GoogledriveCom] Fixup
Diffstat (limited to 'module/plugins/hoster')
-rw-r--r--module/plugins/hoster/GoogledriveCom.py47
1 files changed, 20 insertions, 27 deletions
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<N>.*?)">'
OFFLINE_PATTERN = r'align="center"><p class="errorMessage"'
+ LINK_FREE_PATTERN = r'"([^"]+uc\?.*?)"'
+
def setup(self):
self.multiDL = True
@@ -36,32 +38,23 @@ class GoogledriveCom(SimpleHoster):
def handleFree(self, pyfile):
- 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"))
-
- 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"))
-
- 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)