summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
Diffstat (limited to 'module')
-rw-r--r--module/plugins/internal/SimpleCrypter.py20
-rw-r--r--module/plugins/internal/SimpleHoster.py29
2 files changed, 28 insertions, 21 deletions
diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py
index d69995402..43e8b46cb 100644
--- a/module/plugins/internal/SimpleCrypter.py
+++ b/module/plugins/internal/SimpleCrypter.py
@@ -18,11 +18,12 @@ class SimpleCrypter(Crypter):
__author_name__ = ("stickell", "zoidberg", "Walter Purcaro")
__author_mail__ = ("l.stickell@yahoo.it", "zoidberg@mujmail.cz", "vuolter@gmail.com")
+
"""
Following patterns should be defined by each crypter:
LINK_PATTERN: group(1) must be a download link or a regex to catch more links
- example: LINK_PATTERN = r'<div class="link"><a href="(http://speedload.org/\w+)'
+ example: LINK_PATTERN = r'<div class="link"><a href="(.+?)"'
TITLE_PATTERN: (optional) group(1) should be the folder name or the webpage title
example: TITLE_PATTERN = r'<title>Files of: ([^<]+) folder</title>'
@@ -48,7 +49,6 @@ class SimpleCrypter(Crypter):
return the html of the page number page_n
"""
-
TITLE_REPLACEMENTS = [("&#?\w+;", fixup)]
URL_REPLACEMENTS = []
@@ -111,24 +111,28 @@ class SimpleCrypter(Crypter):
def getPackageNameAndFolder(self):
if hasattr(self, 'TITLE_PATTERN'):
- m = re.search(self.TITLE_PATTERN, self.html)
- if m:
+ try:
+ m = re.search(self.TITLE_PATTERN, self.html)
name = replace_patterns(m.group(1).strip(), self.TITLE_REPLACEMENTS)
folder = html_unescape(name)
+ except:
+ pass
+ else:
self.logDebug("Found name [%s] and folder [%s] in package info" % (name, folder))
return name, folder
name = self.pyfile.package().name
folder = self.pyfile.package().folder
self.logDebug("Package info not found, defaulting to pyfile name [%s] and folder [%s]" % (name, folder))
+
return name, folder
def handleMultiPages(self):
- pages = re.search(self.PAGES_PATTERN, self.html)
- if pages:
- pages = int(pages.group(1))
- else:
+ try:
+ m = re.search(self.PAGES_PATTERN, self.html)
+ pages = int(m.group(1))
+ except:
pages = 1
for p in xrange(2, pages + 1):
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
index 6ad8398bb..238c98b05 100644
--- a/module/plugins/internal/SimpleHoster.py
+++ b/module/plugins/internal/SimpleHoster.py
@@ -112,9 +112,8 @@ def parseFileInfo(self, url='', html=''):
self.FILE_SIZE_REPLACEMENTS)
info['size'] = parseFileSize(size)
elif isinstance(info['size'], basestring):
- if 'units' in info:
- info['size'] += info['units']
- info['size'] = parseFileSize(info['size'])
+ unit = info['units'] if 'units' in info else None
+ info['size'] = parseFileSize(info['size'], unit)
if hasattr(self, "file_info"):
self.file_info = info
@@ -161,6 +160,7 @@ class SimpleHoster(Hoster):
__author_name__ = ("zoidberg", "stickell", "Walter Purcaro")
__author_mail__ = ("zoidberg@mujmail.cz", "l.stickell@yahoo.it", "vuolter@gmail.com")
+
"""
Following patterns should be defined by each hoster:
@@ -184,8 +184,11 @@ class SimpleHoster(Hoster):
Instead overriding handleFree and handlePremium methods now you can define patterns for direct download:
- LINK_FREE_PATTERN: (optional) Get direct link for free download
- LINK_PREMIUM_PATTERN: (optional) Get direct link for premium download
+ LINK_FREE_PATTERN: (optional) group(1) should be the direct link for free download
+ example: LINK_FREE_PATTERN = r'<div class="link"><a href="(.+?)"'
+
+ LINK_PREMIUM_PATTERN: (optional) group(1) should be the direct link for premium download
+ example: LINK_PREMIUM_PATTERN = r'<div class="link"><a href="(.+?)"'
"""
FILE_NAME_REPLACEMENTS = [("&#?\w+;", fixup)]
@@ -264,11 +267,11 @@ class SimpleHoster(Hoster):
if not hasattr(self, 'LINK_FREE_PATTERN'):
self.fail("Free download not implemented")
- m = re.search(self.LINK_FREE_PATTERN, self.html)
- if m is None:
- self.parseError("Free download link not found")
-
try:
+ m = re.search(self.LINK_FREE_PATTERN, self.html)
+ if m is None:
+ self.parseError("Free download link not found")
+
link = m.group(1)
except Exception, e:
self.logError(str(e))
@@ -280,11 +283,11 @@ class SimpleHoster(Hoster):
if not hasattr(self, 'LINK_PREMIUM_PATTERN'):
self.fail("Premium download not implemented")
- m = re.search(self.LINK_PREMIUM_PATTERN, self.html)
- if m is None:
- self.parseError("Premium download link not found")
-
try:
+ m = re.search(self.LINK_PREMIUM_PATTERN, self.html)
+ if m is None:
+ self.parseError("Premium download link not found")
+
link = m.group(1)
except Exception, e:
self.logError(str(e))