diff options
Diffstat (limited to 'module')
-rw-r--r-- | module/plugins/accounts/XFileSharingPro.py | 26 | ||||
-rw-r--r-- | module/plugins/crypter/XFileSharingFolder.py | 49 | ||||
-rw-r--r-- | module/plugins/hooks/XFileSharing.py | 126 | ||||
-rw-r--r-- | module/plugins/hoster/XFileSharing.py | 51 |
4 files changed, 98 insertions, 154 deletions
diff --git a/module/plugins/accounts/XFileSharingPro.py b/module/plugins/accounts/XFileSharingPro.py deleted file mode 100644 index 1696042d6..000000000 --- a/module/plugins/accounts/XFileSharingPro.py +++ /dev/null @@ -1,26 +0,0 @@ -# -*- coding: utf-8 -*- - -from module.plugins.internal.XFSAccount import XFSAccount - - -class XFileSharing(XFSAccount): - __name__ = "XFileSharing" - __type__ = "account" - __version__ = "0.11" - __status__ = "testing" - - __description__ = """XFileSharing multi-purpose account plugin""" - __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - - - PLUGIN_DOMAIN = None - - - def signin(self, user, password, data): - try: - return super(XFileSharing, self).signin(user, password, data) - - except Fail: - self.PLUGIN_URL = self.PLUGIN_URL.replace("www.", "") - return super(XFileSharing, self).signin(user, password, data) diff --git a/module/plugins/crypter/XFileSharingFolder.py b/module/plugins/crypter/XFileSharingFolder.py index 6341e9895..4f08e63df 100644 --- a/module/plugins/crypter/XFileSharingFolder.py +++ b/module/plugins/crypter/XFileSharingFolder.py @@ -8,10 +8,9 @@ from module.plugins.internal.XFSCrypter import XFSCrypter, create_getInfo class XFileSharingFolder(XFSCrypter): __name__ = "XFileSharingFolder" __type__ = "crypter" - __version__ = "0.19" + __version__ = "0.20" __status__ = "testing" - # __pattern__ = r'https?://(?:www\.)?(?:\w+\.)*(?P<DOMAIN>(?:[\d.]+|[\w\-^_]{3,63}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:user|folder)s?/\w+' __pattern__ = r'^unmatchable$' __config__ = [("activated" , "bool", "Activated" , True), ("use_subfolder" , "bool", "Save package to subfolder" , True), @@ -28,48 +27,30 @@ class XFileSharingFolder(XFSCrypter): def init(self): - super(XFileSharingFolder, self).init() - self.__pattern__ = self.pyload.pluginManager.crypterPlugins[self.classname]['pattern'] self.PLUGIN_DOMAIN = re.match(self.__pattern__, self.pyfile.url).group("DOMAIN").lower() - self.PLUGIN_NAME = "".join(part.capitalize() for part in re.split(r'(\.|\d+|-)', self.PLUGIN_DOMAIN) if part != '.') - + self.PLUGIN_NAME = "".join(part.capitalize() for part in re.split(r'\.|\d+|-', self.PLUGIN_DOMAIN) if part != '.') - def _setup(self): - account_name = self.classname if not self.account or self.account.PLUGIN_DOMAIN is None else self.PLUGIN_NAME - self.chunk_limit = 1 - self.multiDL = True + #@TODO: Recheck in 0.4.10 + def setup_base(self): if self.account: - self.req = self.pyload.requestFactory.getRequest(accountname, self.account.user) - self.premium = self.account.premium - self.resume_download = self.premium + self.req = self.pyload.requestFactory.getRequest(self.PLUGIN_NAME, self.account.user) + self.premium = self.account.info['data']['premium'] #@NOTE: Avoid one unnecessary get_info call by `self.account.premium` here else: - self.req = self.pyload.requestFactory.getRequest(account_name) - self.premium = False - self.resume_download = False - - - def load_account(self): - if self.req: - self.req.close() + self.req = self.pyload.requestFactory.getRequest(self.classname) + self.premium = False - if not self.account: - self.account = self.pyload.accountManager.getAccountPlugin(self.PLUGIN_NAME) + super(SimpleCrypter, self).setup_base() - if not self.account: - self.account = self.pyload.accountManager.getAccountPlugin(self.classname) - if self.account: - if not self.account.PLUGIN_DOMAIN: - self.account.PLUGIN_DOMAIN = self.PLUGIN_DOMAIN - - if not self.account.user: #@TODO: Move to `Account` in 0.4.10 - self.account.user = self.account.select()[0] - - if not self.account.logged: - self.account = False + #@TODO: Recheck in 0.4.10 + def load_account(self): + class_name = self.classname + self.__class__.__name__ = self.PLUGIN_NAME + super(XFileSharingFolder, self).load_account() + self.__class__.__name__ = class_name getInfo = create_getInfo(XFileSharingFolder) diff --git a/module/plugins/hooks/XFileSharing.py b/module/plugins/hooks/XFileSharing.py index 50068fc72..2677fbd04 100644 --- a/module/plugins/hooks/XFileSharing.py +++ b/module/plugins/hooks/XFileSharing.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- +import inspect import re from module.plugins.internal.Addon import Addon @@ -8,7 +9,7 @@ from module.plugins.internal.Addon import Addon class XFileSharing(Addon): __name__ = "XFileSharing" __type__ = "hook" - __version__ = "0.46" + __version__ = "0.48" __status__ = "testing" __config__ = [("activated" , "bool", "Activated" , True ), @@ -18,15 +19,15 @@ class XFileSharing(Addon): ("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""" + __description__ = """Load XFileSharing hosters and crypters which don't need a own plugin""" __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+')} + regexp = {'hoster' : (r'(?:https?://(?:www\.)?)(?!%s)(?:\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\.)?)(?!%s)(?:\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", @@ -47,82 +48,81 @@ class XFileSharing(Addon): def activate(self): - self.load_pattern() - + for type, plugin in (("hoster" , "XFileSharing"), + ("crypter", "XFileSharingFolder")): + self._load(type, plugin) - def load_pattern(self): - use_builtin_list = self.get_config('use_builtin_list') - for type, plugin in (("hoster", "XFileSharing"), + def deactivate(self): + for type, plugin in (("hoster" , "XFileSharing"), ("crypter", "XFileSharingFolder")): - every_plugin = not self.get_config("use_%s_list" % type) + self._unload(type, plugin) - 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())) + def get_pattern(self, type, plugin): + if self.get_config("use_%s_list" % type): + plugin_list = self.get_config('%s_list' % type) + plugin_list = plugin_list.replace(' ', '').replace('\\', '') + plugin_list = plugin_list.replace('|', ',').replace(';', ',') + plugin_list = plugin_list.lower().split(',') - plugin_set -= set(('', u'')) + plugin_set = set(plugin_list) - if not plugin_set: - self.log_info(_("No %s to handle") % type) - self._unload(type, plugin) - return + if self.get_config('use_builtin_list'): + builtin_list = getattr(self, "BUILTIN_%sS" % type.upper()) + plugin_set.update(builtin_list) - match_list = '|'.join(sorted(plugin_set)) + plugin_set.difference_update(('', u'')) - 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('|', ', '))) + if not plugin_set: + self.log_info(_("No %s to handle") % type) + return - pattern = self.regexp[type][1] % match_list.replace('.', '\.') + match_list = '|'.join(sorted(plugin_set)).replace('.', '\.') + pattern = self.regexp[type][1] % match_list - dict = self.pyload.pluginManager.plugins[type][plugin] - dict['pattern'] = pattern - dict['re'] = re.compile(pattern) + self.log_info(_("Handle %d %s%s: %s") % + (len(plugin_set), + type, + "" if len(plugin_set) is 1 else "s", + match_list.replace('\.', '.').replace('|', ', '))) + else: + plugin_list = [] + isXFS = lambda klass: any(k.__name__.startswith("XFS") for k in inspect.getmro(klass)) - self.log_debug("Loaded %s pattern: %s" % (type, pattern)) + for p in self.pyload.pluginManager.plugins[type].values(): + klass = self.pyload.pluginManager.loadClass(type, p['name']) + if hasattr(klass, "HOSTER_DOMAIN") and klass.HOSTER_DOMAIN and isXFS(klass): + plugin_list.append(klass.HOSTER_DOMAIN) + if plugin_list: + unmatch_list = '|'.join(sorted(plugin_list)).replace('.', '\.') + pattern = self.regexp[type][0] % unmatch_list + else: + pattern = self.regexp[type][0] - def _unload(self, type, plugin): - dict = self.pyload.pluginManager.plugins[type][plugin] - dict['pattern'] = r'^unmatchable$' - dict['re'] = re.compile(dict['pattern']) + self.log_info(_("Handle any %s site on the web!") % type) + return pattern - def deactivate(self): - # self.unload_hoster("BasePlugin") - for type, plugin in (("hoster", "XFileSharing"), - ("crypter", "XFileSharingFolder")): - self._unload(type, plugin) + def _load(self, type, plugin): + dict = self.pyload.pluginManager.plugins[type][plugin] + pattern = self.get_pattern(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 not pattern: + return - if "new_module" in hdict: - hdict.pop('new_module', None) - hdict.pop('new_name', None) + 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']) - 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") diff --git a/module/plugins/hoster/XFileSharing.py b/module/plugins/hoster/XFileSharing.py index 111460cb7..cc8f5be68 100644 --- a/module/plugins/hoster/XFileSharing.py +++ b/module/plugins/hoster/XFileSharing.py @@ -8,10 +8,9 @@ from module.plugins.internal.XFSHoster import XFSHoster, create_getInfo class XFileSharing(XFSHoster): __name__ = "XFileSharing" __type__ = "hoster" - __version__ = "0.59" + __version__ = "0.60" __status__ = "testing" - # __pattern__ = r'https?://(?:www\.)?(?:\w+\.)*(?P<DOMAIN>(?:[\d.]+|[\w\-^_]{3,63}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)' __pattern__ = r'^unmatchable$' __config__ = [("activated", "bool", "Activated", True)] @@ -32,43 +31,33 @@ class XFileSharing(XFSHoster): self.__pattern__ = self.pyload.pluginManager.hosterPlugins[self.classname]['pattern'] self.PLUGIN_DOMAIN = re.match(self.__pattern__, self.pyfile.url).group("DOMAIN").lower() - self.PLUGIN_NAME = "".join(part.capitalize() for part in re.split(r'(\.|\d+|-)', self.PLUGIN_DOMAIN) if part != '.') + self.PLUGIN_NAME = "".join(part.capitalize() for part in re.split(r'\.|\d+|-', self.PLUGIN_DOMAIN) if part != '.') - def _setup(self): - account_name = self.classname if not self.account or self.account.PLUGIN_DOMAIN is None else self.PLUGIN_NAME - self.chunk_limit = 1 - self.multiDL = True + def setup(self): + self.chunk_limit = -1 if self.premium else 1 + self.multiDL = True + self.resume_download = self.premium + + #@TODO: Recheck in 0.4.10 + def setup_base(self): if self.account: - self.req = self.pyload.requestFactory.getRequest(accountname, self.account.user) - self.premium = self.account.premium - self.resume_download = self.premium + self.req = self.pyload.requestFactory.getRequest(self.PLUGIN_NAME, self.account.user) + self.premium = self.account.info['data']['premium'] #@NOTE: Avoid one unnecessary get_info call by `self.account.premium` here else: - self.req = self.pyload.requestFactory.getRequest(account_name) - self.premium = False - self.resume_download = False - - - def load_account(self): - if self.req: - self.req.close() + self.req = self.pyload.requestFactory.getRequest(self.classname) + self.premium = False - if not self.account: - self.account = self.pyload.accountManager.getAccountPlugin(self.PLUGIN_NAME) + super(SimpleCrypter, self).setup_base() - if not self.account: - self.account = self.pyload.accountManager.getAccountPlugin(self.classname) - if self.account: - if not self.account.PLUGIN_DOMAIN: - self.account.PLUGIN_DOMAIN = self.PLUGIN_DOMAIN - - if not self.account.user: #@TODO: Move to `Account` in 0.4.10 - self.account.user = self.account.select()[0] - - if not self.account.logged: - self.account = False + #@TODO: Recheck in 0.4.10 + def load_account(self): + class_name = self.classname + self.__class__.__name__ = self.PLUGIN_NAME + super(XFileSharing, self).load_account() + self.__class__.__name__ = class_name getInfo = create_getInfo(XFileSharing) |