summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-07-05 16:42:24 +0200
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-07-05 16:42:24 +0200
commit15362ebceaee1eb66920d4822d2faa947151e74a (patch)
tree5ee1b2203cf208d8fcf80b135ca4ebb70de00f90 /module/plugins/internal
parent[DailymotionCom] Default quality changed to "Highest" (diff)
downloadpyload-15362ebceaee1eb66920d4822d2faa947151e74a.tar.xz
[SimpleCrypter] Better inline docs + support for offline & temp.offline check
Diffstat (limited to 'module/plugins/internal')
-rw-r--r--module/plugins/internal/SimpleCrypter.py40
1 files changed, 29 insertions, 11 deletions
diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py
index 268efee86..2c024d738 100644
--- a/module/plugins/internal/SimpleCrypter.py
+++ b/module/plugins/internal/SimpleCrypter.py
@@ -26,34 +26,44 @@ from module.plugins.internal.SimpleHoster import replace_patterns, set_cookies
class SimpleCrypter(Crypter):
__name__ = "SimpleCrypter"
- __version__ = "0.08"
+ __version__ = "0.09"
__pattern__ = None
__type__ = "crypter"
__description__ = """Simple decrypter plugin"""
__author_name__ = ("stickell", "zoidberg")
__author_mail__ = ("l.stickell@yahoo.it", "zoidberg@mujmail.cz")
+
"""
- These patterns should be defined by each crypter:
+ 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+)'
+
+ TITLE_PATTERN: (optional) The group defined by 'title' should be the title
+ example: TITLE_PATTERN = r'<title>Files of: (?P<title>[^<]+) folder</title>'
+
+ OFFLINE_PATTERN: (optional) Checks if the file is yet available online
+ example: OFFLINE_PATTERN = r'File (deleted|not found)'
- LINK_PATTERN: group(1) must be a download link
- example: <div class="link"><a href="(http://speedload.org/\w+)
+ TEMP_OFFLINE_PATTERN: (optional) Checks if the file is temporarily offline
+ example: TEMP_OFFLINE_PATTERN = r'Server maintainance'
- 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
+ PAGES_PATTERN: The group defined by 'pages' must be the total number of pages
+ example: PAGES_PATTERN = r''
and a function:
- loadPage(self, page_n):
- must return the html of the page number 'page_n'
+ loadPage(self, page_n):
+ return the html of the page number 'page_n'
"""
- FILE_URL_REPLACEMENTS = []
+ URL_REPLACEMENTS = []
+
SH_COOKIES = True # or False or list of tuples [(domain, name, value)]
@@ -62,10 +72,12 @@ class SimpleCrypter(Crypter):
set_cookies(self.req.cj, self.SH_COOKIES)
def decrypt(self, pyfile):
- pyfile.url = replace_patterns(pyfile.url, self.FILE_URL_REPLACEMENTS)
+ pyfile.url = replace_patterns(pyfile.url, self.URL_REPLACEMENTS)
self.html = self.load(pyfile.url, decode=True)
+ self.checkOnline()
+
package_name, folder_name = self.getPackageNameAndFolder()
self.package_links = self.getLinks()
@@ -87,6 +99,12 @@ 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)