diff options
| author | 2013-09-07 19:53:41 +0200 | |
|---|---|---|
| committer | 2013-09-07 19:53:41 +0200 | |
| commit | f0ffe30d41cbe2df6fd4273fc527c1feff62708b (patch) | |
| tree | 5a5186a2af40095e9f0158d0d0311142750a505b /module/plugins | |
| parent | XFileSharingPro: improved DIRECT_LINK_PATTERN (diff) | |
| download | pyload-f0ffe30d41cbe2df6fd4273fc527c1feff62708b.tar.xz | |
SimpleCrypter: using a separated method to extract links.
Suggested in #257
Diffstat (limited to 'module/plugins')
| -rw-r--r-- | module/plugins/internal/SimpleCrypter.py | 15 | 
1 files changed, 12 insertions, 3 deletions
| diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 546b920e0..f0fe0b764 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -25,7 +25,7 @@ from module.utils import html_unescape  class SimpleCrypter(Crypter):      __name__ = "SimpleCrypter" -    __version__ = "0.05" +    __version__ = "0.06"      __pattern__ = None      __type__ = "crypter"      __description__ = """Base crypter plugin""" @@ -40,6 +40,8 @@ class SimpleCrypter(Crypter):      TITLE_PATTERN: (optional) the group defined by 'title' should be the title      example: <title>Files of: (?P<title>[^<]+) folder</title> +    If it's impossible to extract the links using the LINK_PATTERN only you can override the getLinks method. +      If the links are disposed on multiple pages you need to define a pattern:      PAGES_PATTERN: the group defined by 'pages' must be the total number of pages @@ -55,7 +57,7 @@ class SimpleCrypter(Crypter):          package_name, folder_name = self.getPackageNameAndFolder() -        self.package_links = re.findall(self.LINK_PATTERN, self.html) +        self.package_links = self.getLinks()          if hasattr(self, 'PAGES_PATTERN') and hasattr(self, 'loadPage'):              self.handleMultiPages() @@ -67,6 +69,13 @@ class SimpleCrypter(Crypter):          else:              self.fail('Could not extract any links') +    def getLinks(self): +        """ +        Returns the links extracted from self.html +        You should override this only if it's impossible to extract links using only the LINK_PATTERN. +        """ +        return re.findall(self.LINK_PATTERN, self.html) +      def getPackageNameAndFolder(self):          if hasattr(self, 'TITLE_PATTERN'):              m = re.search(self.TITLE_PATTERN, self.html) @@ -89,4 +98,4 @@ class SimpleCrypter(Crypter):          for p in range(2, pages + 1):              self.html = self.loadPage(p) -            self.package_links += re.findall(self.LINK_PATTERN, self.html) +            self.package_links += self.getLinks() | 
