diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-10-19 04:48:07 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-10-19 04:48:07 +0200 |
commit | ffd38f027ed103f7b39ec78c6af0d182774950a4 (patch) | |
tree | e6d88b064a38bb44932674f32ac602efc786468b /module/plugins/hooks/XFileSharing.py | |
parent | Merge pull request #2054 from GammaC0de/patch-1 (diff) | |
download | pyload-ffd38f027ed103f7b39ec78c6af0d182774950a4.tar.xz |
Spare fixes
Diffstat (limited to 'module/plugins/hooks/XFileSharing.py')
-rw-r--r-- | module/plugins/hooks/XFileSharing.py | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/module/plugins/hooks/XFileSharing.py b/module/plugins/hooks/XFileSharing.py new file mode 100644 index 000000000..50068fc72 --- /dev/null +++ b/module/plugins/hooks/XFileSharing.py @@ -0,0 +1,128 @@ +# -*- coding: utf-8 -*- + +import re + +from module.plugins.internal.Addon import Addon + + +class XFileSharing(Addon): + __name__ = "XFileSharing" + __type__ = "hook" + __version__ = "0.46" + __status__ = "testing" + + __config__ = [("activated" , "bool", "Activated" , True ), + ("use_hoster_list" , "bool", "Load listed hosters only" , False), + ("use_crypter_list", "bool", "Load listed crypters only" , False), + ("use_builtin_list", "bool", "Load built-in plugin list" , True ), + ("hoster_list" , "str" , "Hoster list (comma separated)" , "" ), + ("crypter_list" , "str" , "Crypter list (comma separated)", "" )] + + __description__ = """Load XFileSharing based hosters and crypters which don't need a own plugin to run""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + regexp = {'hoster' : (r'https?://(?:www\.)?(?:\w+\.)*(?P<DOMAIN>(?:[\d.]+|[\w\-^_]{3,63}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', + r'https?://(?:[^/]+\.)?(?P<DOMAIN>%s)/(?:embed-)?\w+'), + 'crypter': (r'https?://(?:www\.)?(?:\w+\.)*(?P<DOMAIN>(?:[\d.]+|[\w\-^_]{3,63}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:user|folder)s?/\w+', + r'https?://(?:[^/]+\.)?(?P<DOMAIN>%s)/(?:user|folder)s?/\w+')} + + BUILTIN_HOSTERS = [#WORKING HOSTERS: + "ani-stream.com", "backin.net", "cloudsix.me", "eyesfile.ca", + "file4safe.com", "fileband.com", "filedwon.com", "fileparadox.in", + "filevice.com", "hostingbulk.com", "junkyvideo.com", "ravishare.com", + "ryushare.com", "salefiles.com", "sendmyway.com", "sharebeast.com", + "sharesix.com", "thefile.me", "verzend.be", "worldbytez.com", + "xvidstage.com", + #: NOT TESTED: + "101shared.com", "4upfiles.com", "filemaze.ws", "filenuke.com", + "linkzhost.com", "mightyupload.com", "rockdizfile.com", "sharerepo.com", + "shareswift.com", "uploadbaz.com", "uploadc.com", "vidbull.com", + "zalaa.com", "zomgupload.com", + #: NOT WORKING: + "amonshare.com", "banicrazy.info", "boosterking.com", "host4desi.com", + "laoupload.com", "rd-fs.com"] + BUILTIN_CRYPTERS = ["junocloud.me", "rapidfileshare.net"] + + + def activate(self): + self.load_pattern() + + + def load_pattern(self): + use_builtin_list = self.get_config('use_builtin_list') + + for type, plugin in (("hoster", "XFileSharing"), + ("crypter", "XFileSharingFolder")): + every_plugin = not self.get_config("use_%s_list" % type) + + if every_plugin: + self.log_info(_("Handling any %s I can!") % type) + pattern = self.regexp[type][0] + else: + plugins = self.get_config('%s_list' % type) + plugin_set = set(plugins.replace(' ', '').replace('\\', '').replace('|', ',').replace(';', ',').lower().split(',')) + + if use_builtin_list: + plugin_set |= set(x.lower() for x in getattr(self, "BUILTIN_%sS" % type.upper())) + + plugin_set -= set(('', u'')) + + if not plugin_set: + self.log_info(_("No %s to handle") % type) + self._unload(type, plugin) + return + + match_list = '|'.join(sorted(plugin_set)) + + len_match_list = len(plugin_set) + self.log_info(_("Handling %d %s%s: %s") % (len_match_list, + type, + "" if len_match_list == 1 else "s", + match_list.replace('|', ', '))) + + pattern = self.regexp[type][1] % match_list.replace('.', '\.') + + dict = self.pyload.pluginManager.plugins[type][plugin] + dict['pattern'] = pattern + dict['re'] = re.compile(pattern) + + self.log_debug("Loaded %s pattern: %s" % (type, pattern)) + + + def _unload(self, type, plugin): + dict = self.pyload.pluginManager.plugins[type][plugin] + dict['pattern'] = r'^unmatchable$' + dict['re'] = re.compile(dict['pattern']) + + + def deactivate(self): + # self.unload_hoster("BasePlugin") + for type, plugin in (("hoster", "XFileSharing"), + ("crypter", "XFileSharingFolder")): + self._unload(type, plugin) + + + def unload_hoster(self, hoster): + hdict = self.pyload.pluginManager.hosterPlugins[hoster] + if "new_name" in hdict and hdict['new_name'] == "XFileSharing": + if "module" in hdict: + hdict.pop('module', None) + + if "new_module" in hdict: + hdict.pop('new_module', None) + hdict.pop('new_name', None) + + return True + else: + return False + + + # def download_failed(self, pyfile): + # if pyfile.pluginname == "BasePlugin" \ + # and pyfile.hasStatus("failed") \ + # and not self.get_config('use_hoster_list') \ + # and self.unload_hoster("BasePlugin"): + # self.log_debug("Unloaded XFileSharing from BasePlugin") + # pyfile.setStatus("queued") |