summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-05-29 01:53:28 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-05-29 01:53:28 +0200
commita51c92425e3b77b5a6b85babd29cc97411ee647c (patch)
treeee08aec5c3331159025c404ad287c581c2085cf8
parent[GooGl] Update (diff)
downloadpyload-a51c92425e3b77b5a6b85babd29cc97411ee647c.tar.xz
[SimpleDereferer] Handle direct link
-rw-r--r--module/plugins/crypter/GooGl.py2
-rw-r--r--module/plugins/internal/SimpleCrypter.py2
-rw-r--r--module/plugins/internal/SimpleDereferer.py30
-rw-r--r--module/plugins/internal/SimpleHoster.py6
4 files changed, 22 insertions, 18 deletions
diff --git a/module/plugins/crypter/GooGl.py b/module/plugins/crypter/GooGl.py
index 4cea66d2a..30e193b9d 100644
--- a/module/plugins/crypter/GooGl.py
+++ b/module/plugins/crypter/GooGl.py
@@ -9,7 +9,7 @@ class GooGl(SimpleDereferer):
__type__ = "crypter"
__version__ = "0.02"
- __pattern__ = r'https?://(?:www\.)?goo\.gl/(\w+/)?\w+'
+ __pattern__ = r'https?://(?:www\.)?goo\.gl/([a-zA-Z]+/)?\w+'
__description__ = """Goo.gl decrypter plugin"""
__license__ = "GPLv3"
diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py
index 48e1e0fab..b843a28f0 100644
--- a/module/plugins/internal/SimpleCrypter.py
+++ b/module/plugins/internal/SimpleCrypter.py
@@ -155,7 +155,7 @@ class SimpleCrypter(Crypter, SimpleHoster):
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]
+ return [html_unescape(l.strip().decode('unicode-escape')) for l in links]
def handlePages(self, pyfile):
diff --git a/module/plugins/internal/SimpleDereferer.py b/module/plugins/internal/SimpleDereferer.py
index 3a5f21900..022f006f2 100644
--- a/module/plugins/internal/SimpleDereferer.py
+++ b/module/plugins/internal/SimpleDereferer.py
@@ -11,7 +11,7 @@ from module.utils import html_unescape
class SimpleDereferer(Crypter):
__name__ = "SimpleDereferer"
__type__ = "crypter"
- __version__ = "0.12"
+ __version__ = "0.13"
__pattern__ = r'^unmatchable$'
__config__ = [] #@TODO: Remove in 0.4.10
@@ -43,22 +43,28 @@ class SimpleDereferer(Crypter):
COOKIES = True
+ def handleDirect(self, pyfile):
+ header = self.load(pyfile.url, just_header=True, decode=True)
+ if 'location' in header and header['location']:
+ self.link = header['location']
+
+
def decrypt(self, pyfile):
- link = getFileURL(self, pyfile.url)
+ self.handleDirect(pyfile)
- if not link:
+ if not self.link:
try:
- link = urllib.unquote(re.match(self.__pattern__, pyfile.url).group('LINK'))
+ self.link = urllib.unquote(re.match(self.__pattern__, pyfile.url).group('LINK'))
- except Exception:
+ except AttributeError:
self.prepare()
self.preload()
self.checkStatus()
- link = self.getLink()
+ self.link = self.getLink()
- if link.strip():
- self.urls = [link.strip()] #@TODO: Remove `.strip()` in 0.4.10
+ if self.link:
+ self.urls = [self.link]
elif not self.urls and not self.packages: #@TODO: Remove in 0.4.10
self.fail(_("No link grabbed"))
@@ -67,6 +73,7 @@ class SimpleDereferer(Crypter):
def prepare(self):
self.info = {}
self.html = ""
+ self.link = "" #@TODO: Move to hoster class in 0.4.10
self.req.setOption("timeout", 120)
@@ -90,8 +97,5 @@ class SimpleDereferer(Crypter):
def getLink(self):
- try:
- return html_unescape(re.search(self.LINK_PATTERN, self.html).group(1).decode('unicode-escape')) #@TODO: Move this check to plugin `load` method in 0.4.10
-
- except Exception:
- pass
+ link = re.search(self.LINK_PATTERN, self.html).group(1)
+ return html_unescape(link.strip().decode('unicode-escape')) #@TODO: Move this check to plugin `load` method in 0.4.10
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index 0a9986d4c..d362a9615 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -175,7 +175,7 @@ def getFileURL(self, url, follow_location=None):
if 'content-disposition' in header:
link = url
- elif 'location' in header and header['location'].strip():
+ elif 'location' in header and header['location']:
location = header['location']
if not urlparse.urlparse(location).scheme:
@@ -193,7 +193,7 @@ def getFileURL(self, url, follow_location=None):
else:
extension = os.path.splitext(urlparse.urlparse(url).path.split('/')[-1])[-1]
- if 'content-type' in header and header['content-type'].strip():
+ if 'content-type' in header and header['content-type']:
mimetype = header['content-type'].split(';')[0].strip()
elif extension:
@@ -509,7 +509,7 @@ class SimpleHoster(Hoster):
self.correctCaptcha()
- link = html_unescape(link.decode('unicode-escape')) #@TODO: Move this check to plugin `load` method in 0.4.10
+ link = html_unescape(link.strip().decode('unicode-escape')) #@TODO: Move this check to plugin `load` method in 0.4.10
if not urlparse.urlparse(link).scheme:
url_p = urlparse.urlparse(self.pyfile.url)