Example #1
0
def index():
    """ Generate a list of filters & sections and render it to the client

    :return: Section & Filter config
    :rtype: dict
    """
    section_data = []
    for section in ['tv', 'movie']:
        config_section = "section_{0}".format(section)
        section_info = {}
        for key in ['dl_path', 'group_name', 'sort_seasons']:
            try:
                section_info[key] = config.get(config_section, key)
            except (NoOptionError, NoSectionError):
                pass
        for key in ['quality_hd', 'quality_sd', 'quality_any']:
            try:
                values = [" ".join(show.split()) for show in config.get(config_section, key).split(",") if show]
                if values:
                    section_info[key] = values

            except (NoOptionError, NoSectionError):
                pass
        section_info['section'] = section
        section_data.append(section_info)
    return dict(section_data=section_data)
Example #2
0
def index():
    """ Generate a list of filters & sections and render it to the client

    :return: Section & Filter config
    :rtype: dict
    """
    section_data = []
    for section in ['tv', 'movie']:
        config_section = "section_{0}".format(section)
        section_info = {}
        for key in ['dl_path', 'group_name', 'sort_seasons']:
            try:
                section_info[key] = config.get(config_section, key)
            except (NoOptionError, NoSectionError):
                pass
        for key in ['quality_hd', 'quality_sd', 'quality_any']:
            try:
                values = [
                    " ".join(show.split())
                    for show in config.get(config_section, key).split(",")
                    if show
                ]
                if values:
                    section_info[key] = values

            except (NoOptionError, NoSectionError):
                pass
        section_info['section'] = section
        section_data.append(section_info)
    return dict(section_data=section_data)
Example #3
0
def _post_request(method, data):
    key = config.get_default('service_trakt', 'api_key', None)
    if not key:
        return {}
    username = config.get("service_trakt", "username")
    password = config.get("service_trakt", "password")
    url = _make_url(method, key, json=False)
    data['username'] = username
    data['password'] = hashlib.sha1(password).hexdigest()
    results = net.http_request(url, data=data, method='post')
    return results
Example #4
0
def _post_request(method, data):
    key = config.get_default('service_trakt', 'api_key', None)
    if not key:
        return {}
    username = config.get("service_trakt", "username")
    password = config.get("service_trakt", "password")
    url = _make_url(method, key, json=False)
    data['username'] = username
    data['password'] = hashlib.sha1(password).hexdigest()
    results = net.http_request(url, data=data, method='post')
    return results
Example #5
0
def system():
    """ Show system / OS info

    # TODO Better Win/OSX/BSD? support.

    :return: System info
    :rtype: dict
    """
    about_info = OrderedDict()
    about_info["Hostname"] = platform.node()
    about_info["Platform"] = "{0} ({1})".format(platform.platform(), platform.architecture()[0])
    about_info["Python"] = "{0} {1}".format(platform.python_implementation(), platform.python_version())
    about_info["Uptime-Sys"] = time.strftime("%H:%M:%S", time.gmtime(util.uptime_sys()))
    about_info["Uptime-App"] = time.strftime("%H:%M:%S", time.gmtime(util.uptime_app()))
    try:
        if hasattr(sys, "real_prefix"):
            about_info["Distribution"] = "VirtualEnv"
        else:
            distro = platform.linux_distribution()
            if distro[0]:
                about_info["Distribution"] = "{0} {1} {2}".format(distro[0], distro[1], distro[2])
    except IndexError:
        pass

    # Get disk info and sort it by path
    disk_info = util.disk_free()
    sorted_disk_info = OrderedDict()
    for key in sorted(disk_info.keys()):
        sorted_disk_info[key] = disk_info[key]

    # Get arbitary client information
    client_name = config.get("general", "client")
    client_info = client.get().client_information()

    return dict(info=about_info, disk_info=sorted_disk_info, client_name=client_name, client_info=client_info)
