Esempio n. 1
0
    def init_providers(self):
        """ Initialize and return the API based services.

        TODO Remove hard coded service names

        :return: Configured services API's
        :rtype: []TorrentProvider
        """
        self.services = []
        service_list = set(config.find_sections("rss_") + config.find_sections("provider_"))
        for service_name in service_list:
            if service_name.startswith("rss_"):
                self.services.append(RSSFeed(service_name))
            elif service_name == "provider_broadcastthenet":
                from tranny.provider.broadcastthenet import BroadcastTheNet

                self.services.append(BroadcastTheNet(service_name))
            elif service_name == 'provider_ptp':
                from tranny.provider.ptp import PTP

                self.services.append(PTP(service_name))
            elif service_name == 'provider_hdbits':
                from tranny.provider.hdbits import HDBits

                self.services.append(HDBits(service_name))
        return self.services
Esempio n. 2
0
def index():
    """ Generate and render a list of provider configs

    :return: Provider configs
    :rtype: dict
    """
    provider_info = {k: config.get_section_values(k) for k in config.find_sections("provider_")}
    return dict(provider_info=provider_info)
Esempio n. 3
0
def index():
    """ Generate and render a list of provider configs

    :return: Provider configs
    :rtype: dict
    """
    provider_info = {
        k: config.get_section_values(k)
        for k in config.find_sections("provider_")
    }
    return dict(provider_info=provider_info)
Esempio n. 4
0
def index():
    feed_data = {}
    for section in config.find_sections("rss_"):
        settings = config.get_section_values(section)
        # for key, default, type_func in option_set:
        #     settings[key] = config.get_default(section, key, default, type_func)
        if not "enabled" in settings:
            try:
                enabled = config.getboolean(section, "enabled")
            except NoOptionError:
                enabled = False
            settings['enabled'] = "0" if enabled else "1"
        tpl_key = section.split("_")[1]
        feed_data[tpl_key] = settings
    return ui.render_template("rss.html", section="rss", feeds=feed_data)
Esempio n. 5
0
def index():
    """ Generate feed configuration data from the local config and show
    it to the user to allow editing

    :return: RSS Configuration
    :rtype: dict
    """
    feed_data = {}
    for section in config.find_sections("rss_"):
        settings = config.get_section_values(section)
        # for key, default, type_func in option_set:
        #     settings[key] = config.get_default(section, key, default, type_func)
        if not "enabled" in settings:
            try:
                enabled = config.getboolean(section, "enabled")
            except NoOptionError:
                enabled = False
            settings['enabled'] = "0" if enabled else "1"
        tpl_key = section.partition("_")[2]
        feed_data[tpl_key] = settings
    return dict(feeds=feed_data)
Esempio n. 6
0
def index():
    """ Generate feed configuration data from the local config and show
    it to the user to allow editing

    :return: RSS Configuration
    :rtype: dict
    """
    feed_data = {}
    for section in config.find_sections("rss_"):
        settings = config.get_section_values(section)
        # for key, default, type_func in option_set:
        #     settings[key] = config.get_default(section, key, default, type_func)
        if not "enabled" in settings:
            try:
                enabled = config.getboolean(section, "enabled")
            except NoOptionError:
                enabled = False
            settings['enabled'] = "0" if enabled else "1"
        tpl_key = section.partition("_")[2]
        feed_data[tpl_key] = settings
    return dict(feeds=feed_data)
Esempio n. 7
0
    def __init__(self, service_manager):
        """

        :param service_manager:
        :type service_manager: tranny.manager.ServiceManager                continue
        :return:
        :rtype:
        """
        self._service_manager = service_manager
        self._observer = Observer()
        for section in config.find_sections("watch"):
            try:
                section_name = config.get_default(section, "section", False)
                watch_path = config.get(section, "path")
                if not exists(watch_path):
                    log.warn(
                        "Watch path does not exist {0}".format(watch_path))
            except (NoOptionError, NoSectionError):
                log.warn(
                    "Failed to get dl_path key for watch section {0}. Does not exist"
                    .format(section))
                continue

            dl_path = expanduser(
                config.get("section_{0}".format(section_name), "dl_path"))
            if not dl_path or not exists(dl_path) or not isdir(dl_path):
                log.warning(
                    "Invalid download directory {0}. Disabling watch service for this directory"
                    .format(dl_path))
                watch_path = None
            if not config.has_section("section_{0}".format(section_name)):
                log.warning(
                    "Invalid section name specified for watch dir: {0}".format(
                        section_name))
            if watch_path:
                self._observer.schedule(self, watch_path, recursive=True)
                self._path_sections[watch_path] = section_name
        if not self._path_sections:
            log.warning("No valid watch dirs found, disabling service")
        self._observer.start()
Esempio n. 8
0
    def __init__(self, service_manager):
        """

        :param service_manager:
        :type service_manager: tranny.manager.ServiceManager                continue
        :return:
        :rtype:
        """
        self._service_manager = service_manager
        self._observer = Observer()
        for section in config.find_sections("watch"):
            try:
                section_name = config.get_default(section, "section", False)
                watch_path = config.get(section, "path")
                if not exists(watch_path):
                    logger.warn("Watch path does not exist {0}".format(watch_path))
            except (NoOptionError, NoSectionError):
                logger.warn("Failed to get dl_path key for watch section {0}. Does not exist".format(
                    section
                ))
                continue

            dl_path = expanduser(config.get("section_{0}".format(section_name), "dl_path"))
            if not dl_path or not exists(dl_path) or not isdir(dl_path):
                logger.warning(
                    "Invalid download directory {0}. Disabling watch service for this directory".format(dl_path)
                )
                watch_path = None
            if not config.has_section("section_{0}".format(section_name)):
                logger.warning("Invalid section name specified for watch dir: {0}".format(section_name))
            if watch_path:
                self._observer.schedule(self, watch_path, recursive=True)
                self._path_sections[watch_path] = section_name
        if not self._path_sections:
            logger.warning("No valid watch dirs found, disabling service")
        self._observer.start()
Esempio n. 9
0
def index():
    service_info = {k: config.get_section_values(k) for k in config.find_sections("service_")}
    return ui.render_template("services.html", section="services", service_info=service_info)