def test_clean_url(self): """ Test cleaning of urls """ log = logging.getLogger(__name__) test = namedtuple('test', 'expected_result dirty clean') url_tests = [ test(True, "https://subdomain.domain.tld/endpoint", "https://subdomain.domain.tld/endpoint" ), # does not add a final / test(True, "http://www.example.com/folder/", "http://www.example.com/folder/" ), # does not remove the final / test(True, "google.com/xml.rpc", "http://google.com/xml.rpc"), # add scheme if missing test(True, "google.com", "http://google.com/" ), # add scheme if missing and final / if its just the domain test(True, "scgi:///home/user/.config/path/socket", "scgi:///home/user/.config/path/socket" ), # scgi identified as scheme test(True, None, ''), # None URL returns empty string test(False, "https://subdomain.domain.tld/endpoint", "http://subdomain.domain.tld/endpoint" ), # does not change schemes from https to http test(False, "http://subdomain.domain.tld/endpoint", "https://subdomain.domain.tld/endpoint"), # ...or vice versa test(False, "google.com/xml.rpc", "google.com/xml.rpc"), # scheme is always added test(False, "google.com", "https://google.com/"), # does not default to https test(False, "http://www.example.com/folder/", "http://www.example.com/folder"), # does not strip final / test(False, "scgi:///home/user/.config/path/socket", "scgi:///home/user/.config/path/socket/" ), # does not add a final / test(AttributeError, 1, 1), # None URL returns empty string ] for test_url in url_tests: if issubclass(type(Exception), type(test_url.expected_result)): with self.assertRaises(test_url.expected_result): self.assertEqual(config.clean_url(test_url.dirty), test_url.clean) elif test_url.expected_result is True: self.assertEqual(config.clean_url(test_url.dirty), test_url.clean) elif test_url.expected_result is False: self.assertNotEqual(config.clean_url(test_url.dirty), test_url.clean) else: log.error('Test not defined for %s', test_url)
def canAddTorrentRssProvider(name, url, cookies, titleTAG): if not name: return json.dumps({"error": "Invalid name specified"}) url = config.clean_url(url) tempProvider = rsstorrent.TorrentRssProvider(name, url, cookies, titleTAG) if tempProvider.get_id() in (x.get_id() for x in settings.torrentRssProviderList): return json.dumps({"error": "Exists as " + tempProvider.name}) else: (succ, errMsg) = tempProvider.validateRSS() if succ: return json.dumps({"success": tempProvider.get_id()}) else: return json.dumps({"error": errMsg})
def saveGeneral(self, 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, fanart_background=None, fanart_background_opacity=None, sickchill_background=None, sickchill_background_path=None, custom_css=None, custom_css_path=None, git_reset=None, git_username=None, git_token=None, display_all_seasons=None, gui_language=None, ignore_broken_symlinks=None, ended_shows_update_interval=None): results = [] if gui_language != settings.GUI_LANG: setup_gettext(gui_language) settings.GUI_LANG = gui_language # Misc settings.DOWNLOAD_URL = download_url settings.INDEXER_DEFAULT_LANGUAGE = indexerDefaultLang settings.EP_DEFAULT_DELETED_STATUS = ep_default_deleted_status settings.SKIP_REMOVED_FILES = config.checkbox_to_value( skip_removed_files) settings.LAUNCH_BROWSER = config.checkbox_to_value(launch_browser) config.change_showupdate_hour(showupdate_hour) config.change_version_notify(version_notify) settings.AUTO_UPDATE = config.checkbox_to_value(auto_update) settings.NOTIFY_ON_UPDATE = config.checkbox_to_value(notify_on_update) settings.LOG_NR = log_nr settings.LOG_SIZE = float(log_size) settings.WEB_LOG = config.checkbox_to_value(web_log) settings.TRASH_REMOVE_SHOW = config.checkbox_to_value( trash_remove_show) settings.TRASH_ROTATE_LOGS = config.checkbox_to_value( trash_rotate_logs) settings.IGNORE_BROKEN_SYMLINKS = config.checkbox_to_value( ignore_broken_symlinks) config.change_update_frequency(update_frequency) settings.LAUNCH_BROWSER = config.checkbox_to_value(launch_browser) settings.SORT_ARTICLE = config.checkbox_to_value(sort_article) settings.CPU_PRESET = cpu_preset settings.ANON_REDIRECT = anon_redirect settings.PROXY_SETTING = proxy_setting if settings.PROXY_SETTING: settings.PROXY_SETTING = config.clean_url( settings.PROXY_SETTING).rstrip('/') settings.PROXY_INDEXERS = config.checkbox_to_value(proxy_indexers) settings.GIT_USERNAME = git_username tmp_git_token = filters.unhide(settings.GIT_TOKEN, git_token) if settings.GIT_TOKEN != tmp_git_token: # Re-Initializes oldbeard.gh, so a restart isn't necessary settings.GIT_TOKEN = tmp_git_token setup_github() # oldbeard.GIT_RESET = config.checkbox_to_value(git_reset) # Force GIT_RESET settings.GIT_RESET = 1 settings.GIT_PATH = git_path settings.GIT_REMOTE = git_remote settings.CALENDAR_UNPROTECTED = config.checkbox_to_value( calendar_unprotected) settings.CALENDAR_ICONS = config.checkbox_to_value(calendar_icons) settings.NO_RESTART = config.checkbox_to_value(no_restart) settings.DEBUG = config.checkbox_to_value(debug) logger.set_level() settings.SSL_VERIFY = config.checkbox_to_value(ssl_verify) settings.COMING_EPS_MISSED_RANGE = config.min_max( coming_eps_missed_range, 7, 0, 42810) settings.DISPLAY_ALL_SEASONS = config.checkbox_to_value( display_all_seasons) settings.NOTIFY_ON_LOGIN = config.checkbox_to_value(notify_on_login) settings.WEB_PORT = try_int(web_port) settings.WEB_IPV6 = config.checkbox_to_value(web_ipv6) settings.ENCRYPTION_VERSION = config.checkbox_to_value( encryption_version, value_on=2, value_off=0) settings.WEB_USERNAME = web_username settings.WEB_PASSWORD = filters.unhide(settings.WEB_PASSWORD, web_password) settings.FUZZY_DATING = config.checkbox_to_value(fuzzy_dating) settings.TRIM_ZERO = config.checkbox_to_value(trim_zero) if date_preset: settings.DATE_PRESET = date_preset if indexer_default: settings.INDEXER_DEFAULT = try_int(indexer_default) if indexer_timeout: settings.INDEXER_TIMEOUT = try_int(indexer_timeout) if time_preset: settings.TIME_PRESET_W_SECONDS = time_preset settings.TIME_PRESET = time_preset.replace(":%S", "") settings.TIMEZONE_DISPLAY = timezone_display settings.API_KEY = api_key settings.ENABLE_HTTPS = config.checkbox_to_value(enable_https) if not config.change_https_cert(https_cert): results += [ _("Unable to create directory {directory}, https cert directory not changed." ).format(directory=os.path.normpath(https_cert)) ] if not config.change_https_key(https_key): results += [ _("Unable to create directory {directory}, https key directory not changed." ).format(directory=os.path.normpath(https_key)) ] settings.HANDLE_REVERSE_PROXY = config.checkbox_to_value( handle_reverse_proxy) settings.THEME_NAME = theme_name settings.SICKCHILL_BACKGROUND = config.checkbox_to_value( sickchill_background) config.change_sickchill_background(sickchill_background_path) settings.FANART_BACKGROUND = config.checkbox_to_value( fanart_background) settings.FANART_BACKGROUND_OPACITY = fanart_background_opacity settings.CUSTOM_CSS = config.checkbox_to_value(custom_css) config.change_custom_css(custom_css_path) settings.ENDED_SHOWS_UPDATE_INTERVAL = int(ended_shows_update_interval) settings.DEFAULT_PAGE = default_page sickchill.start.save_config() if len(results) > 0: for x in results: logger.exception(x) ui.notifications.error(_('Error(s) Saving Configuration'), '<br>\n'.join(results)) else: ui.notifications.message(_('Configuration Saved'), os.path.join(settings.CONFIG_FILE)) return self.redirect("/config/general/")
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, 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_join=None, join_notify_onsnatch=None, join_notify_ondownload=None, join_notify_onsubtitledownload=None, join_id=None, join_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_twilio=None, twilio_notify_onsnatch=None, twilio_notify_ondownload=None, twilio_notify_onsubtitledownload=None, twilio_phone_sid=None, twilio_account_sid=None, twilio_auth_token=None, twilio_to_number=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, pushover_priority=0, 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_sickchill=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_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, pushbullet_channel_list=None, pushbullet_channel=None, use_email=None, email_notify_onsnatch=None, email_notify_ondownload=None, email_notify_onpostprocess=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, use_slack=False, slack_notify_snatch=None, slack_notify_download=None, slack_notify_subtitledownload=None, slack_webhook=None, slack_icon_emoji=None, use_rocketchat=False, rocketchat_notify_snatch=None, rocketchat_notify_download=None, rocketchat_notify_subtitledownload=None, rocketchat_webhook=None, rocketchat_icon_emoji=None, use_matrix=False, matrix_notify_snatch=None, matrix_notify_download=None, matrix_notify_subtitledownload=None, matrix_api_token=None, matrix_server=None, matrix_room=None, use_discord=False, discord_notify_snatch=None, discord_notify_download=None, discord_webhook=None, discord_name=None, discord_avatar_url=None, discord_tts=False): results = [] settings.USE_KODI = config.checkbox_to_value(use_kodi) settings.KODI_ALWAYS_ON = config.checkbox_to_value(kodi_always_on) settings.KODI_NOTIFY_ONSNATCH = config.checkbox_to_value( kodi_notify_onsnatch) settings.KODI_NOTIFY_ONDOWNLOAD = config.checkbox_to_value( kodi_notify_ondownload) settings.KODI_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value( kodi_notify_onsubtitledownload) settings.KODI_UPDATE_LIBRARY = config.checkbox_to_value( kodi_update_library) settings.KODI_UPDATE_FULL = config.checkbox_to_value(kodi_update_full) settings.KODI_UPDATE_ONLYFIRST = config.checkbox_to_value( kodi_update_onlyfirst) settings.KODI_HOST = config.clean_hosts(kodi_host) settings.KODI_USERNAME = kodi_username settings.KODI_PASSWORD = filters.unhide(settings.KODI_PASSWORD, kodi_password) settings.USE_PLEX_SERVER = config.checkbox_to_value(use_plex_server) settings.PLEX_NOTIFY_ONSNATCH = config.checkbox_to_value( plex_notify_onsnatch) settings.PLEX_NOTIFY_ONDOWNLOAD = config.checkbox_to_value( plex_notify_ondownload) settings.PLEX_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value( plex_notify_onsubtitledownload) settings.PLEX_UPDATE_LIBRARY = config.checkbox_to_value( plex_update_library) settings.PLEX_CLIENT_HOST = config.clean_hosts(plex_client_host) settings.PLEX_SERVER_HOST = config.clean_hosts(plex_server_host) settings.PLEX_SERVER_TOKEN = config.clean_host(plex_server_token) settings.PLEX_SERVER_USERNAME = plex_server_username settings.PLEX_SERVER_PASSWORD = filters.unhide( settings.PLEX_SERVER_PASSWORD, plex_server_password) settings.USE_PLEX_CLIENT = config.checkbox_to_value(use_plex_client) settings.PLEX_CLIENT_USERNAME = plex_client_username settings.PLEX_CLIENT_PASSWORD = filters.unhide( settings.PLEX_CLIENT_PASSWORD, plex_client_password) settings.PLEX_SERVER_HTTPS = config.checkbox_to_value( plex_server_https) settings.USE_EMBY = config.checkbox_to_value(use_emby) settings.EMBY_HOST = config.clean_url(emby_host) settings.EMBY_APIKEY = filters.unhide(settings.EMBY_APIKEY, emby_apikey) settings.USE_GROWL = config.checkbox_to_value(use_growl) settings.GROWL_NOTIFY_ONSNATCH = config.checkbox_to_value( growl_notify_onsnatch) settings.GROWL_NOTIFY_ONDOWNLOAD = config.checkbox_to_value( growl_notify_ondownload) settings.GROWL_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value( growl_notify_onsubtitledownload) settings.GROWL_HOST = config.clean_host(growl_host, default_port=23053) settings.GROWL_PASSWORD = filters.unhide(settings.GROWL_PASSWORD, growl_password) settings.USE_FREEMOBILE = config.checkbox_to_value(use_freemobile) settings.FREEMOBILE_NOTIFY_ONSNATCH = config.checkbox_to_value( freemobile_notify_onsnatch) settings.FREEMOBILE_NOTIFY_ONDOWNLOAD = config.checkbox_to_value( freemobile_notify_ondownload) settings.FREEMOBILE_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value( freemobile_notify_onsubtitledownload) settings.FREEMOBILE_ID = freemobile_id settings.FREEMOBILE_APIKEY = filters.unhide(settings.FREEMOBILE_APIKEY, freemobile_apikey) settings.USE_TELEGRAM = config.checkbox_to_value(use_telegram) settings.TELEGRAM_NOTIFY_ONSNATCH = config.checkbox_to_value( telegram_notify_onsnatch) settings.TELEGRAM_NOTIFY_ONDOWNLOAD = config.checkbox_to_value( telegram_notify_ondownload) settings.TELEGRAM_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value( telegram_notify_onsubtitledownload) settings.TELEGRAM_ID = telegram_id settings.TELEGRAM_APIKEY = filters.unhide(settings.TELEGRAM_APIKEY, telegram_apikey) settings.USE_JOIN = config.checkbox_to_value(use_join) settings.JOIN_NOTIFY_ONSNATCH = config.checkbox_to_value( join_notify_onsnatch) settings.JOIN_NOTIFY_ONDOWNLOAD = config.checkbox_to_value( join_notify_ondownload) settings.JOIN_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value( join_notify_onsubtitledownload) settings.JOIN_ID = join_id settings.JOIN_APIKEY = filters.unhide(settings.JOIN_APIKEY, join_apikey) settings.USE_PROWL = config.checkbox_to_value(use_prowl) settings.PROWL_NOTIFY_ONSNATCH = config.checkbox_to_value( prowl_notify_onsnatch) settings.PROWL_NOTIFY_ONDOWNLOAD = config.checkbox_to_value( prowl_notify_ondownload) settings.PROWL_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value( prowl_notify_onsubtitledownload) settings.PROWL_API = prowl_api settings.PROWL_PRIORITY = prowl_priority settings.PROWL_MESSAGE_TITLE = prowl_message_title settings.USE_TWITTER = config.checkbox_to_value(use_twitter) settings.TWITTER_NOTIFY_ONSNATCH = config.checkbox_to_value( twitter_notify_onsnatch) settings.TWITTER_NOTIFY_ONDOWNLOAD = config.checkbox_to_value( twitter_notify_ondownload) settings.TWITTER_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value( twitter_notify_onsubtitledownload) settings.TWITTER_USEDM = config.checkbox_to_value(twitter_usedm) settings.TWITTER_DMTO = twitter_dmto settings.USE_TWILIO = config.checkbox_to_value(use_twilio) settings.TWILIO_NOTIFY_ONSNATCH = config.checkbox_to_value( twilio_notify_onsnatch) settings.TWILIO_NOTIFY_ONDOWNLOAD = config.checkbox_to_value( twilio_notify_ondownload) settings.TWILIO_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value( twilio_notify_onsubtitledownload) settings.TWILIO_PHONE_SID = twilio_phone_sid settings.TWILIO_ACCOUNT_SID = twilio_account_sid settings.TWILIO_AUTH_TOKEN = twilio_auth_token settings.TWILIO_TO_NUMBER = twilio_to_number settings.USE_SLACK = config.checkbox_to_value(use_slack) settings.SLACK_NOTIFY_SNATCH = config.checkbox_to_value( slack_notify_snatch) settings.SLACK_NOTIFY_DOWNLOAD = config.checkbox_to_value( slack_notify_download) settings.SLACK_NOTIFY_SUBTITLEDOWNLOAD = config.checkbox_to_value( slack_notify_subtitledownload) settings.SLACK_WEBHOOK = slack_webhook settings.SLACK_ICON_EMOJI = slack_icon_emoji settings.USE_ROCKETCHAT = config.checkbox_to_value(use_rocketchat) settings.ROCKETCHAT_NOTIFY_SNATCH = config.checkbox_to_value( rocketchat_notify_snatch) settings.ROCKETCHAT_NOTIFY_DOWNLOAD = config.checkbox_to_value( rocketchat_notify_download) settings.ROCKETCHAT_NOTIFY_SUBTITLEDOWNLOAD = config.checkbox_to_value( rocketchat_notify_subtitledownload) settings.ROCKETCHAT_WEBHOOK = rocketchat_webhook settings.ROCKETCHAT_ICON_EMOJI = rocketchat_icon_emoji settings.USE_MATRIX = config.checkbox_to_value(use_matrix) settings.MATRIX_NOTIFY_SNATCH = config.checkbox_to_value( matrix_notify_snatch) settings.MATRIX_NOTIFY_DOWNLOAD = config.checkbox_to_value( matrix_notify_download) settings.MATRIX_NOTIFY_SUBTITLEDOWNLOAD = config.checkbox_to_value( matrix_notify_subtitledownload) settings.MATRIX_API_TOKEN = matrix_api_token settings.MATRIX_SERVER = matrix_server settings.MATRIX_ROOM = matrix_room settings.USE_DISCORD = config.checkbox_to_value(use_discord) settings.DISCORD_NOTIFY_SNATCH = config.checkbox_to_value( discord_notify_snatch) settings.DISCORD_NOTIFY_DOWNLOAD = config.checkbox_to_value( discord_notify_download) settings.DISCORD_WEBHOOK = discord_webhook settings.DISCORD_NAME = discord_name settings.DISCORD_AVATAR_URL = discord_avatar_url settings.DISCORD_TTS = discord_tts settings.USE_BOXCAR2 = config.checkbox_to_value(use_boxcar2) settings.BOXCAR2_NOTIFY_ONSNATCH = config.checkbox_to_value( boxcar2_notify_onsnatch) settings.BOXCAR2_NOTIFY_ONDOWNLOAD = config.checkbox_to_value( boxcar2_notify_ondownload) settings.BOXCAR2_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value( boxcar2_notify_onsubtitledownload) settings.BOXCAR2_ACCESSTOKEN = boxcar2_accesstoken settings.USE_PUSHOVER = config.checkbox_to_value(use_pushover) settings.PUSHOVER_NOTIFY_ONSNATCH = config.checkbox_to_value( pushover_notify_onsnatch) settings.PUSHOVER_NOTIFY_ONDOWNLOAD = config.checkbox_to_value( pushover_notify_ondownload) settings.PUSHOVER_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value( pushover_notify_onsubtitledownload) settings.PUSHOVER_USERKEY = pushover_userkey settings.PUSHOVER_APIKEY = filters.unhide(settings.PUSHOVER_APIKEY, pushover_apikey) settings.PUSHOVER_DEVICE = pushover_device settings.PUSHOVER_SOUND = pushover_sound settings.PUSHOVER_PRIORITY = pushover_priority settings.USE_LIBNOTIFY = config.checkbox_to_value(use_libnotify) settings.LIBNOTIFY_NOTIFY_ONSNATCH = config.checkbox_to_value( libnotify_notify_onsnatch) settings.LIBNOTIFY_NOTIFY_ONDOWNLOAD = config.checkbox_to_value( libnotify_notify_ondownload) settings.LIBNOTIFY_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value( libnotify_notify_onsubtitledownload) settings.USE_NMJ = config.checkbox_to_value(use_nmj) settings.NMJ_HOST = config.clean_host(nmj_host) settings.NMJ_DATABASE = nmj_database settings.NMJ_MOUNT = nmj_mount settings.USE_NMJv2 = config.checkbox_to_value(use_nmjv2) settings.NMJv2_HOST = config.clean_host(nmjv2_host) settings.NMJv2_DATABASE = nmjv2_database settings.NMJv2_DBLOC = nmjv2_dbloc settings.USE_SYNOINDEX = config.checkbox_to_value(use_synoindex) settings.USE_SYNOLOGYNOTIFIER = config.checkbox_to_value( use_synologynotifier) settings.SYNOLOGYNOTIFIER_NOTIFY_ONSNATCH = config.checkbox_to_value( synologynotifier_notify_onsnatch) settings.SYNOLOGYNOTIFIER_NOTIFY_ONDOWNLOAD = config.checkbox_to_value( synologynotifier_notify_ondownload) settings.SYNOLOGYNOTIFIER_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value( synologynotifier_notify_onsubtitledownload) config.change_use_trakt(use_trakt) settings.TRAKT_USERNAME = trakt_username settings.TRAKT_REMOVE_WATCHLIST = config.checkbox_to_value( trakt_remove_watchlist) settings.TRAKT_REMOVE_SERIESLIST = config.checkbox_to_value( trakt_remove_serieslist) settings.TRAKT_REMOVE_SHOW_FROM_SICKCHILL = config.checkbox_to_value( trakt_remove_show_from_sickchill) settings.TRAKT_SYNC_WATCHLIST = config.checkbox_to_value( trakt_sync_watchlist) settings.TRAKT_METHOD_ADD = int(trakt_method_add) settings.TRAKT_START_PAUSED = config.checkbox_to_value( trakt_start_paused) settings.TRAKT_USE_RECOMMENDED = config.checkbox_to_value( trakt_use_recommended) settings.TRAKT_SYNC = config.checkbox_to_value(trakt_sync) settings.TRAKT_SYNC_REMOVE = config.checkbox_to_value( trakt_sync_remove) settings.TRAKT_DEFAULT_INDEXER = int(trakt_default_indexer) settings.TRAKT_TIMEOUT = int(trakt_timeout) settings.TRAKT_BLACKLIST_NAME = trakt_blacklist_name settings.USE_EMAIL = config.checkbox_to_value(use_email) settings.EMAIL_NOTIFY_ONSNATCH = config.checkbox_to_value( email_notify_onsnatch) settings.EMAIL_NOTIFY_ONDOWNLOAD = config.checkbox_to_value( email_notify_ondownload) settings.EMAIL_NOTIFY_ONPOSTPROCESS = config.checkbox_to_value( email_notify_onpostprocess) settings.EMAIL_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value( email_notify_onsubtitledownload) settings.EMAIL_HOST = config.clean_host(email_host) settings.EMAIL_PORT = try_int(email_port, 25) settings.EMAIL_FROM = email_from settings.EMAIL_TLS = config.checkbox_to_value(email_tls) settings.EMAIL_USER = email_user settings.EMAIL_PASSWORD = filters.unhide(settings.EMAIL_PASSWORD, email_password) settings.EMAIL_LIST = email_list settings.EMAIL_SUBJECT = email_subject settings.USE_PYTIVO = config.checkbox_to_value(use_pytivo) settings.PYTIVO_NOTIFY_ONSNATCH = config.checkbox_to_value( pytivo_notify_onsnatch) settings.PYTIVO_NOTIFY_ONDOWNLOAD = config.checkbox_to_value( pytivo_notify_ondownload) settings.PYTIVO_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value( pytivo_notify_onsubtitledownload) settings.PYTIVO_UPDATE_LIBRARY = config.checkbox_to_value( pytivo_update_library) settings.PYTIVO_HOST = config.clean_host(pytivo_host) settings.PYTIVO_SHARE_NAME = pytivo_share_name settings.PYTIVO_TIVO_NAME = pytivo_tivo_name settings.USE_PUSHALOT = config.checkbox_to_value(use_pushalot) settings.PUSHALOT_NOTIFY_ONSNATCH = config.checkbox_to_value( pushalot_notify_onsnatch) settings.PUSHALOT_NOTIFY_ONDOWNLOAD = config.checkbox_to_value( pushalot_notify_ondownload) settings.PUSHALOT_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value( pushalot_notify_onsubtitledownload) settings.PUSHALOT_AUTHORIZATIONTOKEN = pushalot_authorizationtoken settings.USE_PUSHBULLET = config.checkbox_to_value(use_pushbullet) settings.PUSHBULLET_NOTIFY_ONSNATCH = config.checkbox_to_value( pushbullet_notify_onsnatch) settings.PUSHBULLET_NOTIFY_ONDOWNLOAD = config.checkbox_to_value( pushbullet_notify_ondownload) settings.PUSHBULLET_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value( pushbullet_notify_onsubtitledownload) settings.PUSHBULLET_API = pushbullet_api settings.PUSHBULLET_DEVICE = pushbullet_device_list settings.PUSHBULLET_CHANNEL = pushbullet_channel_list or "" sickchill.start.save_config() if len(results) > 0: for x in results: logger.exception(x) ui.notifications.error(_('Error(s) Saving Configuration'), '<br>\n'.join(results)) else: ui.notifications.message(_('Configuration Saved'), os.path.join(settings.CONFIG_FILE)) return self.redirect("/config/notifications/")
def saveProviders(self, newznab_string="", torrentrss_string="", provider_order=None, **kwargs): newznabProviderDict = { x.get_id(): x for x in settings.newznabProviderList } finished_names = [] # add all the newznab info we got into our list # if not newznab_string: # logger.debug('No newznab_string passed to saveProviders') 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) cur_id = GenericProvider.make_id(cur_name) # if it does not already exist then add it if cur_id not in newznabProviderDict: new_provider = newznab.NewznabProvider(cur_name, cur_url, key=cur_key, catIDs=cur_cat) settings.newznabProviderList.append(new_provider) newznabProviderDict[cur_id] = new_provider # set all params newznabProviderDict[cur_id].name = cur_name newznabProviderDict[cur_id].url = cur_url newznabProviderDict[cur_id].key = cur_key newznabProviderDict[cur_id].catIDs = cur_cat # a 0 in the key spot indicates that no key is needed newznabProviderDict[cur_id].needs_auth = cur_key and cur_key != "0" newznabProviderDict[cur_id].search_mode = str( kwargs.get(cur_id + "_search_mode", "eponly")).strip() newznabProviderDict[ cur_id].search_fallback = config.checkbox_to_value(kwargs.get( cur_id + "search_fallback", 0), value_on=1, value_off=0) newznabProviderDict[ cur_id].enable_daily = config.checkbox_to_value(kwargs.get( cur_id + "enable_daily", 0), value_on=1, value_off=0) newznabProviderDict[ cur_id].enable_backlog = config.checkbox_to_value(kwargs.get( cur_id + "enable_backlog", 0), value_on=1, value_off=0) # mark it finished finished_names.append(cur_id) # delete anything that is in the list that was not processed just now if newznab_string: for curProvider in settings.newznabProviderList: if curProvider.get_id() not in finished_names: settings.newznabProviderList.remove(curProvider) del newznabProviderDict[curProvider.get_id()] # if not torrentrss_string: # logger.debug('No torrentrss_string passed to saveProviders') torrentRssProviderDict = { x.get_id(): x for x in settings.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) cur_id = GenericProvider.make_id(cur_name) # if it does not already exist then create it if cur_id not in torrentRssProviderDict: new_provider = rsstorrent.TorrentRssProvider( cur_name, cur_url, cur_cookies, cur_title_tag) settings.torrentRssProviderList.append(new_provider) torrentRssProviderDict[cur_id] = new_provider # update values torrentRssProviderDict[cur_id].name = cur_name torrentRssProviderDict[cur_id].url = cur_url torrentRssProviderDict[cur_id].cookies = cur_cookies torrentRssProviderDict[cur_id].cur_title_tag = cur_title_tag # mark it finished finished_names.append(cur_id) # delete anything that is in the list that was not processed just now if torrentrss_string: for curProvider in settings.torrentRssProviderList: if curProvider.get_id() not in finished_names: settings.torrentRssProviderList.remove(curProvider) del torrentRssProviderDict[curProvider.get_id()] # do the enable/disable enabled_provider_list = [] disabled_provider_list = [] for cur_id, cur_enabled in ( cur_provider_str.split(":") for cur_provider_str in provider_order.split()): cur_enabled = bool(try_int(cur_enabled)) cur_provider_obj = [ x for x in sickchill.oldbeard.providers.sortedProviderList() if x.get_id() == cur_id and hasattr(x, "enabled") ] if cur_provider_obj: cur_provider_obj[0].enabled = cur_enabled if cur_enabled: enabled_provider_list.append(cur_id) else: disabled_provider_list.append(cur_id) if cur_id in newznabProviderDict: newznabProviderDict[cur_id].enabled = cur_enabled elif cur_id in torrentRssProviderDict: torrentRssProviderDict[cur_id].enabled = cur_enabled # dynamically load provider settings for curProvider in sickchill.oldbeard.providers.sortedProviderList(): if hasattr(curProvider, "custom_url"): curProvider.custom_url = str( kwargs.get(curProvider.get_id("_custom_url"), "")).strip() if hasattr(curProvider, "minseed"): curProvider.minseed = int( str(kwargs.get(curProvider.get_id("_minseed"), 0)).strip()) if hasattr(curProvider, "minleech"): curProvider.minleech = int( str(kwargs.get(curProvider.get_id("_minleech"), 0)).strip()) if hasattr(curProvider, "ratio"): if curProvider.get_id("_ratio") in kwargs: ratio = str(kwargs.get( curProvider.get_id("_ratio"))).strip() if ratio in ("None", None, ""): curProvider.ratio = None else: curProvider.ratio = max(float(ratio), -1) else: curProvider.ratio = None if hasattr(curProvider, "digest"): curProvider.digest = str( kwargs.get(curProvider.get_id("_digest"), "")).strip() or None if hasattr(curProvider, "hash"): curProvider.hash = str( kwargs.get(curProvider.get_id("_hash"), "")).strip() or None if hasattr(curProvider, "api_key"): curProvider.api_key = str( kwargs.get(curProvider.get_id("_api_key"), "")).strip() or None if hasattr(curProvider, "username"): curProvider.username = str( kwargs.get(curProvider.get_id("_username"), "")).strip() or None if hasattr(curProvider, "password"): curProvider.password = filters.unhide( curProvider.password, str(kwargs.get(curProvider.get_id("_password"), "")).strip()) if hasattr(curProvider, "passkey"): curProvider.passkey = filters.unhide( curProvider.passkey, str(kwargs.get(curProvider.get_id("_passkey"), "")).strip()) if hasattr(curProvider, "pin"): curProvider.pin = filters.unhide( curProvider.pin, str(kwargs.get(curProvider.get_id("_pin"), "")).strip()) if hasattr(curProvider, "confirmed"): curProvider.confirmed = config.checkbox_to_value( kwargs.get(curProvider.get_id("_confirmed"))) if hasattr(curProvider, "ranked"): curProvider.ranked = config.checkbox_to_value( kwargs.get(curProvider.get_id("_ranked"))) if hasattr(curProvider, "engrelease"): curProvider.engrelease = config.checkbox_to_value( kwargs.get(curProvider.get_id("_engrelease"))) if hasattr(curProvider, "onlyspasearch"): curProvider.onlyspasearch = config.checkbox_to_value( kwargs.get(curProvider.get_id("_onlyspasearch"))) if hasattr(curProvider, "sorting"): curProvider.sorting = str( kwargs.get(curProvider.get_id("_sorting"), "seeders")).strip() if hasattr(curProvider, "freeleech"): curProvider.freeleech = config.checkbox_to_value( kwargs.get(curProvider.get_id("_freeleech"))) if hasattr(curProvider, "search_mode"): curProvider.search_mode = str( kwargs.get(curProvider.get_id("_search_mode"), "eponly")).strip() if hasattr(curProvider, "search_fallback"): curProvider.search_fallback = config.checkbox_to_value( kwargs.get(curProvider.get_id("_search_fallback"))) if hasattr(curProvider, "enable_daily"): curProvider.enable_daily = curProvider.can_daily and config.checkbox_to_value( kwargs.get(curProvider.get_id("_enable_daily"))) if hasattr(curProvider, "enable_backlog"): curProvider.enable_backlog = curProvider.can_backlog and config.checkbox_to_value( kwargs.get(curProvider.get_id("_enable_backlog"))) if hasattr(curProvider, "cat"): curProvider.cat = int( str(kwargs.get(curProvider.get_id("_cat"), 0)).strip()) if hasattr(curProvider, "subtitle"): curProvider.subtitle = config.checkbox_to_value( kwargs.get(curProvider.get_id("_subtitle"))) if curProvider.enable_cookies: curProvider.cookies = str( kwargs.get(curProvider.get_id("_cookies"))).strip() settings.NEWZNAB_DATA = "!!!".join( [x.configStr() for x in settings.newznabProviderList]) settings.PROVIDER_ORDER = enabled_provider_list + disabled_provider_list sickchill.start.save_config() # Add a site_message if no providers are enabled for daily and/or backlog sickchill.oldbeard.providers.check_enabled_providers() ui.notifications.message(_("Configuration Saved"), os.path.join(settings.CONFIG_FILE)) return self.redirect("/config/providers/")
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, backlog_missing_only=None, torrent_dir=None, torrent_username=None, torrent_password=None, torrent_host=None, torrent_label=None, torrent_label_anime=None, torrent_path=None, torrent_path_incomplete=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, trackers_list=None, require_words=None, ignored_subs_list=None, syno_dsm_host=None, syno_dsm_user=None, syno_dsm_pass=None, syno_dsm_path=None, quality_allow_hevc=False, prefer_words=None, ): results = [] if not config.change_nzb_dir(nzb_dir): results += ["Unable to create directory " + os.path.normpath(nzb_dir) + ", dir not changed."] if not config.change_torrent_dir(torrent_dir): results += ["Unable to create directory " + os.path.normpath(torrent_dir) + ", dir not changed."] config.change_daily_search_frequency(dailysearch_frequency) config.change_backlog_frequency(backlog_frequency) settings.BACKLOG_DAYS = try_int(backlog_days, 7) settings.USE_NZBS = config.checkbox_to_value(use_nzbs) settings.USE_TORRENTS = config.checkbox_to_value(use_torrents) settings.NZB_METHOD = nzb_method settings.TORRENT_METHOD = torrent_method settings.USENET_RETENTION = try_int(usenet_retention, 500) settings.IGNORE_WORDS = ignore_words if ignore_words else "" settings.TRACKERS_LIST = trackers_list if trackers_list else "" settings.REQUIRE_WORDS = require_words if require_words else "" settings.PREFER_WORDS = prefer_words if prefer_words else "" settings.IGNORED_SUBS_LIST = ignored_subs_list if ignored_subs_list else "" settings.RANDOMIZE_PROVIDERS = config.checkbox_to_value(randomize_providers) config.change_download_propers(download_propers) settings.CHECK_PROPERS_INTERVAL = check_propers_interval settings.ALLOW_HIGH_PRIORITY = config.checkbox_to_value(allow_high_priority) settings.QUALITY_ALLOW_HEVC = config.checkbox_to_value(quality_allow_hevc) settings.USE_FAILED_DOWNLOADS = config.checkbox_to_value(use_failed_downloads) settings.DELETE_FAILED = config.checkbox_to_value(delete_failed) settings.BACKLOG_MISSING_ONLY = config.checkbox_to_value(backlog_missing_only) settings.SAB_USERNAME = sab_username settings.SAB_PASSWORD = filters.unhide(settings.SAB_PASSWORD, sab_password) settings.SAB_APIKEY = filters.unhide(settings.SAB_APIKEY, sab_apikey.strip()) settings.SAB_CATEGORY = sab_category settings.SAB_CATEGORY_BACKLOG = sab_category_backlog settings.SAB_CATEGORY_ANIME = sab_category_anime settings.SAB_CATEGORY_ANIME_BACKLOG = sab_category_anime_backlog settings.SAB_HOST = config.clean_url(sab_host) settings.SAB_FORCED = config.checkbox_to_value(sab_forced) settings.NZBGET_USERNAME = nzbget_username settings.NZBGET_PASSWORD = filters.unhide(settings.NZBGET_PASSWORD, nzbget_password) settings.NZBGET_CATEGORY = nzbget_category settings.NZBGET_CATEGORY_BACKLOG = nzbget_category_backlog settings.NZBGET_CATEGORY_ANIME = nzbget_category_anime settings.NZBGET_CATEGORY_ANIME_BACKLOG = nzbget_category_anime_backlog settings.NZBGET_HOST = config.clean_host(nzbget_host) settings.NZBGET_USE_HTTPS = config.checkbox_to_value(nzbget_use_https) settings.NZBGET_PRIORITY = try_int(nzbget_priority, 100) settings.TORRENT_USERNAME = torrent_username settings.TORRENT_PASSWORD = filters.unhide(settings.TORRENT_PASSWORD, torrent_password) settings.TORRENT_LABEL = torrent_label settings.TORRENT_LABEL_ANIME = torrent_label_anime settings.TORRENT_VERIFY_CERT = config.checkbox_to_value(torrent_verify_cert) settings.TORRENT_PATH = torrent_path.rstrip("/\\") settings.TORRENT_PATH_INCOMPLETE = torrent_path_incomplete.rstrip("/\\") settings.TORRENT_SEED_TIME = torrent_seed_time settings.TORRENT_PAUSED = config.checkbox_to_value(torrent_paused) settings.TORRENT_HIGH_BANDWIDTH = config.checkbox_to_value(torrent_high_bandwidth) settings.TORRENT_HOST = config.clean_url(torrent_host) settings.TORRENT_RPCURL = torrent_rpcurl settings.TORRENT_AUTH_TYPE = torrent_auth_type settings.SYNOLOGY_DSM_HOST = config.clean_url(syno_dsm_host) settings.SYNOLOGY_DSM_USERNAME = syno_dsm_user settings.SYNOLOGY_DSM_PASSWORD = filters.unhide(settings.SYNOLOGY_DSM_PASSWORD, syno_dsm_pass) settings.SYNOLOGY_DSM_PATH = syno_dsm_path.rstrip("/\\") # This is a PITA, but lets merge the settings if they only set DSM up in one section to save them some time if settings.TORRENT_METHOD == "download_station": if not settings.SYNOLOGY_DSM_HOST: settings.SYNOLOGY_DSM_HOST = settings.TORRENT_HOST if not settings.SYNOLOGY_DSM_USERNAME: settings.SYNOLOGY_DSM_USERNAME = settings.TORRENT_USERNAME if not settings.SYNOLOGY_DSM_PASSWORD: settings.SYNOLOGY_DSM_PASSWORD = settings.TORRENT_PASSWORD if not settings.SYNOLOGY_DSM_PATH: settings.SYNOLOGY_DSM_PATH = settings.TORRENT_PATH if settings.NZB_METHOD == "download_station": if not settings.TORRENT_HOST: settings.TORRENT_HOST = settings.SYNOLOGY_DSM_HOST if not settings.TORRENT_USERNAME: settings.TORRENT_USERNAME = settings.SYNOLOGY_DSM_USERNAME if not settings.TORRENT_PASSWORD: settings.TORRENT_PASSWORD = settings.SYNOLOGY_DSM_PASSWORD if not settings.TORRENT_PATH: settings.TORRENT_PATH = settings.SYNOLOGY_DSM_PATH helpers.manage_torrents_url(reset=True) sickchill.start.save_config() if len(results) > 0: for x in results: logger.exception(x) ui.notifications.error(_("Error(s) Saving Configuration"), "<br>\n".join(results)) else: ui.notifications.message(_("Configuration Saved"), os.path.join(settings.CONFIG_FILE)) return self.redirect("/config/search/")