示例#1
0
    def saveAnime(self,
                  use_anidb=None,
                  anidb_username=None,
                  anidb_password=None,
                  anidb_use_mylist=None,
                  split_home=None):
        """
        Save anime related settings
        """

        results = []

        app.USE_ANIDB = config.checkbox_to_value(use_anidb)
        app.ANIDB_USERNAME = anidb_username
        app.ANIDB_PASSWORD = anidb_password
        app.ANIDB_USE_MYLIST = config.checkbox_to_value(anidb_use_mylist)
        app.ANIME_SPLIT_HOME = config.checkbox_to_value(split_home)

        app.save_config()

        if results:
            for x in results:
                logger.log(x, logger.ERROR)
            ui.notifications.error('Error(s) Saving Configuration',
                                   '<br>\n'.join(results))
        else:
            ui.notifications.message('Configuration Saved',
                                     ek(os.path.join, app.CONFIG_FILE))

        return self.redirect('/config/anime/')
示例#2
0
    def saveAddShowDefaults(defaultStatus,
                            anyQualities,
                            bestQualities,
                            defaultFlattenFolders,
                            subtitles=False,
                            anime=False,
                            scene=False,
                            defaultStatusAfter=WANTED):

        allowed_qualities = anyQualities.split(',') if anyQualities else []
        preferred_qualities = bestQualities.split(',') if bestQualities else []

        new_quality = Quality.combineQualities(
            [int(quality) for quality in allowed_qualities],
            [int(quality) for quality in preferred_qualities])

        app.STATUS_DEFAULT = int(defaultStatus)
        app.STATUS_DEFAULT_AFTER = int(defaultStatusAfter)
        app.QUALITY_DEFAULT = int(new_quality)

        app.FLATTEN_FOLDERS_DEFAULT = config.checkbox_to_value(
            defaultFlattenFolders)
        app.SUBTITLES_DEFAULT = config.checkbox_to_value(subtitles)

        app.ANIME_DEFAULT = config.checkbox_to_value(anime)

        app.SCENE_DEFAULT = config.checkbox_to_value(scene)
        app.save_config()
示例#3
0
    def saveSubtitles(self, use_subtitles=None, subtitles_plugins=None, subtitles_languages=None, subtitles_dir=None, subtitles_perfect_match=None,
                      service_order=None, subtitles_history=None, subtitles_finder_frequency=None,
                      subtitles_multi=None, embedded_subtitles_all=None, subtitles_extra_scripts=None, subtitles_pre_scripts=None, subtitles_hearing_impaired=None,
                      addic7ed_user=None, addic7ed_pass=None, itasa_user=None, itasa_pass=None, legendastv_user=None, legendastv_pass=None, opensubtitles_user=None, opensubtitles_pass=None,
                      subtitles_keep_only_wanted=None, embedded_subtitles_unknown_lang=None, subtitles_stop_at_first=None):
        """
        Save Subtitle Search related settings
        """
        results = []

        config.change_SUBTITLES_FINDER_FREQUENCY(subtitles_finder_frequency)
        config.change_USE_SUBTITLES(use_subtitles)

        app.SUBTITLES_LANGUAGES = [code.strip() for code in subtitles_languages.split(',') if code.strip() in subtitles.subtitle_code_filter()] if subtitles_languages else []
        app.SUBTITLES_DIR = subtitles_dir
        app.SUBTITLES_PERFECT_MATCH = config.checkbox_to_value(subtitles_perfect_match)
        app.SUBTITLES_HISTORY = config.checkbox_to_value(subtitles_history)
        app.EMBEDDED_SUBTITLES_ALL = config.checkbox_to_value(embedded_subtitles_all)
        app.EMBEDDED_SUBTITLES_UNKNOWN_LANG = config.checkbox_to_value(embedded_subtitles_unknown_lang)
        app.SUBTITLES_STOP_AT_FIRST = config.checkbox_to_value(subtitles_stop_at_first)
        app.SUBTITLES_HEARING_IMPAIRED = config.checkbox_to_value(subtitles_hearing_impaired)
        app.SUBTITLES_MULTI = 1 if len(app.SUBTITLES_LANGUAGES) > 1 else config.checkbox_to_value(subtitles_multi)
        app.SUBTITLES_KEEP_ONLY_WANTED = config.checkbox_to_value(subtitles_keep_only_wanted)
        app.SUBTITLES_EXTRA_SCRIPTS = [x.strip() for x in subtitles_extra_scripts.split('|') if x.strip()]
        app.SUBTITLES_PRE_SCRIPTS = [x.strip() for x in subtitles_pre_scripts.split('|') if x.strip()]

        # Subtitles services
        services_str_list = service_order.split()
        subtitles_services_list = []
        subtitles_services_enabled = []
        for curServiceStr in services_str_list:
            cur_service, cur_enabled = curServiceStr.split(':')
            subtitles_services_list.append(cur_service)
            subtitles_services_enabled.append(int(cur_enabled))

        app.SUBTITLES_SERVICES_LIST = subtitles_services_list
        app.SUBTITLES_SERVICES_ENABLED = subtitles_services_enabled

        app.ADDIC7ED_USER = addic7ed_user or ''
        app.ADDIC7ED_PASS = addic7ed_pass or ''
        app.ITASA_USER = itasa_user or ''
        app.ITASA_PASS = itasa_pass or ''
        app.LEGENDASTV_USER = legendastv_user or ''
        app.LEGENDASTV_PASS = legendastv_pass or ''
        app.OPENSUBTITLES_USER = opensubtitles_user or ''
        app.OPENSUBTITLES_PASS = opensubtitles_pass or ''

        app.save_config()
        # Reset provider pool so next time we use the newest settings
        subtitles.get_provider_pool.invalidate()

        if results:
            for x in results:
                logger.log(x, logger.ERROR)
            ui.notifications.error('Error(s) Saving Configuration',
                                   '<br>\n'.join(results))
        else:
            ui.notifications.message('Configuration Saved', os.path.join(app.CONFIG_FILE))

        return self.redirect('/config/subtitles/')
示例#4
0
    def index(self):
        try:
            news = app.versionCheckScheduler.action.check_for_new_news(force=True)
        except Exception:
            logger.log('Could not load news from repo, giving a link!', logger.DEBUG)
            news = 'Could not load news from the repo. [Click here for news.md]({url})'.format(url=app.NEWS_URL)

        app.NEWS_LAST_READ = app.NEWS_LATEST
        app.NEWS_UNREAD = 0
        app.save_config()

        t = PageTemplate(rh=self, filename='markdown.mako')
        data = markdown2.markdown(news if news else 'The was a problem connecting to github, please refresh and try again', extras=['header-ids'])

        return t.render(title='News', header='News', topmenu='system', data=data, controller='news', action='index')
示例#5
0
    def index(self, limit=None):

        if limit is None:
            if app.HISTORY_LIMIT:
                limit = int(app.HISTORY_LIMIT)
            else:
                limit = 100
        else:
            limit = try_int(limit, 100)

        app.HISTORY_LIMIT = limit

        app.save_config()

        history = self.history.get(limit)

        t = PageTemplate(rh=self, filename='history.mako')
        submenu = [
            {
                'title': 'Clear History',
                'path': 'history/clearHistory',
                'icon': 'ui-icon ui-icon-trash',
                'class': 'clearhistory',
                'confirm': True
            },
            {
                'title': 'Trim History',
                'path': 'history/trimHistory',
                'icon': 'menu-icon-cut',
                'class': 'trimhistory',
                'confirm': True
            },
        ]

        return t.render(historyResults=history.detailed,
                        compactResults=history.compact,
                        limit=limit,
                        submenu=submenu,
                        title='History',
                        header='History',
                        topmenu='history',
                        controller='history',
                        action='index')
