diff options
Diffstat (limited to 'module')
| -rw-r--r-- | module/plugins/internal/SimpleCrypter.py | 21 | 
1 files changed, 14 insertions, 7 deletions
| diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 0b99feb42..3cd52d9f1 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -24,7 +24,7 @@ class SimpleCrypter(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+)' -      TITLE_PATTERN: (optional) The group defined by 'title' should be the title +      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>'        OFFLINE_PATTERN: (optional) Checks if the file is yet available online @@ -34,17 +34,18 @@ class SimpleCrypter(Crypter):          example: TEMP_OFFLINE_PATTERN = r'Server maintainance' -    If it's impossible to extract the links using the LINK_PATTERN only you can override the getLinks method. +    You can override the getLinks method if you need a more sophisticated way to extract the links. -    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 +    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+)' -    and a function: +    and its loadPage method: -      loadPage(self, page_n): -          return the html of the page number 'page_n' +      def loadPage(self, page_n): +          return the html of the page number page_n      """      URL_REPLACEMENTS = [] @@ -56,6 +57,7 @@ class SimpleCrypter(Crypter):          if isinstance(self.SH_COOKIES, list):              set_cookies(self.req.cj, self.SH_COOKIES) +      def decrypt(self, pyfile):          pyfile.url = replace_patterns(pyfile.url, self.URL_REPLACEMENTS) @@ -77,6 +79,7 @@ class SimpleCrypter(Crypter):          else:              self.fail('Could not extract any links') +      def getLinks(self):          """          Returns the links extracted from self.html @@ -84,12 +87,14 @@ class SimpleCrypter(Crypter):          """          return re.findall(self.LINK_PATTERN, self.html) +      def checkOnline(self):          if hasattr(self, "OFFLINE_PATTERN") and re.search(self.OFFLINE_PATTERN, self.html):              self.offline()          elif hasattr(self, "TEMP_OFFLINE_PATTERN") and re.search(self.TEMP_OFFLINE_PATTERN, self.html):              self.tempOffline() +      def getPackageNameAndFolder(self):          if hasattr(self, 'TITLE_PATTERN'):              m = re.search(self.TITLE_PATTERN, self.html) @@ -103,6 +108,7 @@ class SimpleCrypter(Crypter):          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: @@ -114,5 +120,6 @@ class SimpleCrypter(Crypter):              self.html = self.loadPage(p)              self.package_links += self.getLinks() +      def parseError(self, msg):          raise PluginParseError(msg) | 
