summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--module/plugins/hoster/GoogledriveCom.py45
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)