示例#6
0
    def migrate_config(self):
        """
        Calls each successive migration until the config is the same version as SB expects
        """

        if self.config_version > self.expected_config_version:
            logger.log_error_and_exit(
                u"""Your config version (%i) has been incremented past what this version of the application supports (%i).
                If you have used other forks or a newer version of the application, your config file may be unusable due to their modifications."""
                % (self.config_version, self.expected_config_version))

        app.CONFIG_VERSION = self.config_version

        while self.config_version < self.expected_config_version:
            next_version = self.config_version + 1

            if next_version in self.migration_names:
                migration_name = ': ' + self.migration_names[next_version]
            else:
                migration_name = ''

            logger.log(u"Backing up config before upgrade")
            if not helpers.backupVersionedFile(app.CONFIG_FILE,
                                               self.config_version):
                logger.log_error_and_exit(
                    u"Config backup failed, abort upgrading config")
            else:
                logger.log(u"Proceeding with upgrade")

            # do the migration, expect a method named _migrate_v<num>
            logger.log(u"Migrating config up to version " + str(next_version) +
                       migration_name)
            getattr(self, '_migrate_v' + str(next_version))()
            self.config_version = next_version

            # save new config after migration
            app.CONFIG_VERSION = self.config_version
            logger.log(u"Saving config file to disk")
            app.save_config()
示例#7
0
    def saveGeneral(self,
                    log_dir=None,
                    log_nr=5,
                    log_size=1,
                    web_port=None,
                    notify_on_login=None,
                    web_log=None,
                    encryption_version=None,
                    web_ipv6=None,
                    trash_remove_show=None,
                    trash_rotate_logs=None,
                    update_frequency=None,
                    skip_removed_files=None,
                    indexerDefaultLang='en',
                    ep_default_deleted_status=None,
                    launch_browser=None,
                    showupdate_hour=3,
                    web_username=None,
                    api_key=None,
                    indexer_default=None,
                    timezone_display=None,
                    cpu_preset='NORMAL',
                    web_password=None,
                    version_notify=None,
                    enable_https=None,
                    https_cert=None,
                    https_key=None,
                    handle_reverse_proxy=None,
                    sort_article=None,
                    auto_update=None,
                    notify_on_update=None,
                    proxy_setting=None,
                    proxy_indexers=None,
                    anon_redirect=None,
                    git_path=None,
                    git_remote=None,
                    calendar_unprotected=None,
                    calendar_icons=None,
                    debug=None,
                    ssl_verify=None,
                    no_restart=None,
                    coming_eps_missed_range=None,
                    fuzzy_dating=None,
                    trim_zero=None,
                    date_preset=None,
                    date_preset_na=None,
                    time_preset=None,
                    indexer_timeout=None,
                    download_url=None,
                    rootDir=None,
                    theme_name=None,
                    default_page=None,
                    git_reset=None,
                    git_reset_branches=None,
                    git_username=None,
                    git_password=None,
                    display_all_seasons=None,
                    subliminal_log=None,
                    privacy_level='normal',
                    fanart_background=None,
                    fanart_background_opacity=None):
        results = []

        # Misc
        app.DOWNLOAD_URL = download_url
        app.INDEXER_DEFAULT_LANGUAGE = indexerDefaultLang
        app.EP_DEFAULT_DELETED_STATUS = ep_default_deleted_status
        app.SKIP_REMOVED_FILES = config.checkbox_to_value(skip_removed_files)
        app.LAUNCH_BROWSER = config.checkbox_to_value(launch_browser)
        config.change_SHOWUPDATE_HOUR(showupdate_hour)
        config.change_VERSION_NOTIFY(config.checkbox_to_value(version_notify))
        app.AUTO_UPDATE = config.checkbox_to_value(auto_update)
        app.NOTIFY_ON_UPDATE = config.checkbox_to_value(notify_on_update)
        # app.LOG_DIR is set in config.change_LOG_DIR()
        app.LOG_NR = log_nr
        app.LOG_SIZE = float(log_size)

        app.TRASH_REMOVE_SHOW = config.checkbox_to_value(trash_remove_show)
        app.TRASH_ROTATE_LOGS = config.checkbox_to_value(trash_rotate_logs)
        config.change_UPDATE_FREQUENCY(update_frequency)
        app.LAUNCH_BROWSER = config.checkbox_to_value(launch_browser)
        app.SORT_ARTICLE = config.checkbox_to_value(sort_article)
        app.CPU_PRESET = cpu_preset
        app.ANON_REDIRECT = anon_redirect
        app.PROXY_SETTING = proxy_setting
        app.PROXY_INDEXERS = config.checkbox_to_value(proxy_indexers)
        app.GIT_USERNAME = git_username
        app.GIT_PASSWORD = git_password
        app.GIT_RESET = config.checkbox_to_value(git_reset)
        app.GIT_RESET_BRANCHES = helpers.ensure_list(git_reset_branches)
        app.GIT_PATH = git_path
        app.GIT_REMOTE = git_remote
        app.CALENDAR_UNPROTECTED = config.checkbox_to_value(
            calendar_unprotected)
        app.CALENDAR_ICONS = config.checkbox_to_value(calendar_icons)
        app.NO_RESTART = config.checkbox_to_value(no_restart)

        app.SSL_VERIFY = config.checkbox_to_value(ssl_verify)
        # app.LOG_DIR is set in config.change_LOG_DIR()
        app.COMING_EPS_MISSED_RANGE = try_int(coming_eps_missed_range, 7)
        app.DISPLAY_ALL_SEASONS = config.checkbox_to_value(display_all_seasons)
        app.NOTIFY_ON_LOGIN = config.checkbox_to_value(notify_on_login)
        app.WEB_PORT = try_int(web_port)
        app.WEB_IPV6 = config.checkbox_to_value(web_ipv6)
        if config.checkbox_to_value(encryption_version) == 1:
            app.ENCRYPTION_VERSION = 2
        else:
            app.ENCRYPTION_VERSION = 0
        app.WEB_USERNAME = web_username
        app.WEB_PASSWORD = web_password

        app.DEBUG = config.checkbox_to_value(debug)
        app.WEB_LOG = config.checkbox_to_value(web_log)
        app.SUBLIMINAL_LOG = config.checkbox_to_value(subliminal_log)

        if not config.change_LOG_DIR(log_dir):
            results += [
                'Unable to create directory {dir}, '
                'log directory not changed.'.format(
                    dir=ek(os.path.normpath, log_dir))
            ]

        # Reconfigure the logger
        logger.reconfigure()

        # Validate github credentials
        try:
            github_client.authenticate(app.GIT_USERNAME, app.GIT_PASSWORD)
        except (GithubException, IOError):
            logger.log('Error while validating your Github credentials.',
                       logger.WARNING)

        app.PRIVACY_LEVEL = privacy_level.lower()

        app.FUZZY_DATING = config.checkbox_to_value(fuzzy_dating)
        app.TRIM_ZERO = config.checkbox_to_value(trim_zero)

        if date_preset:
            app.DATE_PRESET = date_preset

        if indexer_default:
            app.INDEXER_DEFAULT = try_int(indexer_default)

        if indexer_timeout:
            app.INDEXER_TIMEOUT = try_int(indexer_timeout)

        if time_preset:
            app.TIME_PRESET_W_SECONDS = time_preset
            app.TIME_PRESET = app.TIME_PRESET_W_SECONDS.replace(u':%S', u'')

        app.TIMEZONE_DISPLAY = timezone_display

        app.API_KEY = api_key

        app.ENABLE_HTTPS = config.checkbox_to_value(enable_https)

        if not config.change_HTTPS_CERT(https_cert):
            results += [
                'Unable to create directory {dir}, '
                'https cert directory not changed.'.format(
                    dir=ek(os.path.normpath, https_cert))
            ]

        if not config.change_HTTPS_KEY(https_key):
            results += [
                'Unable to create directory {dir}, '
                'https key directory not changed.'.format(
                    dir=ek(os.path.normpath, https_key))
            ]

        app.HANDLE_REVERSE_PROXY = config.checkbox_to_value(
            handle_reverse_proxy)

        app.THEME_NAME = theme_name
        app.FANART_BACKGROUND = config.checkbox_to_value(fanart_background)
        app.FANART_BACKGROUND_OPACITY = fanart_background_opacity

        app.DEFAULT_PAGE = default_page

        app.save_config()

        if results:
            for x in results:
                logger.log(x, logger.ERROR)
            ui.notifications.error('Error(s) Saving Configuration',
                                   '<br>\n'.join(results))
        else:
            ui.notifications.message('Configuration Saved',
                                     ek(os.path.join, app.CONFIG_FILE))

        return self.redirect('/config/general/')
