Example #1
0
    def _create_media_type_configs(self):
        if self._type in (
            MediaTypeManager.__name__,
            System.__name__,
        ):  # dont run for MediaTypeManager or System plugins
            return

        for mtm in common.PM.getMediaTypeManager():
            if type(self.addMediaTypeOptions) is list and mtm.identifier not in self.addMediaTypeOptions:
                continue

            # enable options for mediatype on this plugin
            # log('Creating runFor field on %s from %s' % (self.__class__, mtm.__class__))
            name = helper.replace_some("%s_runfor" % mtm.name)
            self._config[name] = False
            self.config_meta[name] = {"human": "Run for %s" % mtm.type, "type": "enabled", "mediaType": mtm.mt}
            if self.addMediaTypeOptions == "runFor":
                continue

            # log('Creating multi config fields on %s from %s' % (self.__class__, mtm.__class__))
            for configType in [x.__name__ for x in mtm.elementConfigsFor]:
                for element in Element.select().where(Element.type == configType, Element.status != common.TEMP):
                    prefix = self.useConfigsForElementsAs
                    sufix = element.getName()
                    h_name = "%s for %s" % (prefix, sufix)
                    c_name = helper.replace_some("%s %s %s" % (mtm.name, prefix.lower(), sufix))
                    self._config[c_name] = None
                    self.config_meta[c_name] = {
                        "human": h_name,
                        "type": self.useConfigsForElementsAs.lower(),
                        "mediaType": mtm.mt,
                        "element": element,
                    }

            # add costum options
            if self.__class__.__bases__[0] in mtm.addConfig:
                for config in mtm.addConfig[self.__class__.__bases__[0]]:
                    if "forcePrefix" in config and config["forcePrefix"]:
                        prefix = config["prefix"]
                        h_name = "%s %s" % (prefix, config["sufix"])
                        c_type = config["type"]
                    else:
                        prefix = self.useConfigsForElementsAs.lower()
                        h_name = "%s for %s" % (self.useConfigsForElementsAs, config["sufix"])
                        c_type = prefix.lower()
                    c_name = helper.replace_some("%s %s %s" % (mtm.name, prefix, config["sufix"]))
                    self._config[c_name] = config["default"]
                    element = mtm.root
                    self.config_meta[c_name] = {
                        "human": h_name,
                        "type": c_type.lower(),
                        "mediaType": mtm.mt,
                        "element": element,
                    }
Example #2
0
 def runFor(self, mtm):
     try:
         return getattr(self.c, helper.replace_some('%s_runfor' % mtm.name))
     except AttributeError: # this might be a type check
         if hasattr(self, 'types') and mtm.identifier in self.types:
             return True
     return False
Example #3
0
 def runFor(self, mtm):
     try:
         return getattr(self.c, helper.replace_some('%s_runfor' % mtm.name))
     except AttributeError:  # this might be a type check
         if hasattr(self, 'types') and mtm.identifier in self.types:
             return True
     return False
