diff options
-rw-r--r-- | module/plugins/Plugin.py | 12 | ||||
-rw-r--r-- | module/plugins/accounts/RapidfileshareNet.py | 2 | ||||
-rw-r--r-- | module/plugins/captcha/captcha.py | 15 | ||||
-rw-r--r-- | module/plugins/crypter/EasybytezComFolder.py | 2 | ||||
-rw-r--r-- | module/plugins/crypter/TusfilesNetFolder.py | 2 | ||||
-rw-r--r-- | module/plugins/crypter/XFileSharingProFolder.py | 22 | ||||
-rw-r--r-- | module/plugins/hooks/XFileSharingPro.py | 82 | ||||
-rw-r--r-- | module/plugins/hoster/UploadedTo.py | 4 | ||||
-rw-r--r-- | module/plugins/internal/SimpleCrypter.py | 2 | ||||
-rw-r--r-- | module/plugins/internal/XFSPCrypter.py | 39 |
10 files changed, 127 insertions, 55 deletions
diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py index fa1d2c3b1..d17776485 100644 --- a/module/plugins/Plugin.py +++ b/module/plugins/Plugin.py @@ -335,9 +335,9 @@ class Plugin(Base): img = self.load(url, get=get, post=post, cookies=cookies) id = ("%.2f" % time())[-6:].replace(".", "") - temp_file = open(join("tmp", "tmpCaptcha_%s_%s.%s" % (self.__name__, id, imgtype)), "wb") - temp_file.write(img) - temp_file.close() + tmpCaptcha = open(join("tmp", "tmpCaptcha_%s_%s.%s" % (self.__name__, id, imgtype)), "wb") + tmpCaptcha.write(img) + tmpCaptcha.close() has_plugin = self.__name__ in self.core.pluginManager.captchaPlugins @@ -351,10 +351,10 @@ class Plugin(Base): if self.pyfile.abort: raise Abort ocr = Ocr() - result = ocr.get_captcha(temp_file.name) + result = ocr.get_captcha(tmpCaptcha.name) else: captchaManager = self.core.captchaManager - task = captchaManager.newTask(img, imgtype, temp_file.name, result_type) + task = captchaManager.newTask(img, imgtype, tmpCaptcha.name, result_type) self.cTask = task captchaManager.handleCaptcha(task) @@ -378,7 +378,7 @@ class Plugin(Base): if not self.core.debug: try: - remove(temp_file.name) + remove(tmpCaptcha.name) except: pass diff --git a/module/plugins/accounts/RapidfileshareNet.py b/module/plugins/accounts/RapidfileshareNet.py index 0b021aea7..99a4af98b 100644 --- a/module/plugins/accounts/RapidfileshareNet.py +++ b/module/plugins/accounts/RapidfileshareNet.py @@ -16,4 +16,4 @@ class RapidfileshareNet(XFSPAccount): HOSTER_URL = "http://www.rapidfileshare.net/" TRAFFIC_LEFT_PATTERN = r'>Traffic available today:</TD><TD><label for="name">\s*(?P<S>[\d.,]+)\s*(?:(?P<U>[\w^_]+)\s*)?</label></TD></TR>' - + diff --git a/module/plugins/captcha/captcha.py b/module/plugins/captcha/captcha.py index b3d4bd57e..fb85d8996 100644 --- a/module/plugins/captcha/captcha.py +++ b/module/plugins/captcha/captcha.py @@ -51,28 +51,25 @@ class OCR(object): self.logger.debug("Tesseract ReturnCode %s Output: %s" % (popen.returncode, output)) def run_tesser(self, subset=False, digits=True, lowercase=True, uppercase=True): - #self.logger.debug("create tmp tif") + #tmpTif = tempfile.NamedTemporaryFile(suffix=".tif") + tmpTif = open(join("tmp", "tmpTif_%s.tif" % self.__name__), "wb") + tmpTif.close() - #tmp = tempfile.NamedTemporaryFile(suffix=".tif") - tmp = open(join("tmp", "tmpTif_%s.tif" % self.__name__), "wb") - tmp.close() - #self.logger.debug("create tmp txt") #tmpTxt = tempfile.NamedTemporaryFile(suffix=".txt") tmpTxt = open(join("tmp", "tmpTxt_%s.txt" % self.__name__), "wb") tmpTxt.close() self.logger.debug("save tiff") - self.image.save(tmp.name, 'TIFF') + self.image.save(tmpTif.name, 'TIFF') if os.name == "nt": tessparams = [join(pypath, "tesseract", "tesseract.exe")] else: tessparams = ["tesseract"] - tessparams.extend( [abspath(tmp.name), abspath(tmpTxt.name).replace(".txt", "")] ) + tessparams.extend( [abspath(tmpTif.name), abspath(tmpTxt.name).replace(".txt", "")] ) if subset and (digits or lowercase or uppercase): - #self.logger.debug("create temp subset config") #tmpSub = tempfile.NamedTemporaryFile(suffix=".subset") tmpSub = open(join("tmp", "tmpSub_%s.subset" % self.__name__), "wb") tmpSub.write("tessedit_char_whitelist ") @@ -99,7 +96,7 @@ class OCR(object): self.logger.debug(self.result_captcha) try: - os.remove(tmp.name) + os.remove(tmpTif.name) os.remove(tmpTxt.name) if subset and (digits or lowercase or uppercase): os.remove(tmpSub.name) diff --git a/module/plugins/crypter/EasybytezComFolder.py b/module/plugins/crypter/EasybytezComFolder.py index 0b73a10ae..c80b6cd61 100644 --- a/module/plugins/crypter/EasybytezComFolder.py +++ b/module/plugins/crypter/EasybytezComFolder.py @@ -15,7 +15,7 @@ class EasybytezComFolder(SimpleCrypter): __authors__ = [("stickell", "l.stickell@yahoo.it")] - URL_REPLACEMENTS = [(__pattern__, r"http://www.easybytez.com/users/\g<ID>?per_page=10000")] + URL_REPLACEMENTS = [(__pattern__, r'http://www.easybytez.com/users/\g<ID>?per_page=10000')] LINK_PATTERN = r'<td><a href="(http://www\.easybytez\.com/\w+)" target="_blank">.+(?:</a>)?</td>' TITLE_PATTERN = r'<Title>Files of \d+: (.+) folder</Title>' diff --git a/module/plugins/crypter/TusfilesNetFolder.py b/module/plugins/crypter/TusfilesNetFolder.py index a6e76adb8..1d804c2a8 100644 --- a/module/plugins/crypter/TusfilesNetFolder.py +++ b/module/plugins/crypter/TusfilesNetFolder.py @@ -12,7 +12,7 @@ class TusfilesNetFolder(SimpleCrypter): __type__ = "crypter" __version__ = "0.03" - __pattern__ = r'https?://(?:www\.)?tusfiles\.net/go/(?P<ID>\w+)/?' + __pattern__ = r'https?://(?:www\.)?tusfiles\.net/go/(?P<ID>\w+)' __description__ = """Tusfiles.net folder decrypter plugin""" __license__ = "GPLv3" diff --git a/module/plugins/crypter/XFileSharingProFolder.py b/module/plugins/crypter/XFileSharingProFolder.py new file mode 100644 index 000000000..f3003e2aa --- /dev/null +++ b/module/plugins/crypter/XFileSharingProFolder.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- + +import re + +from module.plugins.internal.XFSPCrypter import XFSPCrypter + + +class XFileSharingProFolder(XFSPCrypter): + __name__ = "XFileSharingProFolder" + __type__ = "crypter" + __version__ = "0.01" + + __pattern__ = r'^unmatchable$' + + __description__ = """XFileSharingPro dummy folder decrypter plugin for hook""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + def setup(self): + self.__pattern__ = self.core.pluginManager.crypterPlugins[self.__name__]['pattern'] + self.HOSTER_NAME = re.match(self.__pattern__, self.pyfile.url).group(1).lower() diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index f5d40dd62..62a5791b7 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -8,15 +8,18 @@ from module.plugins.Hook import Hook class XFileSharingPro(Hook): __name__ = "XFileSharingPro" __type__ = "hook" - __version__ = "0.15" + __version__ = "0.16" __config__ = [("activated", "bool", "Activated", True), - ("match", "Always;Always except excluded;Listed only", "Hoster match", "Always except excluded"), - ("load_default", "bool", "Include built-in hoster list", True), + ("match_hoster", "Always;Always except excluded;Listed only", "Hoster match", "Always except excluded"), + ("match_crypter", "Always;Always except excluded;Listed only", "Crypter match", "Always except excluded"), + ("load_default", "bool", "Include built-in lists", True), ("include_hosters", "str", "Include hosters (comma separated)", ""), - ("exclude_hosters", "str", "Exclude hosters (comma separated)", "")] + ("exclude_hosters", "str", "Exclude hosters (comma separated)", ""), + ("include_crypters", "str", "Include crypters (comma separated)", ""), + ("exclude_crypters", "str", "Exclude crypters (comma separated)", "")] - __description__ = """Load XFileSharingPro based hosters which don't need a own plugin to work fine""" + __description__ = """Load hosters and crypter, based upon XFileSharingPro, which don't need a own plugin to work fine""" __license__ = "GPLv3" __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), ("Walter Purcaro", "vuolter@gmail.com")] @@ -33,6 +36,7 @@ class XFileSharingPro(Hook): "vidbull.com", "zalaa.com", "zomgupload.com", #NOT WORKING: "amonshare.com", "banicrazy.info", "boosterking.com", "host4desi.com", "laoupload.com", "rd-fs.com"] + CRYPTER_LIST = [] def pluginConfigChanged(self, plugin, name, value): @@ -45,41 +49,48 @@ class XFileSharingPro(Hook): def loadPattern(self): - include_hosters = self.getConfigSet('include_hosters') - exclude_hosters = self.getConfigSet('exclude_hosters') + regex = {'hoster' = (r'https?://(?!(?:www\.)?(?:%s))(?:www\.)?([\w^_]+(?:\.[a-zA-Z]{2,})+(?:\:\d+)?)/(?:embed-)?\w{12}', + r'https?://(?:[^/]+\.)?(%s)/(?:embed-)?\w{12}'), + 'crypter' = (r'https?://(?!(?:www\.)?(?:%s))(?:www\.)?([\w^_]+(?:\.[a-zA-Z]{2,})+(?:\:\d+)?)/(?:user|folder)s?/\w+', + r'https?://(?:[^/]+\.)?(%s)/(?:user|folder)s?/\w+')} + + for type, plugin in (("hoster", "XFileSharingPro"), ("crypter", "XFileSharingProFolder")): + match = self.getConfig('match_%ss' % type) + include_set = self.getConfigSet('include_%ss' % type) + exclude_set = self.getConfigSet('exclude_%ss' % type) + + if match != "Listed only": + if match == "Always": + match_list = "" + else: + hoster_list = exclude_set - set(('', u'')) + match_list = '|'.join(sorted(hoster_list)) + self.logDebug("Excluding %d %ss" % (len(hoster_list), type), match_list.replace('|', ', ')) + + regexp = regex[type][0] % match_list.replace('.', '\.') - if self.getConfig("match") != "Listed only": - if self.getConfig("match") == "Always": - match_list = "" else: - hoster_list = exclude_hosters - set(('', u'')) - match_list = '|'.join(sorted(hoster_list)) - self.logDebug("Excluding %d hosters" % len(hoster_list), match_list.replace('|', ', ')) - - regexp = r'https?://(?!(?:www\.)?(?:%s))(?:www\.)?([\w^_]+(?:\.[a-zA-Z]{2,})+(?:\:\d+)?)/(?:embed-)?\w{12}' % match_list.replace('.', '\.') + hoster_list = include_set - else: - hoster_list = include_hosters + if self.getConfig('load_default'): + hoster_list |= set(getattr(self, "%s_LIST" % type.upper())) - if self.getConfig('load_default'): - hoster_list |= set(self.HOSTER_LIST) + hoster_list -= exclude_set + hoster_list -= set(('', u'')) - hoster_list -= exclude_hosters - hoster_list -= set(('', u'')) + if not hoster_list: + self.unload() + return - if not hoster_list: - self.unload() - return - - match_list = '|'.join(sorted(hoster_list)) - self.logDebug("Handling %d hosters" % len(hoster_list), match_list.replace('|', ', ')) + match_list = '|'.join(sorted(hoster_list)) + self.logDebug("Handling %d %ss" % (len(hoster_list), type), match_list.replace('|', ', ')) - regexp = r'https?://(?:[^/]*\.)?(%s)/(?:embed-)?\w{12}' % match_list.replace('.', '\.') + regexp = regex[type][1] % match_list.replace('.', '\.') - dict = self.core.pluginManager.hosterPlugins['XFileSharingPro'] - dict['pattern'] = regexp - dict['re'] = re.compile(regexp) - self.logDebug("Pattern loaded") + dict = self.core.pluginManager.plugins[type][plugin] + dict['pattern'] = regexp + dict['re'] = re.compile(regexp) + self.logDebug("Pattern loaded for %ss" % type) def getConfigSet(self, option): @@ -89,6 +100,7 @@ class XFileSharingPro(Hook): def unload(self): regexp = r'^unmatchable$' - dict = self.core.pluginManager.hosterPlugins['XFileSharingPro'] - dict['pattern'] = regexp - dict['re'] = re.compile(regexp) + for type, plugin in (("hoster", "XFileSharingPro"), ("crypter", "XFileSharingProFolder")): + dict = self.core.pluginManager.plugins[type][plugin] + dict['pattern'] = regexp + dict['re'] = re.compile(regexp) diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py index 0affffbb9..73a903902 100644 --- a/module/plugins/hoster/UploadedTo.py +++ b/module/plugins/hoster/UploadedTo.py @@ -94,7 +94,7 @@ def getInfo(urls): class UploadedTo(Hoster): __name__ = "UploadedTo" __type__ = "hoster" - __version__ = "0.73" + __version__ = "0.74" __pattern__ = r'https?://(?:www\.)?(uploaded\.(to|net)|ul\.to)(/file/|/?\?id=|.*?&id=|/)(?P<ID>\w+)' @@ -219,7 +219,7 @@ class UploadedTo(Hoster): self.retry() elif "limit-parallel" in result: self.fail("Cannot download in parallel") - elif self.DL_LIMIT_PATTERN in result: # limit-dl + elif "limit-dl" in result or self.DL_LIMIT_PATTERN in result: # limit-dl self.setWait(3 * 60 * 60, True) self.wait() self.retry() diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 8139d661d..73329ed65 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -51,6 +51,8 @@ class SimpleCrypter(Crypter): return the html of the page number page_n """ + LINK_PATTERN = None + TITLE_REPLACEMENTS = [("&#?\w+;", fixup)] URL_REPLACEMENTS = [] diff --git a/module/plugins/internal/XFSPCrypter.py b/module/plugins/internal/XFSPCrypter.py new file mode 100644 index 000000000..4c5fff4f3 --- /dev/null +++ b/module/plugins/internal/XFSPCrypter.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- + +from module.plugins.internal.SimpleCrypter import SimpleCrypter + + +class XFSPCrypter(SimpleCrypter): + __name__ = "XFSPCrypter" + __type__ = "crypter" + __version__ = "0.01" + + __pattern__ = None + + __description__ = """XFileSharingPro decrypter plugin""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_NAME = None + + URL_REPLACEMENTS = [(r'[?/&]+$', r''), (r'(.+/[^?]*)$', r'\1?'), (r'$', r'&per_page=10000')] + + COOKIES = [(HOSTER_NAME, "lang", "english")] + + LINK_PATTERN = None + TITLE_PATTERN = r'<[tT]itle>.*?\: (.+) folder</[tT]itle>' + + OFFLINE_PATTERN = r'>\s*\w+ (Not Found|file (was|has been) removed)' + TEMP_OFFLINE_PATTERN = r'>\s*\w+ server (is in )?(maintenance|maintainance)' + + + def prepare(self): + if not self.HOSTER_NAME: + self.fail("Missing HOSTER_NAME") + + if not self.LINK_PATTERN: + pattern = r'<a href="(.+?)" target="_blank">.+?(?:</a>)?\s*</(?:td|TD)>' + self.LINK_PATTERN = pattern % self.HOSTER_NAME + + super(XFSPCrypter, self).prepare() |