示例#8
0
    def savePostProcessing(self,
                           kodi_data=None,
                           kodi_12plus_data=None,
                           mediabrowser_data=None,
                           sony_ps3_data=None,
                           wdtv_data=None,
                           tivo_data=None,
                           mede8er_data=None,
                           keep_processed_dir=None,
                           process_method=None,
                           del_rar_contents=None,
                           process_automatically=None,
                           no_delete=None,
                           rename_episodes=None,
                           airdate_episodes=None,
                           file_timestamp_timezone=None,
                           unpack=None,
                           move_associated_files=None,
                           sync_files=None,
                           postpone_if_sync_files=None,
                           postpone_if_no_subs=None,
                           allowed_extensions=None,
                           tv_download_dir=None,
                           create_missing_show_dirs=None,
                           add_shows_wo_dir=None,
                           extra_scripts=None,
                           nfo_rename=None,
                           naming_pattern=None,
                           naming_multi_ep=None,
                           naming_custom_abd=None,
                           naming_anime=None,
                           naming_abd_pattern=None,
                           naming_strip_year=None,
                           naming_custom_sports=None,
                           naming_sports_pattern=None,
                           naming_custom_anime=None,
                           naming_anime_pattern=None,
                           naming_anime_multi_ep=None,
                           autopostprocessor_frequency=None):

        results = []

        if not config.change_TV_DOWNLOAD_DIR(tv_download_dir):
            results += [
                'Unable to create directory {dir}, '
                'dir not changed.'.format(
                    dir=ek(os.path.normpath, tv_download_dir))
            ]

        config.change_AUTOPOSTPROCESSOR_FREQUENCY(autopostprocessor_frequency)
        config.change_PROCESS_AUTOMATICALLY(process_automatically)

        if unpack:
            if self.isRarSupported() != 'not supported':
                app.UNPACK = config.checkbox_to_value(unpack)
            else:
                app.UNPACK = 0
                results.append(
                    'Unpacking Not Supported, disabling unpack setting')
        else:
            app.UNPACK = config.checkbox_to_value(unpack)
        app.NO_DELETE = config.checkbox_to_value(no_delete)
        app.KEEP_PROCESSED_DIR = config.checkbox_to_value(keep_processed_dir)
        app.CREATE_MISSING_SHOW_DIRS = config.checkbox_to_value(
            create_missing_show_dirs)
        app.ADD_SHOWS_WO_DIR = config.checkbox_to_value(add_shows_wo_dir)
        app.PROCESS_METHOD = process_method
        app.DELRARCONTENTS = config.checkbox_to_value(del_rar_contents)
        app.EXTRA_SCRIPTS = [
            x.strip() for x in extra_scripts.split('|') if x.strip()
        ]
        app.RENAME_EPISODES = config.checkbox_to_value(rename_episodes)
        app.AIRDATE_EPISODES = config.checkbox_to_value(airdate_episodes)
        app.FILE_TIMESTAMP_TIMEZONE = file_timestamp_timezone
        app.MOVE_ASSOCIATED_FILES = config.checkbox_to_value(
            move_associated_files)
        app.SYNC_FILES = sync_files
        app.POSTPONE_IF_SYNC_FILES = config.checkbox_to_value(
            postpone_if_sync_files)
        app.POSTPONE_IF_NO_SUBS = config.checkbox_to_value(postpone_if_no_subs)
        # If 'postpone if no subs' is enabled, we must have SRT in allowed extensions list
        if app.POSTPONE_IF_NO_SUBS:
            allowed_extensions += ',srt'
            # # Auto PP must be disabled because FINDSUBTITLE thread that calls manual PP (like nzbtomedia)
            # app.PROCESS_AUTOMATICALLY = 0
        app.ALLOWED_EXTENSIONS = ','.join(
            {x.strip()
             for x in allowed_extensions.split(',') if x.strip()})
        app.NAMING_CUSTOM_ABD = config.checkbox_to_value(naming_custom_abd)
        app.NAMING_CUSTOM_SPORTS = config.checkbox_to_value(
            naming_custom_sports)
        app.NAMING_CUSTOM_ANIME = config.checkbox_to_value(naming_custom_anime)
        app.NAMING_STRIP_YEAR = config.checkbox_to_value(naming_strip_year)
        app.NFO_RENAME = config.checkbox_to_value(nfo_rename)

        app.METADATA_KODI = kodi_data
        app.METADATA_KODI_12PLUS = kodi_12plus_data
        app.METADATA_MEDIABROWSER = mediabrowser_data
        app.METADATA_PS3 = sony_ps3_data
        app.METADATA_WDTV = wdtv_data
        app.METADATA_TIVO = tivo_data
        app.METADATA_MEDE8ER = mede8er_data

        app.metadata_provider_dict['KODI'].set_config(app.METADATA_KODI)
        app.metadata_provider_dict['KODI 12+'].set_config(
            app.METADATA_KODI_12PLUS)
        app.metadata_provider_dict['MediaBrowser'].set_config(
            app.METADATA_MEDIABROWSER)
        app.metadata_provider_dict['Sony PS3'].set_config(app.METADATA_PS3)
        app.metadata_provider_dict['WDTV'].set_config(app.METADATA_WDTV)
        app.metadata_provider_dict['TIVO'].set_config(app.METADATA_TIVO)
        app.metadata_provider_dict['Mede8er'].set_config(app.METADATA_MEDE8ER)

        if self.isNamingValid(naming_pattern,
                              naming_multi_ep,
                              anime_type=naming_anime) != 'invalid':
            app.NAMING_PATTERN = naming_pattern
            app.NAMING_MULTI_EP = int(naming_multi_ep)
            app.NAMING_ANIME = int(naming_anime)
            app.NAMING_FORCE_FOLDERS = naming.check_force_season_folders()
        else:
            if int(naming_anime) in [1, 2]:
                results.append(
                    'You tried saving an invalid anime naming config, not saving your naming settings'
                )
            else:
                results.append(
                    'You tried saving an invalid naming config, not saving your naming settings'
                )

        if self.isNamingValid(naming_anime_pattern,
                              naming_anime_multi_ep,
                              anime_type=naming_anime) != 'invalid':
            app.NAMING_ANIME_PATTERN = naming_anime_pattern
            app.NAMING_ANIME_MULTI_EP = int(naming_anime_multi_ep)
            app.NAMING_ANIME = int(naming_anime)
            app.NAMING_FORCE_FOLDERS = naming.check_force_season_folders()
        else:
            if int(naming_anime) in [1, 2]:
                results.append(
                    'You tried saving an invalid anime naming config, not saving your naming settings'
                )
            else:
                results.append(
                    'You tried saving an invalid naming config, not saving your naming settings'
                )

        if self.isNamingValid(naming_abd_pattern, None, abd=True) != 'invalid':
            app.NAMING_ABD_PATTERN = naming_abd_pattern
        else:
            results.append(
                'You tried saving an invalid air-by-date naming config, not saving your air-by-date settings'
            )

        if self.isNamingValid(naming_sports_pattern, None,
                              sports=True) != 'invalid':
            app.NAMING_SPORTS_PATTERN = naming_sports_pattern
        else:
            results.append(
                'You tried saving an invalid sports naming config, not saving your sports settings'
            )

        app.save_config()

        if results:
            for x in results:
                logger.log(x, logger.WARNING)
            ui.notifications.error('Error(s) Saving Configuration',
                                   '<br>\n'.join(results))
        else:
            ui.notifications.message('Configuration Saved',
                                     ek(os.path.join, app.CONFIG_FILE))

        return self.redirect('/config/postProcessing/')