Example #4
0
 def getConfigHtml(self):
     return """<script>
             function newsznab_""" + self.instance + """_spreadCategories(data){
               console.log(data);
               $.each(data, function(k,i){
                   $('#""" + helper.replace_some(
         self.name) + """ input[name$="'+k+'"]').val(i)
Example #5
0
    def _create_media_type_configs(self):
        if self._type in (MediaTypeManager.__name__, System.__name__): # dont run for MediaTypeManager or System plugins
            return

        for mtm in common.PM.getMediaTypeManager():
            if type(self.addMediaTypeOptions) is list and mtm.identifier not in self.addMediaTypeOptions:
                continue

            # enable options for mediatype on this plugin
            # log('Creating runFor field on %s from %s' % (self.__class__, mtm.__class__))
            name = helper.replace_some('%s_runfor' % mtm.name)
            self._config[name] = False
            self.config_meta[name] = {'human': 'Run for %s' % mtm.type, 'type': 'enabled', 'mediaType': mtm.mt}
            if self.addMediaTypeOptions == 'runFor':
                continue

            # log('Creating multi config fields on %s from %s' % (self.__class__, mtm.__class__))
            for configType in [x.__name__ for x in mtm.elementConfigsFor]:
                for element in Element.select().where(Element.type == configType, Element.status != common.TEMP):
                    prefix = self.useConfigsForElementsAs
                    sufix = element.getName()
                    h_name = '%s for %s' % (prefix, sufix)
                    c_name = helper.replace_some('%s %s %s' % (mtm.name, prefix.lower(), sufix))
                    self._config[c_name] = None
                    self.config_meta[c_name] = {'human': h_name,
                                                'type': self.useConfigsForElementsAs.lower(),
                                                'mediaType': mtm.mt,
                                                'element': element}

            # add costum options
            if self.__class__.__bases__[0] in mtm.addConfig:
                for config in mtm.addConfig[self.__class__.__bases__[0]]:
                    if 'forcePrefix' in config and config['forcePrefix']:
                        prefix = config['prefix']
                        h_name = '%s %s' % (prefix, config['sufix'])
                        c_type = config['type']
                    else:
                        prefix = self.useConfigsForElementsAs.lower()
                        h_name = '%s for %s' % (self.useConfigsForElementsAs, config['sufix'])
                        c_type = prefix.lower()
                    c_name = helper.replace_some('%s %s %s' % (mtm.name, prefix, config['sufix']))
                    self._config[c_name] = config['default']
                    element = mtm.root
                    self.config_meta[c_name] = {'human': h_name, 'type': c_type.lower(), 'mediaType': mtm.mt, 'element': element}
Example #6
0
    def _create_media_type_configs(self):
        if self._type in (MediaTypeManager.__name__, System.__name__): # dont run for MediaTypeManager or System plugins
            return

        for mtm in common.PM.getMediaTypeManager():
            if type(self.addMediaTypeOptions) is list and mtm.identifier not in self.addMediaTypeOptions:
                continue

            # enable options for mediatype on this plugin
            # log('Creating runFor field on %s from %s' % (self.__class__, mtm.__class__))
            name = helper.replace_some('%s_runfor' % mtm.name)
            self._config[name] = False
            self.config_meta[name] = {'human': 'Run for %s' % mtm.type, 'type': 'enabled', 'mediaType': mtm.mt}
            if self.addMediaTypeOptions == 'runFor':
                continue

            # log('Creating multi config fields on %s from %s' % (self.__class__, mtm.__class__))
            for configType in [x.__name__ for x in mtm.elementConfigsFor]:
                for element in Element.select().where(Element.type == configType, Element.status != common.TEMP):
                    prefix = self.useConfigsForElementsAs
                    sufix = element.getName()
                    h_name = '%s for %s' % (prefix, sufix)
                    c_name = helper.replace_some('%s %s %s' % (mtm.name, prefix.lower(), sufix))
                    self._config[c_name] = None
                    self.config_meta[c_name] = {'human': h_name,
                                                'type': self.useConfigsForElementsAs.lower(),
                                                'mediaType': mtm.mt,
                                                'element': element}

            # add costum options
            if self.__class__.__bases__[0] in mtm.addConfig:
                for config in mtm.addConfig[self.__class__.__bases__[0]]:
                    if 'forcePrefix' in config and config['forcePrefix']:
                        prefix = config['prefix']
                        h_name = '%s %s' % (prefix, config['sufix'])
                        c_type = config['type']
                    else:
                        prefix = self.useConfigsForElementsAs.lower()
                        h_name = '%s for %s' % (self.useConfigsForElementsAs, config['sufix'])
                        c_type = prefix.lower()
                    c_name = helper.replace_some('%s %s %s' % (mtm.name, prefix, config['sufix']))
                    self._config[c_name] = config['default']
                    element = mtm.root
                    self.config_meta[c_name] = {'human': h_name, 'type': c_type.lower(), 'mediaType': mtm.mt, 'element': element}
Example #7
0
    def __init__(self, instance='Default'):
        for mtm in common.PM.getMediaTypeManager():
            prefix = self.useConfigsForElementsAs
            sufix = mtm.type
            h_name = '%s for %s' % (prefix, sufix)
            c_name = helper.replace_some('%s %s %s' % (mtm.name, prefix.lower(), sufix))
            self._config[c_name] = None
            self.config_meta[c_name] = {'human': h_name,
                                        'type': self.useConfigsForElementsAs.lower(),
                                        'mediaType': mtm.mt,
                                        'element': mtm.root}

        PostProcessor.__init__(self, instance=instance)
Example #8
0
    def __init__(self, instance='Default'):
        for mtm in common.PM.getMediaTypeManager():
            prefix = self.useConfigsForElementsAs
            sufix = mtm.type
            h_name = '%s for %s' % (prefix, sufix)
            c_name = helper.replace_some('%s %s %s' % (mtm.name, prefix.lower(), sufix))
            self._config[c_name] = None
            self.config_meta[c_name] = {'human': h_name,
                                        'type': self.useConfigsForElementsAs.lower(),
                                        'mediaType': mtm.mt,
                                        'element': mtm.root}

        PostProcessor.__init__(self, instance=instance)
Example #9
0
    def __init__(self, instance="Default"):
        for mtm in common.PM.getMediaTypeManager():
            prefix = self.useConfigsForElementsAs
            sufix = mtm.type
            h_name = "%s for %s" % (prefix, sufix)
            c_name = helper.replace_some("%s %s %s" % (mtm.name, prefix.lower(), sufix))
            self._config[c_name] = None
            self.config_meta[c_name] = {
                "human": h_name,
                "type": self.useConfigsForElementsAs.lower(),
                "mediaType": mtm.mt,
                "element": mtm.root,
            }

        PostProcessor.__init__(self, instance=instance)