summaryrefslogtreecommitdiffstats
path: root/module/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins')
-rw-r--r--module/plugins/hoster/GoogledriveCom.py47
-rw-r--r--module/plugins/internal/SimpleCrypter.py10
-rw-r--r--module/plugins/internal/SimpleHoster.py25
3 files changed, 41 insertions, 41 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)
diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py
index 46ccb11b5..48e1e0fab 100644
--- a/module/plugins/internal/SimpleCrypter.py
+++ b/module/plugins/internal/SimpleCrypter.py
@@ -5,13 +5,13 @@ import urlparse
from module.plugins.Crypter import Crypter
from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, replace_patterns, set_cookies
-from module.utils import fixup
+from module.utils import fixup, html_unescape
class SimpleCrypter(Crypter, SimpleHoster):
__name__ = "SimpleCrypter"
__type__ = "crypter"
- __version__ = "0.45"
+ __version__ = "0.46"
__pattern__ = r'^unmatchable$'
__config__ = [("use_subfolder" , "bool", "Save package to subfolder" , True), #: Overrides core.config['general']['folder_per_package']
@@ -152,8 +152,10 @@ class SimpleCrypter(Crypter, SimpleHoster):
url_p = urlparse.urlparse(self.pyfile.url)
baseurl = "%s://%s" % (url_p.scheme, url_p.netloc)
- return [(urlparse.urljoin(baseurl, link) if not urlparse.urlparse(link).scheme else link).decode('unicode-escape') \
- for link in re.findall(self.LINK_PATTERN, self.html)]
+ links = [urlparse.urljoin(baseurl, link) if not urlparse.urlparse(link).scheme else link \
+ for link in re.findall(self.LINK_PATTERN, self.html)]
+
+ return [html_unescape(l.decode('unicode-escape')) for l in links]
def handlePages(self, pyfile):
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index 11c6c64f2..d3c269548 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -14,7 +14,7 @@ from module.network.HTTPRequest import BadHeader
from module.network.RequestFactory import getURL
from module.plugins.Hoster import Hoster
from module.plugins.Plugin import Fail, Retry
-from module.utils import fixup, fs_encode, parseFileSize
+from module.utils import fixup, fs_encode, html_unescape, parseFileSize
#@TODO: Adapt and move to PyFile in 0.4.10
@@ -239,7 +239,7 @@ def secondsToMidnight(gmt=0):
class SimpleHoster(Hoster):
__name__ = "SimpleHoster"
__type__ = "hoster"
- __version__ = "1.48"
+ __version__ = "1.49"
__pattern__ = r'^unmatchable$'
__config__ = [("use_premium", "bool", "Use premium account if available" , True),
@@ -504,15 +504,19 @@ class SimpleHoster(Hoster):
def downloadLink(self, link, disposition=True):
- if link and isinstance(link, basestring):
- self.correctCaptcha()
+ if not link or not isinstance(link, basestring):
+ return
+
+ self.correctCaptcha()
- if not urlparse.urlparse(link).scheme:
- url_p = urlparse.urlparse(self.pyfile.url)
- baseurl = "%s://%s" % (url_p.scheme, url_p.netloc)
- link = urlparse.urljoin(baseurl, link)
+ link = html_unescape(link.decode('unicode-escape')) #@TODO: Move this check to plugin `load` method
- self.download(link, ref=False, disposition=disposition)
+ if not urlparse.urlparse(link).scheme:
+ url_p = urlparse.urlparse(self.pyfile.url)
+ baseurl = "%s://%s" % (url_p.scheme, url_p.netloc)
+ link = urlparse.urljoin(baseurl, link)
+
+ self.download(link, ref=False, disposition=disposition)
def checkFile(self, rules={}):
@@ -794,7 +798,8 @@ class SimpleHoster(Hoster):
return size <= traffic
- def getConfig(self, option, default=''): #@TODO: Remove in 0.4.10
+ #@TODO: Remove in 0.4.10
+ def getConfig(self, option, default=''):
"""getConfig with default value - sublass may not implements all config options"""
try:
return self.getConf(option)