示例#9
0
    def saveSearch(self, use_nzbs=None, use_torrents=None, nzb_dir=None, sab_username=None, sab_password=None,
                   sab_apikey=None, sab_category=None, sab_category_anime=None, sab_category_backlog=None,
                   sab_category_anime_backlog=None, sab_host=None, nzbget_username=None, nzbget_password=None,
                   nzbget_category=None, nzbget_category_backlog=None, nzbget_category_anime=None,
                   nzbget_category_anime_backlog=None, nzbget_priority=None, nzbget_host=None,
                   nzbget_use_https=None, backlog_days=None, backlog_frequency=None, dailysearch_frequency=None,
                   nzb_method=None, torrent_method=None, usenet_retention=None, download_propers=None,
                   check_propers_interval=None, allow_high_priority=None, sab_forced=None,
                   randomize_providers=None, use_failed_downloads=None, delete_failed=None,
                   torrent_dir=None, torrent_username=None, torrent_password=None, torrent_host=None,
                   torrent_label=None, torrent_label_anime=None, torrent_path=None, torrent_verify_cert=None,
                   torrent_seed_time=None, torrent_paused=None, torrent_high_bandwidth=None,
                   torrent_rpcurl=None, torrent_auth_type=None, ignore_words=None,
                   preferred_words=None, undesired_words=None, trackers_list=None, require_words=None,
                   ignored_subs_list=None, ignore_und_subs=None, cache_trimming=None, max_cache_age=None):
        """
        Save Search related settings
        """

        results = []

        if not config.change_NZB_DIR(nzb_dir):
            results += ['Unable to create directory {dir}, dir not changed.'.format(dir=ek(os.path.normpath, nzb_dir))]

        if not config.change_TORRENT_DIR(torrent_dir):
            results += ['Unable to create directory {dir}, dir not changed.'.format(dir=ek(os.path.normpath, torrent_dir))]

        config.change_DAILYSEARCH_FREQUENCY(dailysearch_frequency)

        config.change_BACKLOG_FREQUENCY(backlog_frequency)
        app.BACKLOG_DAYS = try_int(backlog_days, 7)

        app.CACHE_TRIMMING = config.checkbox_to_value(cache_trimming)
        app.MAX_CACHE_AGE = try_int(max_cache_age, 0)

        app.USE_NZBS = config.checkbox_to_value(use_nzbs)
        app.USE_TORRENTS = config.checkbox_to_value(use_torrents)

        app.NZB_METHOD = nzb_method
        app.TORRENT_METHOD = torrent_method
        app.USENET_RETENTION = try_int(usenet_retention, 500)

        app.IGNORE_WORDS = ignore_words if ignore_words else ''
        app.PREFERRED_WORDS = preferred_words if preferred_words else ''
        app.UNDESIRED_WORDS = undesired_words if undesired_words else ''
        app.TRACKERS_LIST = trackers_list if trackers_list else ''
        app.REQUIRE_WORDS = require_words if require_words else ''
        app.IGNORED_SUBS_LIST = ignored_subs_list if ignored_subs_list else ''
        app.IGNORE_UND_SUBS = config.checkbox_to_value(ignore_und_subs)

        app.RANDOMIZE_PROVIDERS = config.checkbox_to_value(randomize_providers)

        config.change_DOWNLOAD_PROPERS(download_propers)

        app.CHECK_PROPERS_INTERVAL = check_propers_interval

        app.ALLOW_HIGH_PRIORITY = config.checkbox_to_value(allow_high_priority)

        app.USE_FAILED_DOWNLOADS = config.checkbox_to_value(use_failed_downloads)
        app.DELETE_FAILED = config.checkbox_to_value(delete_failed)

        app.SAB_USERNAME = sab_username
        app.SAB_PASSWORD = sab_password
        app.SAB_APIKEY = sab_apikey.strip()
        app.SAB_CATEGORY = sab_category
        app.SAB_CATEGORY_BACKLOG = sab_category_backlog
        app.SAB_CATEGORY_ANIME = sab_category_anime
        app.SAB_CATEGORY_ANIME_BACKLOG = sab_category_anime_backlog
        app.SAB_HOST = config.clean_url(sab_host)
        app.SAB_FORCED = config.checkbox_to_value(sab_forced)

        app.NZBGET_USERNAME = nzbget_username
        app.NZBGET_PASSWORD = nzbget_password
        app.NZBGET_CATEGORY = nzbget_category
        app.NZBGET_CATEGORY_BACKLOG = nzbget_category_backlog
        app.NZBGET_CATEGORY_ANIME = nzbget_category_anime
        app.NZBGET_CATEGORY_ANIME_BACKLOG = nzbget_category_anime_backlog
        app.NZBGET_HOST = config.clean_host(nzbget_host)
        app.NZBGET_USE_HTTPS = config.checkbox_to_value(nzbget_use_https)
        app.NZBGET_PRIORITY = try_int(nzbget_priority, 100)

        app.TORRENT_USERNAME = torrent_username
        app.TORRENT_PASSWORD = torrent_password
        app.TORRENT_LABEL = torrent_label
        app.TORRENT_LABEL_ANIME = torrent_label_anime
        app.TORRENT_VERIFY_CERT = config.checkbox_to_value(torrent_verify_cert)
        app.TORRENT_PATH = torrent_path.rstrip('/\\')
        app.TORRENT_SEED_TIME = torrent_seed_time
        app.TORRENT_PAUSED = config.checkbox_to_value(torrent_paused)
        app.TORRENT_HIGH_BANDWIDTH = config.checkbox_to_value(torrent_high_bandwidth)
        app.TORRENT_HOST = config.clean_url(torrent_host)
        app.TORRENT_RPCURL = torrent_rpcurl
        app.TORRENT_AUTH_TYPE = torrent_auth_type

        app.save_config()

        if results:
            for x in results:
                logger.log(x, logger.ERROR)
            ui.notifications.error('Error(s) Saving Configuration',
                                   '<br>\n'.join(results))
        else:
            ui.notifications.message('Configuration Saved', ek(os.path.join, app.CONFIG_FILE))

        return self.redirect('/config/search/')