Example #6
0
def index():
    section_data = []
    for section in ['tv', 'movies']:
        config_section = "section_{0}".format(section)
        section_info = {}
        for key in ['dl_path', 'group_name', 'sort_seasons']:
            try:
                section_info[key] = config.get(config_section, key)
            except (NoOptionError, NoSectionError):
                pass
        for key in ['quality_hd', 'quality_sd', 'quality_any']:
            try:
                values = [" ".join(show.split()) for show in config.get(config_section, key).split(",") if show]
                if values:
                    section_info[key] = values

            except (NoOptionError, NoSectionError):
                pass
        section_info['section'] = section
        section_data.append(section_info)
    return ui.render_template("filters.html", section_data=section_data, section="filters")
Example #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()
Example #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()
Example #9
0
def system():
    """ Show system / OS info

    # TODO Better Win/OSX/BSD? support.

    :return: System info
    :rtype: dict
    """
    about_info = OrderedDict()
    about_info['Hostname'] = platform.node()
    about_info['Platform'] = "{0} ({1})".format(platform.platform(),
                                                platform.architecture()[0])
    about_info['Python'] = "{0} {1}".format(platform.python_implementation(),
                                            platform.python_version())
    about_info['Uptime-Sys'] = time.strftime("%H:%M:%S",
                                             time.gmtime(util.uptime_sys()))
    about_info['Uptime-App'] = time.strftime("%H:%M:%S",
                                             time.gmtime(util.uptime_app()))
    try:
        if hasattr(sys, "real_prefix"):
            about_info['Distribution'] = "VirtualEnv"
        else:
            distro = platform.linux_distribution()
            if distro[0]:
                about_info['Distribution'] = "{0} {1} {2}".format(
                    distro[0], distro[1], distro[2])
    except IndexError:
        pass

    # Get disk info and sort it by path
    disk_info = util.disk_free()
    sorted_disk_info = OrderedDict()
    for key in sorted(disk_info.keys()):
        sorted_disk_info[key] = disk_info[key]

    # Get arbitary client information
    client_name = config.get("general", "client")
    client_info = client.get().client_information()

    return dict(info=about_info,
                disk_info=sorted_disk_info,
                client_name=client_name,
                client_info=client_info)
Example #10
0
def _make_imdb():
    """ Configure and return the imdb object ready for use

    :return: Imdb instance for querying
    :rtype: IMDbBase
    """
    # TODO fix this sillyness
    access_method = config.get_default(config_section, 'sql', 'http')
    if access_method.lower() in ["1", "true"]:
        access_method = "sql"
    elif access_method.lower() in ["0", "false"]:
        access_method = "http"
    kwargs = {}
    if access_method == 'sql':
        kwargs = {"uri": config.get('db', 'uri'), "useORM": "sqlalchemy"}

    i = IMDb(access_method, **kwargs)
    if access_method == "http":
        if config.getboolean("proxy", "enabled"):
            i.set_proxy(config.get_default("proxy", "server", ''))
    return i
Example #11
0
def _make_imdb():
    """ Configure and return the imdb object ready for use

    :return: Imdb instance for querying
    :rtype: IMDbBase
    """
    # TODO fix this sillyness
    access_method = config.get_default(config_section, 'sql', 'http')
    if access_method.lower() in ["1", "true"]:
        access_method = "sql"
    elif access_method.lower() in ["0", "false"]:
        access_method = "http"
    kwargs = {}
    if access_method == 'sql':
        kwargs = {
            "uri": config.get('db', 'uri'),
            "useORM": "sqlalchemy"
        }

    i = IMDb(access_method, **kwargs)
    if access_method == "http":
        if config.getboolean("proxy", "enabled"):
            i.set_proxy(config.get_default("proxy", "server", ''))
    return i
Example #12
0
 def test_upload(self):
     torrent = TorrentData(
         'Jimmy.Fallon.2014.01.01.John.Smith.HDTV.x264-GROUP',
         open(self.get_fixture('linux-iso.torrent'), 'rb').read(),
         'section_tv')
     self.assertTrue(self.client.add(torrent, config.get(torrent.section, 'dl_path')))
Example #13
0
 def __init__(self):
     self._server = SCGIServerProxy(config.get(self._config_key, 'uri'))