diff options
Diffstat (limited to 'pyload/plugins/internal/SimpleCrypter.py')
| -rw-r--r-- | pyload/plugins/internal/SimpleCrypter.py | 43 | 
1 files changed, 25 insertions, 18 deletions
| diff --git a/pyload/plugins/internal/SimpleCrypter.py b/pyload/plugins/internal/SimpleCrypter.py index 454a95e84..6c5c9593f 100644 --- a/pyload/plugins/internal/SimpleCrypter.py +++ b/pyload/plugins/internal/SimpleCrypter.py @@ -2,30 +2,32 @@  import re -from pyload.plugins.base.Crypter import Crypter +from pyload.plugins.Crypter import Crypter  from pyload.plugins.internal.SimpleHoster import PluginParseError, replace_patterns, set_cookies -from pyload.utils import html_unescape +from pyload.utils import fixup, html_unescape  class SimpleCrypter(Crypter):      __name__ = "SimpleCrypter"      __type__ = "crypter" -    __version__ = "0.12" +    __version__ = "0.13"      __pattern__ = None      __description__ = """Simple decrypter plugin""" -    __author_name__ = ("stickell", "zoidberg", "Walter Purcaro") -    __author_mail__ = ("l.stickell@yahoo.it", "zoidberg@mujmail.cz", "vuolter@gmail.com") +    __authors__ = [("stickell", "l.stickell@yahoo.it"), +                   ("zoidberg", "zoidberg@mujmail.cz"), +                   ("Walter Purcaro", "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) The group defined by 'title' should be the folder name or the webpage title -        example: TITLE_PATTERN = r'<title>Files of: (?P<title>[^<]+) folder</title>' +      TITLE_PATTERN: (optional) group(1) should be the folder name or the webpage title +        example: TITLE_PATTERN = r'<title>Files of: ([^<]+) folder</title>'        OFFLINE_PATTERN: (optional) Checks if the file is yet available online          example: OFFLINE_PATTERN = r'File (deleted|not found)' @@ -39,8 +41,8 @@ class SimpleCrypter(Crypter):      If the links are splitted on multiple pages you can define the PAGES_PATTERN regex: -      PAGES_PATTERN: (optional) The group defined by 'pages' should be the number of overall pages containing the links -        example: PAGES_PATTERN = r'Pages: (?P<pages>\d+)' +      PAGES_PATTERN: (optional) group(1) should be the number of overall pages containing the links +        example: PAGES_PATTERN = r'Pages: (\d+)'      and its loadPage method: @@ -48,7 +50,7 @@ class SimpleCrypter(Crypter):            return the html of the page number page_n      """ - +    TITLE_REPLACEMENTS = [("&#?\w+;", fixup)]      URL_REPLACEMENTS = []      TEXT_ENCODING = False  #: Set to True or encoding name if encoding in http header is not correct @@ -110,23 +112,28 @@ class SimpleCrypter(Crypter):      def getPackageNameAndFolder(self):          if hasattr(self, 'TITLE_PATTERN'): -            m = re.search(self.TITLE_PATTERN, self.html) -            if m: -                name = folder = html_unescape(m.group('title').strip()) +            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('pages')) -        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): | 