示例#10
0
    def saveProviders(self,
                      newznab_string='',
                      torrentrss_string='',
                      provider_order=None,
                      **kwargs):
        """
        Save Provider related settings
        """
        results = []

        provider_str_list = provider_order.split()
        provider_list = []

        newznab_provider_dict = dict(
            zip([x.get_id() for x in app.newznabProviderList],
                app.newznabProviderList))

        finished_names = []

        # add all the newznab info we got into our list
        if newznab_string:
            for curNewznabProviderStr in newznab_string.split('!!!'):

                if not curNewznabProviderStr:
                    continue

                cur_name, cur_url, cur_key, cur_cat = curNewznabProviderStr.split(
                    '|')
                cur_url = config.clean_url(cur_url)

                new_provider = NewznabProvider(cur_name,
                                               cur_url,
                                               key=cur_key,
                                               catIDs=cur_cat)

                cur_id = new_provider.get_id()

                # if it already exists then update it
                if cur_id in newznab_provider_dict:
                    newznab_provider_dict[cur_id].name = cur_name
                    newznab_provider_dict[cur_id].url = cur_url
                    newznab_provider_dict[cur_id].key = cur_key
                    newznab_provider_dict[cur_id].catIDs = cur_cat
                    # a 0 in the key spot indicates that no key is needed
                    if cur_key == '0':
                        newznab_provider_dict[cur_id].needs_auth = False
                    else:
                        newznab_provider_dict[cur_id].needs_auth = True

                    try:
                        newznab_provider_dict[cur_id].search_mode = str(
                            kwargs['{id}_search_mode'.format(
                                id=cur_id)]).strip()
                    except (AttributeError, KeyError):
                        pass  # these exceptions are actually catching unselected checkboxes

                    try:
                        newznab_provider_dict[
                            cur_id].search_fallback = config.checkbox_to_value(
                                kwargs['{id}_search_fallback'.format(
                                    id=cur_id)])
                    except (AttributeError, KeyError):
                        newznab_provider_dict[
                            cur_id].search_fallback = 0  # these exceptions are actually catching unselected checkboxes

                    try:
                        newznab_provider_dict[
                            cur_id].enable_daily = config.checkbox_to_value(
                                kwargs['{id}_enable_daily'.format(id=cur_id)])
                    except (AttributeError, KeyError):
                        newznab_provider_dict[
                            cur_id].enable_daily = 0  # these exceptions are actually catching unselected checkboxes

                    try:
                        newznab_provider_dict[
                            cur_id].enable_manualsearch = config.checkbox_to_value(
                                kwargs['{id}_enable_manualsearch'.format(
                                    id=cur_id)])
                    except (AttributeError, KeyError):
                        newznab_provider_dict[
                            cur_id].enable_manualsearch = 0  # these exceptions are actually catching unselected checkboxes

                    try:
                        newznab_provider_dict[
                            cur_id].enable_backlog = config.checkbox_to_value(
                                kwargs['{id}_enable_backlog'.format(
                                    id=cur_id)])
                    except (AttributeError, KeyError):
                        newznab_provider_dict[
                            cur_id].enable_backlog = 0  # these exceptions are actually catching unselected checkboxes
                else:
                    app.newznabProviderList.append(new_provider)

                finished_names.append(cur_id)

        # delete anything that is missing
        for cur_provider in app.newznabProviderList:
            if cur_provider.get_id() not in finished_names:
                app.newznabProviderList.remove(cur_provider)

        torrent_rss_provider_dict = dict(
            zip([x.get_id() for x in app.torrentRssProviderList],
                app.torrentRssProviderList))
        finished_names = []

        if torrentrss_string:
            for curTorrentRssProviderStr in torrentrss_string.split('!!!'):

                if not curTorrentRssProviderStr:
                    continue

                cur_name, cur_url, cur_cookies, cur_title_tag = curTorrentRssProviderStr.split(
                    '|')
                cur_url = config.clean_url(cur_url)

                new_provider = TorrentRssProvider(cur_name, cur_url,
                                                  cur_cookies, cur_title_tag)

                cur_id = new_provider.get_id()

                # if it already exists then update it
                if cur_id in torrent_rss_provider_dict:
                    torrent_rss_provider_dict[cur_id].name = cur_name
                    torrent_rss_provider_dict[cur_id].url = cur_url
                    torrent_rss_provider_dict[cur_id].cookies = cur_cookies
                    torrent_rss_provider_dict[
                        cur_id].curTitleTAG = cur_title_tag
                else:
                    app.torrentRssProviderList.append(new_provider)

                finished_names.append(cur_id)

        # delete anything that is missing
        for cur_provider in app.torrentRssProviderList:
            if cur_provider.get_id() not in finished_names:
                app.torrentRssProviderList.remove(cur_provider)

        disabled_list = []
        # do the enable/disable
        for cur_providerStr in provider_str_list:
            cur_provider, cur_enabled = cur_providerStr.split(':')
            cur_enabled = try_int(cur_enabled)

            cur_prov_obj = [
                x for x in app.providers.sortedProviderList()
                if x.get_id() == cur_provider and hasattr(x, 'enabled')
            ]
            if cur_prov_obj:
                cur_prov_obj[0].enabled = bool(cur_enabled)

            if cur_enabled:
                provider_list.append(cur_provider)
            else:
                disabled_list.append(cur_provider)

            if cur_provider in newznab_provider_dict:
                newznab_provider_dict[cur_provider].enabled = bool(cur_enabled)
            elif cur_provider in torrent_rss_provider_dict:
                torrent_rss_provider_dict[cur_provider].enabled = bool(
                    cur_enabled)

        provider_list.extend(disabled_list)

        # dynamically load provider settings
        for curTorrentProvider in [
                prov for prov in app.providers.sortedProviderList()
                if prov.provider_type == GenericProvider.TORRENT
        ]:

            if hasattr(curTorrentProvider, 'custom_url'):
                try:
                    curTorrentProvider.custom_url = str(
                        kwargs['{id}_custom_url'.format(
                            id=curTorrentProvider.get_id())]).strip()
                except (AttributeError, KeyError):
                    curTorrentProvider.custom_url = None  # these exceptions are actually catching unselected checkboxes

            if hasattr(curTorrentProvider, 'minseed'):
                try:
                    curTorrentProvider.minseed = int(
                        str(kwargs['{id}_minseed'.format(
                            id=curTorrentProvider.get_id())]).strip())
                except (AttributeError, KeyError):
                    curTorrentProvider.minseed = 0  # these exceptions are actually catching unselected checkboxes

            if hasattr(curTorrentProvider, 'minleech'):
                try:
                    curTorrentProvider.minleech = int(
                        str(kwargs['{id}_minleech'.format(
                            id=curTorrentProvider.get_id())]).strip())
                except (AttributeError, KeyError):
                    curTorrentProvider.minleech = 0  # these exceptions are actually catching unselected checkboxes

            if hasattr(curTorrentProvider, 'ratio'):
                try:
                    ratio = float(
                        str(kwargs['{id}_ratio'.format(
                            id=curTorrentProvider.get_id())]).strip())
                    curTorrentProvider.ratio = (ratio, -1)[ratio < 0]
                except (AttributeError, KeyError, ValueError):
                    curTorrentProvider.ratio = None  # these exceptions are actually catching unselected checkboxes

            if hasattr(curTorrentProvider, 'digest'):
                try:
                    curTorrentProvider.digest = str(
                        kwargs['{id}_digest'.format(
                            id=curTorrentProvider.get_id())]).strip()
                except (AttributeError, KeyError):
                    curTorrentProvider.digest = None  # these exceptions are actually catching unselected checkboxes

            if hasattr(curTorrentProvider, 'hash'):
                try:
                    curTorrentProvider.hash = str(kwargs['{id}_hash'.format(
                        id=curTorrentProvider.get_id())]).strip()
                except (AttributeError, KeyError):
                    curTorrentProvider.hash = None  # these exceptions are actually catching unselected checkboxes

            if hasattr(curTorrentProvider, 'api_key'):
                try:
                    curTorrentProvider.api_key = str(
                        kwargs['{id}_api_key'.format(
                            id=curTorrentProvider.get_id())]).strip()
                except (AttributeError, KeyError):
                    curTorrentProvider.api_key = None  # these exceptions are actually catching unselected checkboxes

            if hasattr(curTorrentProvider, 'username'):
                try:
                    curTorrentProvider.username = str(
                        kwargs['{id}_username'.format(
                            id=curTorrentProvider.get_id())]).strip()
                except (AttributeError, KeyError):
                    curTorrentProvider.username = None  # these exceptions are actually catching unselected checkboxes

            if hasattr(curTorrentProvider, 'password'):
                try:
                    curTorrentProvider.password = str(
                        kwargs['{id}_password'.format(
                            id=curTorrentProvider.get_id())]).strip()
                except (AttributeError, KeyError):
                    curTorrentProvider.password = None  # these exceptions are actually catching unselected checkboxes

            if hasattr(curTorrentProvider, 'passkey'):
                try:
                    curTorrentProvider.passkey = str(
                        kwargs['{id}_passkey'.format(
                            id=curTorrentProvider.get_id())]).strip()
                except (AttributeError, KeyError):
                    curTorrentProvider.passkey = None  # these exceptions are actually catching unselected checkboxes

            if hasattr(curTorrentProvider, 'pin'):
                try:
                    curTorrentProvider.pin = str(kwargs['{id}_pin'.format(
                        id=curTorrentProvider.get_id())]).strip()
                except (AttributeError, KeyError):
                    curTorrentProvider.pin = None  # these exceptions are actually catching unselected checkboxes

            if hasattr(curTorrentProvider, 'confirmed'):
                try:
                    curTorrentProvider.confirmed = config.checkbox_to_value(
                        kwargs['{id}_confirmed'.format(
                            id=curTorrentProvider.get_id())])
                except (AttributeError, KeyError):
                    curTorrentProvider.confirmed = 0  # these exceptions are actually catching unselected checkboxes

            if hasattr(curTorrentProvider, 'ranked'):
                try:
                    curTorrentProvider.ranked = config.checkbox_to_value(
                        kwargs['{id}_ranked'.format(
                            id=curTorrentProvider.get_id())])
                except (AttributeError, KeyError):
                    curTorrentProvider.ranked = 0  # these exceptions are actually catching unselected checkboxes

            if hasattr(curTorrentProvider, 'engrelease'):
                try:
                    curTorrentProvider.engrelease = config.checkbox_to_value(
                        kwargs['{id}_engrelease'.format(
                            id=curTorrentProvider.get_id())])
                except (AttributeError, KeyError):
                    curTorrentProvider.engrelease = 0  # these exceptions are actually catching unselected checkboxes

            if hasattr(curTorrentProvider, 'onlyspasearch'):
                try:
                    curTorrentProvider.onlyspasearch = config.checkbox_to_value(
                        kwargs['{id}_onlyspasearch'.format(
                            id=curTorrentProvider.get_id())])
                except (AttributeError, KeyError):
                    curTorrentProvider.onlyspasearch = 0  # these exceptions are actually catching unselected checkboxes

            if hasattr(curTorrentProvider, 'sorting'):
                try:
                    curTorrentProvider.sorting = str(
                        kwargs['{id}_sorting'.format(
                            id=curTorrentProvider.get_id())]).strip()
                except (AttributeError, KeyError):
                    curTorrentProvider.sorting = 'seeders'  # these exceptions are actually catching unselected checkboxes

            if hasattr(curTorrentProvider, 'freeleech'):
                try:
                    curTorrentProvider.freeleech = config.checkbox_to_value(
                        kwargs['{id}_freeleech'.format(
                            id=curTorrentProvider.get_id())])
                except (AttributeError, KeyError):
                    curTorrentProvider.freeleech = 0  # these exceptions are actually catching unselected checkboxes

            if hasattr(curTorrentProvider, 'search_mode'):
                try:
                    curTorrentProvider.search_mode = str(
                        kwargs['{id}_search_mode'.format(
                            id=curTorrentProvider.get_id())]).strip()
                except (AttributeError, KeyError):
                    curTorrentProvider.search_mode = 'eponly'  # these exceptions are actually catching unselected checkboxes

            if hasattr(curTorrentProvider, 'search_fallback'):
                try:
                    curTorrentProvider.search_fallback = config.checkbox_to_value(
                        kwargs['{id}_search_fallback'.format(
                            id=curTorrentProvider.get_id())])
                except (AttributeError, KeyError):
                    curTorrentProvider.search_fallback = 0  # these exceptions are catching unselected checkboxes

            if hasattr(curTorrentProvider, 'enable_daily'):
                try:
                    curTorrentProvider.enable_daily = config.checkbox_to_value(
                        kwargs['{id}_enable_daily'.format(
                            id=curTorrentProvider.get_id())])
                except (AttributeError, KeyError):
                    curTorrentProvider.enable_daily = 0  # these exceptions are actually catching unselected checkboxes

            if hasattr(curTorrentProvider, 'enable_manualsearch'):
                try:
                    curTorrentProvider.enable_manualsearch = config.checkbox_to_value(
                        kwargs['{id}_enable_manualsearch'.format(
                            id=curTorrentProvider.get_id())])
                except (AttributeError, KeyError):
                    curTorrentProvider.enable_manualsearch = 0  # these exceptions are actually catching unselected checkboxes

            if hasattr(curTorrentProvider, 'enable_backlog'):
                try:
                    curTorrentProvider.enable_backlog = config.checkbox_to_value(
                        kwargs['{id}_enable_backlog'.format(
                            id=curTorrentProvider.get_id())])
                except (AttributeError, KeyError):
                    curTorrentProvider.enable_backlog = 0  # these exceptions are actually catching unselected checkboxes

            if hasattr(curTorrentProvider, 'cat'):
                try:
                    curTorrentProvider.cat = int(
                        str(kwargs['{id}_cat'.format(
                            id=curTorrentProvider.get_id())]).strip())
                except (AttributeError, KeyError):
                    curTorrentProvider.cat = 0  # these exceptions are actually catching unselected checkboxes

            if hasattr(curTorrentProvider, 'subtitle'):
                try:
                    curTorrentProvider.subtitle = config.checkbox_to_value(
                        kwargs['{id}_subtitle'.format(
                            id=curTorrentProvider.get_id())])
                except (AttributeError, KeyError):
                    curTorrentProvider.subtitle = 0  # these exceptions are actually catching unselected checkboxes

            if curTorrentProvider.enable_cookies:
                try:
                    curTorrentProvider.cookies = str(
                        kwargs['{id}_cookies'.format(
                            id=curTorrentProvider.get_id())]).strip()
                except (AttributeError, KeyError):
                    pass  # I don't want to configure a default value here, as it can also be configured intially as a custom rss torrent provider

        for curNzbProvider in [
                prov for prov in app.providers.sortedProviderList()
                if prov.provider_type == GenericProvider.NZB
        ]:

            if hasattr(curNzbProvider, 'api_key'):
                try:
                    curNzbProvider.api_key = str(kwargs['{id}_api_key'.format(
                        id=curNzbProvider.get_id())]).strip()
                except (AttributeError, KeyError):
                    curNzbProvider.api_key = None  # these exceptions are actually catching unselected checkboxes

            if hasattr(curNzbProvider, 'username'):
                try:
                    curNzbProvider.username = str(
                        kwargs['{id}_username'.format(
                            id=curNzbProvider.get_id())]).strip()
                except (AttributeError, KeyError):
                    curNzbProvider.username = None  # these exceptions are actually catching unselected checkboxes

            if hasattr(curNzbProvider, 'search_mode'):
                try:
                    curNzbProvider.search_mode = str(
                        kwargs['{id}_search_mode'.format(
                            id=curNzbProvider.get_id())]).strip()
                except (AttributeError, KeyError):
                    curNzbProvider.search_mode = 'eponly'  # these exceptions are actually catching unselected checkboxes

            if hasattr(curNzbProvider, 'search_fallback'):
                try:
                    curNzbProvider.search_fallback = config.checkbox_to_value(
                        kwargs['{id}_search_fallback'.format(
                            id=curNzbProvider.get_id())])
                except (AttributeError, KeyError):
                    curNzbProvider.search_fallback = 0  # these exceptions are actually catching unselected checkboxes

            if hasattr(curNzbProvider, 'enable_daily'):
                try:
                    curNzbProvider.enable_daily = config.checkbox_to_value(
                        kwargs['{id}_enable_daily'.format(
                            id=curNzbProvider.get_id())])
                except (AttributeError, KeyError):
                    curNzbProvider.enable_daily = 0  # these exceptions are actually catching unselected checkboxes

            if hasattr(curNzbProvider, 'enable_manualsearch'):
                try:
                    curNzbProvider.enable_manualsearch = config.checkbox_to_value(
                        kwargs['{id}_enable_manualsearch'.format(
                            id=curNzbProvider.get_id())])
                except (AttributeError, KeyError):
                    curNzbProvider.enable_manualsearch = 0  # these exceptions are actually catching unselected checkboxes

            if hasattr(curNzbProvider, 'enable_backlog'):
                try:
                    curNzbProvider.enable_backlog = config.checkbox_to_value(
                        kwargs['{id}_enable_backlog'.format(
                            id=curNzbProvider.get_id())])
                except (AttributeError, KeyError):
                    curNzbProvider.enable_backlog = 0  # these exceptions are actually catching unselected checkboxes

        app.NEWZNAB_DATA = '!!!'.join(
            [x.config_string() for x in app.newznabProviderList])
        app.PROVIDER_ORDER = provider_list

        app.save_config()

        if results:
            for x in results:
                logger.log(x, logger.ERROR)
            ui.notifications.error('Error(s) Saving Configuration',
                                   '<br>\n'.join(results))
        else:
            ui.notifications.message('Configuration Saved',
                                     ek(os.path.join, app.CONFIG_FILE))

        return self.redirect('/config/providers/')
示例#11
0
文件: base.py 项目: DazzFX/SickRage-1
    def setPosterSortDir(direction):

        app.POSTER_SORTDIR = int(direction)
        app.save_config()
示例#12
0
文件: base.py 项目: DazzFX/SickRage-1
    def setPosterSortBy(sort):
        if sort not in ('name', 'date', 'network', 'progress'):
            sort = 'name'

        app.POSTER_SORTBY = sort
        app.save_config()
示例#13
0
    def saveNotifications(self,
                          use_kodi=None,
                          kodi_always_on=None,
                          kodi_notify_onsnatch=None,
                          kodi_notify_ondownload=None,
                          kodi_notify_onsubtitledownload=None,
                          kodi_update_onlyfirst=None,
                          kodi_update_library=None,
                          kodi_update_full=None,
                          kodi_host=None,
                          kodi_username=None,
                          kodi_password=None,
                          kodi_clean_library=None,
                          use_plex_server=None,
                          plex_notify_onsnatch=None,
                          plex_notify_ondownload=None,
                          plex_notify_onsubtitledownload=None,
                          plex_update_library=None,
                          plex_server_host=None,
                          plex_server_token=None,
                          plex_client_host=None,
                          plex_server_username=None,
                          plex_server_password=None,
                          use_plex_client=None,
                          plex_client_username=None,
                          plex_client_password=None,
                          plex_server_https=None,
                          use_emby=None,
                          emby_host=None,
                          emby_apikey=None,
                          use_growl=None,
                          growl_notify_onsnatch=None,
                          growl_notify_ondownload=None,
                          growl_notify_onsubtitledownload=None,
                          growl_host=None,
                          growl_password=None,
                          use_freemobile=None,
                          freemobile_notify_onsnatch=None,
                          freemobile_notify_ondownload=None,
                          freemobile_notify_onsubtitledownload=None,
                          freemobile_id=None,
                          freemobile_apikey=None,
                          use_telegram=None,
                          telegram_notify_onsnatch=None,
                          telegram_notify_ondownload=None,
                          telegram_notify_onsubtitledownload=None,
                          telegram_id=None,
                          telegram_apikey=None,
                          use_prowl=None,
                          prowl_notify_onsnatch=None,
                          prowl_notify_ondownload=None,
                          prowl_notify_onsubtitledownload=None,
                          prowl_api=None,
                          prowl_priority=0,
                          prowl_show_list=None,
                          prowl_show=None,
                          prowl_message_title=None,
                          use_twitter=None,
                          twitter_notify_onsnatch=None,
                          twitter_notify_ondownload=None,
                          twitter_notify_onsubtitledownload=None,
                          twitter_usedm=None,
                          twitter_dmto=None,
                          use_boxcar2=None,
                          boxcar2_notify_onsnatch=None,
                          boxcar2_notify_ondownload=None,
                          boxcar2_notify_onsubtitledownload=None,
                          boxcar2_accesstoken=None,
                          use_pushover=None,
                          pushover_notify_onsnatch=None,
                          pushover_notify_ondownload=None,
                          pushover_notify_onsubtitledownload=None,
                          pushover_userkey=None,
                          pushover_apikey=None,
                          pushover_device=None,
                          pushover_sound=None,
                          use_libnotify=None,
                          libnotify_notify_onsnatch=None,
                          libnotify_notify_ondownload=None,
                          libnotify_notify_onsubtitledownload=None,
                          use_nmj=None,
                          nmj_host=None,
                          nmj_database=None,
                          nmj_mount=None,
                          use_synoindex=None,
                          use_nmjv2=None,
                          nmjv2_host=None,
                          nmjv2_dbloc=None,
                          nmjv2_database=None,
                          use_trakt=None,
                          trakt_username=None,
                          trakt_pin=None,
                          trakt_remove_watchlist=None,
                          trakt_sync_watchlist=None,
                          trakt_remove_show_from_application=None,
                          trakt_method_add=None,
                          trakt_start_paused=None,
                          trakt_use_recommended=None,
                          trakt_sync=None,
                          trakt_sync_remove=None,
                          trakt_default_indexer=None,
                          trakt_remove_serieslist=None,
                          trakt_timeout=None,
                          trakt_blacklist_name=None,
                          use_synologynotifier=None,
                          synologynotifier_notify_onsnatch=None,
                          synologynotifier_notify_ondownload=None,
                          synologynotifier_notify_onsubtitledownload=None,
                          use_pytivo=None,
                          pytivo_notify_onsnatch=None,
                          pytivo_notify_ondownload=None,
                          pytivo_notify_onsubtitledownload=None,
                          pytivo_update_library=None,
                          pytivo_host=None,
                          pytivo_share_name=None,
                          pytivo_tivo_name=None,
                          use_nma=None,
                          nma_notify_onsnatch=None,
                          nma_notify_ondownload=None,
                          nma_notify_onsubtitledownload=None,
                          nma_api=None,
                          nma_priority=0,
                          use_pushalot=None,
                          pushalot_notify_onsnatch=None,
                          pushalot_notify_ondownload=None,
                          pushalot_notify_onsubtitledownload=None,
                          pushalot_authorizationtoken=None,
                          use_pushbullet=None,
                          pushbullet_notify_onsnatch=None,
                          pushbullet_notify_ondownload=None,
                          pushbullet_notify_onsubtitledownload=None,
                          pushbullet_api=None,
                          pushbullet_device=None,
                          pushbullet_device_list=None,
                          use_email=None,
                          email_notify_onsnatch=None,
                          email_notify_ondownload=None,
                          email_notify_onsubtitledownload=None,
                          email_host=None,
                          email_port=25,
                          email_from=None,
                          email_tls=None,
                          email_user=None,
                          email_password=None,
                          email_list=None,
                          email_subject=None,
                          email_show_list=None,
                          email_show=None):
        """
        Save notification related settings
        """

        results = []

        app.USE_KODI = config.checkbox_to_value(use_kodi)
        app.KODI_ALWAYS_ON = config.checkbox_to_value(kodi_always_on)
        app.KODI_NOTIFY_ONSNATCH = config.checkbox_to_value(
            kodi_notify_onsnatch)
        app.KODI_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(
            kodi_notify_ondownload)
        app.KODI_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(
            kodi_notify_onsubtitledownload)
        app.KODI_UPDATE_LIBRARY = config.checkbox_to_value(kodi_update_library)
        app.KODI_UPDATE_FULL = config.checkbox_to_value(kodi_update_full)
        app.KODI_UPDATE_ONLYFIRST = config.checkbox_to_value(
            kodi_update_onlyfirst)
        app.KODI_HOST = config.clean_hosts(kodi_host)
        app.KODI_USERNAME = kodi_username
        app.KODI_PASSWORD = kodi_password
        app.KODI_CLEAN_LIBRARY = config.checkbox_to_value(kodi_clean_library)

        app.USE_PLEX_SERVER = config.checkbox_to_value(use_plex_server)
        app.PLEX_NOTIFY_ONSNATCH = config.checkbox_to_value(
            plex_notify_onsnatch)
        app.PLEX_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(
            plex_notify_ondownload)
        app.PLEX_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(
            plex_notify_onsubtitledownload)
        app.PLEX_UPDATE_LIBRARY = config.checkbox_to_value(plex_update_library)
        app.PLEX_CLIENT_HOST = config.clean_hosts(plex_client_host)
        app.PLEX_SERVER_HOST = config.clean_hosts(plex_server_host)
        app.PLEX_SERVER_TOKEN = config.clean_host(plex_server_token)
        app.PLEX_SERVER_USERNAME = plex_server_username
        if plex_server_password != '*' * len(app.PLEX_SERVER_PASSWORD):
            app.PLEX_SERVER_PASSWORD = plex_server_password

        app.USE_PLEX_CLIENT = config.checkbox_to_value(use_plex_client)
        app.PLEX_CLIENT_USERNAME = plex_client_username
        if plex_client_password != '*' * len(app.PLEX_CLIENT_PASSWORD):
            app.PLEX_CLIENT_PASSWORD = plex_client_password
        app.PLEX_SERVER_HTTPS = config.checkbox_to_value(plex_server_https)

        app.USE_EMBY = config.checkbox_to_value(use_emby)
        app.EMBY_HOST = config.clean_host(emby_host)
        app.EMBY_APIKEY = emby_apikey

        app.USE_GROWL = config.checkbox_to_value(use_growl)
        app.GROWL_NOTIFY_ONSNATCH = config.checkbox_to_value(
            growl_notify_onsnatch)
        app.GROWL_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(
            growl_notify_ondownload)
        app.GROWL_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(
            growl_notify_onsubtitledownload)
        app.GROWL_HOST = config.clean_host(growl_host, default_port=23053)
        app.GROWL_PASSWORD = growl_password

        app.USE_FREEMOBILE = config.checkbox_to_value(use_freemobile)
        app.FREEMOBILE_NOTIFY_ONSNATCH = config.checkbox_to_value(
            freemobile_notify_onsnatch)
        app.FREEMOBILE_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(
            freemobile_notify_ondownload)
        app.FREEMOBILE_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(
            freemobile_notify_onsubtitledownload)
        app.FREEMOBILE_ID = freemobile_id
        app.FREEMOBILE_APIKEY = freemobile_apikey

        app.USE_TELEGRAM = config.checkbox_to_value(use_telegram)
        app.TELEGRAM_NOTIFY_ONSNATCH = config.checkbox_to_value(
            telegram_notify_onsnatch)
        app.TELEGRAM_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(
            telegram_notify_ondownload)
        app.TELEGRAM_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(
            telegram_notify_onsubtitledownload)
        app.TELEGRAM_ID = telegram_id
        app.TELEGRAM_APIKEY = telegram_apikey

        app.USE_PROWL = config.checkbox_to_value(use_prowl)
        app.PROWL_NOTIFY_ONSNATCH = config.checkbox_to_value(
            prowl_notify_onsnatch)
        app.PROWL_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(
            prowl_notify_ondownload)
        app.PROWL_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(
            prowl_notify_onsubtitledownload)
        app.PROWL_API = prowl_api
        app.PROWL_PRIORITY = prowl_priority
        app.PROWL_MESSAGE_TITLE = prowl_message_title

        app.USE_TWITTER = config.checkbox_to_value(use_twitter)
        app.TWITTER_NOTIFY_ONSNATCH = config.checkbox_to_value(
            twitter_notify_onsnatch)
        app.TWITTER_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(
            twitter_notify_ondownload)
        app.TWITTER_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(
            twitter_notify_onsubtitledownload)
        app.TWITTER_USEDM = config.checkbox_to_value(twitter_usedm)
        app.TWITTER_DMTO = twitter_dmto

        app.USE_BOXCAR2 = config.checkbox_to_value(use_boxcar2)
        app.BOXCAR2_NOTIFY_ONSNATCH = config.checkbox_to_value(
            boxcar2_notify_onsnatch)
        app.BOXCAR2_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(
            boxcar2_notify_ondownload)
        app.BOXCAR2_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(
            boxcar2_notify_onsubtitledownload)
        app.BOXCAR2_ACCESSTOKEN = boxcar2_accesstoken

        app.USE_PUSHOVER = config.checkbox_to_value(use_pushover)
        app.PUSHOVER_NOTIFY_ONSNATCH = config.checkbox_to_value(
            pushover_notify_onsnatch)
        app.PUSHOVER_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(
            pushover_notify_ondownload)
        app.PUSHOVER_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(
            pushover_notify_onsubtitledownload)
        app.PUSHOVER_USERKEY = pushover_userkey
        app.PUSHOVER_APIKEY = pushover_apikey
        app.PUSHOVER_DEVICE = pushover_device
        app.PUSHOVER_SOUND = pushover_sound

        app.USE_LIBNOTIFY = config.checkbox_to_value(use_libnotify)
        app.LIBNOTIFY_NOTIFY_ONSNATCH = config.checkbox_to_value(
            libnotify_notify_onsnatch)
        app.LIBNOTIFY_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(
            libnotify_notify_ondownload)
        app.LIBNOTIFY_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(
            libnotify_notify_onsubtitledownload)

        app.USE_NMJ = config.checkbox_to_value(use_nmj)
        app.NMJ_HOST = config.clean_host(nmj_host)
        app.NMJ_DATABASE = nmj_database
        app.NMJ_MOUNT = nmj_mount

        app.USE_NMJv2 = config.checkbox_to_value(use_nmjv2)
        app.NMJv2_HOST = config.clean_host(nmjv2_host)
        app.NMJv2_DATABASE = nmjv2_database
        app.NMJv2_DBLOC = nmjv2_dbloc

        app.USE_SYNOINDEX = config.checkbox_to_value(use_synoindex)

        app.USE_SYNOLOGYNOTIFIER = config.checkbox_to_value(
            use_synologynotifier)
        app.SYNOLOGYNOTIFIER_NOTIFY_ONSNATCH = config.checkbox_to_value(
            synologynotifier_notify_onsnatch)
        app.SYNOLOGYNOTIFIER_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(
            synologynotifier_notify_ondownload)
        app.SYNOLOGYNOTIFIER_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(
            synologynotifier_notify_onsubtitledownload)

        config.change_USE_TRAKT(use_trakt)
        app.TRAKT_USERNAME = trakt_username
        app.TRAKT_REMOVE_WATCHLIST = config.checkbox_to_value(
            trakt_remove_watchlist)
        app.TRAKT_REMOVE_SERIESLIST = config.checkbox_to_value(
            trakt_remove_serieslist)
        app.TRAKT_REMOVE_SHOW_FROM_APPLICATION = config.checkbox_to_value(
            trakt_remove_show_from_application)
        app.TRAKT_SYNC_WATCHLIST = config.checkbox_to_value(
            trakt_sync_watchlist)
        app.TRAKT_METHOD_ADD = int(trakt_method_add)
        app.TRAKT_START_PAUSED = config.checkbox_to_value(trakt_start_paused)
        app.TRAKT_USE_RECOMMENDED = config.checkbox_to_value(
            trakt_use_recommended)
        app.TRAKT_SYNC = config.checkbox_to_value(trakt_sync)
        app.TRAKT_SYNC_REMOVE = config.checkbox_to_value(trakt_sync_remove)
        app.TRAKT_DEFAULT_INDEXER = int(trakt_default_indexer)
        app.TRAKT_TIMEOUT = int(trakt_timeout)
        app.TRAKT_BLACKLIST_NAME = trakt_blacklist_name

        app.USE_EMAIL = config.checkbox_to_value(use_email)
        app.EMAIL_NOTIFY_ONSNATCH = config.checkbox_to_value(
            email_notify_onsnatch)
        app.EMAIL_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(
            email_notify_ondownload)
        app.EMAIL_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(
            email_notify_onsubtitledownload)
        app.EMAIL_HOST = config.clean_host(email_host)
        app.EMAIL_PORT = try_int(email_port, 25)
        app.EMAIL_FROM = email_from
        app.EMAIL_TLS = config.checkbox_to_value(email_tls)
        app.EMAIL_USER = email_user
        app.EMAIL_PASSWORD = email_password
        app.EMAIL_LIST = email_list
        app.EMAIL_SUBJECT = email_subject

        app.USE_PYTIVO = config.checkbox_to_value(use_pytivo)
        app.PYTIVO_NOTIFY_ONSNATCH = config.checkbox_to_value(
            pytivo_notify_onsnatch)
        app.PYTIVO_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(
            pytivo_notify_ondownload)
        app.PYTIVO_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(
            pytivo_notify_onsubtitledownload)
        app.PYTIVO_UPDATE_LIBRARY = config.checkbox_to_value(
            pytivo_update_library)
        app.PYTIVO_HOST = config.clean_host(pytivo_host)
        app.PYTIVO_SHARE_NAME = pytivo_share_name
        app.PYTIVO_TIVO_NAME = pytivo_tivo_name

        app.USE_NMA = config.checkbox_to_value(use_nma)
        app.NMA_NOTIFY_ONSNATCH = config.checkbox_to_value(nma_notify_onsnatch)
        app.NMA_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(
            nma_notify_ondownload)
        app.NMA_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(
            nma_notify_onsubtitledownload)
        app.NMA_API = nma_api
        app.NMA_PRIORITY = nma_priority

        app.USE_PUSHALOT = config.checkbox_to_value(use_pushalot)
        app.PUSHALOT_NOTIFY_ONSNATCH = config.checkbox_to_value(
            pushalot_notify_onsnatch)
        app.PUSHALOT_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(
            pushalot_notify_ondownload)
        app.PUSHALOT_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(
            pushalot_notify_onsubtitledownload)
        app.PUSHALOT_AUTHORIZATIONTOKEN = pushalot_authorizationtoken

        app.USE_PUSHBULLET = config.checkbox_to_value(use_pushbullet)
        app.PUSHBULLET_NOTIFY_ONSNATCH = config.checkbox_to_value(
            pushbullet_notify_onsnatch)
        app.PUSHBULLET_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(
            pushbullet_notify_ondownload)
        app.PUSHBULLET_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(
            pushbullet_notify_onsubtitledownload)
        app.PUSHBULLET_API = pushbullet_api
        app.PUSHBULLET_DEVICE = pushbullet_device_list

        app.save_config()

        if results:
            for x in results:
                logger.log(x, logger.ERROR)
            ui.notifications.error('Error(s) Saving Configuration',
                                   '<br>\n'.join(results))
        else:
            ui.notifications.message('Configuration Saved',
                                     os.path.join(app.CONFIG_FILE))

        return self.redirect('/config/notifications/')