def saveAddShowDefaults(default_status, allowed_qualities, preferred_qualities, default_season_folders, subtitles=False, anime=False, scene=False, default_status_after=WANTED): allowed_qualities = [_.strip() for _ in allowed_qualities.split(',') ] if allowed_qualities else [] preferred_qualities = [ _.strip() for _ in preferred_qualities.split(',') ] if preferred_qualities else [] new_quality = Quality.combine_qualities( [int(quality) for quality in allowed_qualities], [int(quality) for quality in preferred_qualities]) app.STATUS_DEFAULT = int(default_status) app.STATUS_DEFAULT_AFTER = int(default_status_after) app.QUALITY_DEFAULT = int(new_quality) app.SEASON_FOLDERS_DEFAULT = config.checkbox_to_value( default_season_folders) 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.instance.save_config()
def saveAnime(self, use_anidb=None, anidb_username=None, anidb_password=None, anidb_use_mylist=None, split_home=None, split_home_in_tabs=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.ANIME_SPLIT_HOME_IN_TABS = config.checkbox_to_value( split_home_in_tabs) app.instance.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/anime/')
def saveAnime(self, use_anidb=None, anidb_username=None, anidb_password=None, anidb_use_mylist=None, split_home=None, split_home_in_tabs=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.ANIME_SPLIT_HOME_IN_TABS = config.checkbox_to_value(split_home_in_tabs) app.instance.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/anime/')
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_erase_cache=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_ERASE_CACHE = config.checkbox_to_value(subtitles_erase_cache) 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.IGNORE_EMBEDDED_SUBS = config.checkbox_to_value(embedded_subtitles_all) app.ACCEPT_UNKNOWN_EMBEDDED_SUBS = 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.instance.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/')
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_erase_cache=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_ERASE_CACHE = config.checkbox_to_value(subtitles_erase_cache) 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.IGNORE_EMBEDDED_SUBS = config.checkbox_to_value(embedded_subtitles_all) app.ACCEPT_UNKNOWN_EMBEDDED_SUBS = 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 cur_service_str in services_str_list: cur_service, cur_enabled = cur_service_str.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.instance.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/')
def testDiscord(discord_webhook=None, discord_tts=None, discord_override_avatar=None): result, message = notifiers.discord_notifier.test_notify( discord_webhook, config.checkbox_to_value(discord_tts), config.checkbox_to_value(discord_override_avatar)) if result: return 'Discord notification succeeded. Check your Discord channels to make sure it worked' else: return 'Error sending Discord notification: {msg}'.format( msg=message)
def saveAddShowDefaults(default_status, allowed_qualities, preferred_qualities, default_season_folders, subtitles=False, anime=False, scene=False, default_status_after=WANTED): allowed_qualities = [_.strip() for _ in allowed_qualities.split(',')] if allowed_qualities else [] preferred_qualities = [_.strip() for _ in preferred_qualities.split(',')] if preferred_qualities else [] new_quality = Quality.combine_qualities([int(quality) for quality in allowed_qualities], [int(quality) for quality in preferred_qualities]) app.STATUS_DEFAULT = int(default_status) app.STATUS_DEFAULT_AFTER = int(default_status_after) app.QUALITY_DEFAULT = int(new_quality) app.SEASON_FOLDERS_DEFAULT = config.checkbox_to_value(default_season_folders) 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.instance.save_config()
def testNZBget(host=None, username=None, password=None, use_https=False): try: connected_status, error_msg = nzbget.test_authentication( host, username, password, config.checkbox_to_value(use_https)) except Exception as error: logger.log( 'Error while testing NZBget connection: {error}'.format( error=error), logger.WARNING) return 'Error while testing connection. Check warning logs.' if connected_status: return 'Success. Connected and authenticated' else: return 'Unable to connect to host. Error: {msg}'.format( msg=error_msg)
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=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 = [ _.strip() for _ in extra_scripts.split('|') if _.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 = [ _.strip() for _ in sync_files.split(',') if _.strip() ] 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 = { _.strip() for _ in allowed_extensions.split(',') if _.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.split('|') app.METADATA_KODI_12PLUS = kodi_12plus_data.split('|') app.METADATA_MEDIABROWSER = mediabrowser_data.split('|') app.METADATA_PS3 = sony_ps3_data.split('|') app.METADATA_WDTV = wdtv_data.split('|') app.METADATA_TIVO = tivo_data.split('|') app.METADATA_MEDE8ER = mede8er_data.split('|') 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.instance.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', os.path.join(app.CONFIG_FILE)) return self.redirect('/config/postProcessing/')
def savePostProcessing(self, process_automatically=None, unpack=None, allowed_extensions=None, tv_download_dir=None, naming_pattern=None, naming_multi_ep=None, naming_anime=None, naming_abd_pattern=None, naming_sports_pattern=None, naming_anime_pattern=None, naming_anime_multi_ep=None, autopostprocessor_frequency=None): """[deprecated] Save Post Processing configuration.""" # @TODO: The following validations need to be incorporated into API v2 (PATCH /api/v2/config/main) results = [] if not config.change_TV_DOWNLOAD_DIR(tv_download_dir): results += ['Unable to create directory {dir}, ' 'dir not changed.'.format(dir=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) # @TODO: postprocessor for `POSTPONE_IF_NO_SUBS` and `ALLOWED_EXTENSIONS` ? # 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 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.instance.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', os.path.join(app.CONFIG_FILE)) return self.redirect('/config/postProcessing/')
def addExistingShows(self, shows_to_add=None, promptForSettings=None): """ Receives a dir list and add them. Adds the ones with given TVDB IDs first, then forwards along to the newShow page. """ prompt_for_settings = promptForSettings # grab a list of other shows to add, if provided if not shows_to_add: shows_to_add = [] elif not isinstance(shows_to_add, list): shows_to_add = [shows_to_add] shows_to_add = [ text_type(x, 'utf-8') if not isinstance(x, text_type) else x for x in shows_to_add ] prompt_for_settings = config.checkbox_to_value(prompt_for_settings) indexer_id_given = [] dirs_only = [] # separate all the ones with Indexer IDs for cur_dir in shows_to_add: if '|' not in cur_dir: # 'series_dir' dirs_only.append(cur_dir) else: indexer, show_dir, indexer_id, show_name = self.split_extra_show( cur_dir) if indexer and show_dir and not indexer_id: # 'indexer_id|show_dir' or 'indexer_id|show_dir|show_name' dirs_only.append(cur_dir) continue if not (show_dir and indexer_id and show_name): # 'indexer_id' continue # 'indexer_id|show_dir|series_id|series_name' indexer_id_given.append( (int(indexer), show_dir, int(indexer_id), show_name)) # if they want me to prompt for settings then I will just carry on to the newShow page if prompt_for_settings and shows_to_add: return json_response( redirect='/addShows/newShow/', params=[('show_to_add' if not i else 'other_shows', cur_dir) for i, cur_dir in enumerate(shows_to_add)]) # if they don't want me to prompt for settings then I can just add all the nfo shows now num_added = 0 for cur_show in indexer_id_given: indexer, show_dir, indexer_id, show_name = cur_show if indexer is not None and indexer_id is not None: # add the show app.show_queue_scheduler.action.addShow( indexer, indexer_id, show_dir, default_status=app.STATUS_DEFAULT, quality=app.QUALITY_DEFAULT, season_folders=app.SEASON_FOLDERS_DEFAULT, subtitles=app.SUBTITLES_DEFAULT, anime=app.ANIME_DEFAULT, scene=app.SCENE_DEFAULT, default_status_after=app.STATUS_DEFAULT_AFTER) num_added += 1 if num_added: ui.notifications.message( 'Shows Added', 'Automatically added {quantity} from their existing metadata files' .format(quantity=num_added)) # if we're done then go home if not dirs_only: return json_response(redirect='/home/') # for the remaining shows we need to prompt for each one, so forward this on to the newShow page return json_response(redirect='/addShows/newShow/', params=[ ('show_to_add' if not i else 'other_shows', cur_dir) for i, cur_dir in enumerate(dirs_only) ])
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, pushover_priority=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_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_join=None, join_notify_onsnatch=None, join_notify_ondownload=None, join_notify_onsubtitledownload=None, join_api=None, join_device=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, use_slack=None, slack_notify_onsnatch=None, slack_notify_ondownload=None, slack_notify_onsubtitledownload=None, slack_webhook=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 = [_.strip() for _ in prowl_api.split(',')] 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 = [_.strip() for _ in pushover_device.split(',')] app.PUSHOVER_SOUND = pushover_sound app.PUSHOVER_PRIORITY = pushover_priority 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) app.USE_SLACK = config.checkbox_to_value(use_slack) app.SLACK_NOTIFY_DOWNLOAD = config.checkbox_to_value(slack_notify_ondownload) app.SLACK_NOTIFY_SNATCH = config.checkbox_to_value(slack_notify_onsnatch) app.SLACK_NOTIFY_SUBTITLEDOWNLOAD = config.checkbox_to_value(slack_notify_onsubtitledownload) app.SLACK_WEBHOOK = slack_webhook 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 = [_.strip() for _ in email_list.split(',')] 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_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.USE_JOIN = config.checkbox_to_value(use_join) app.JOIN_NOTIFY_ONSNATCH = config.checkbox_to_value(join_notify_onsnatch) app.JOIN_NOTIFY_ONDOWNLOAD = config.checkbox_to_value(join_notify_ondownload) app.JOIN_NOTIFY_ONSUBTITLEDOWNLOAD = config.checkbox_to_value(join_notify_onsubtitledownload) app.JOIN_API = join_api app.JOIN_DEVICE = join_device app.instance.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/')
def addExistingShows(self, shows_to_add=None, promptForSettings=None): """ Receives a dir list and add them. Adds the ones with given TVDB IDs first, then forwards along to the newShow page. """ prompt_for_settings = promptForSettings # grab a list of other shows to add, if provided if not shows_to_add: shows_to_add = [] elif not isinstance(shows_to_add, list): shows_to_add = [shows_to_add] shows_to_add = [unquote_plus(x) for x in shows_to_add] prompt_for_settings = config.checkbox_to_value(prompt_for_settings) indexer_id_given = [] dirs_only = [] # separate all the ones with Indexer IDs for cur_dir in shows_to_add: if '|' in cur_dir: split_vals = cur_dir.split('|') if len(split_vals) < 3: dirs_only.append(cur_dir) if '|' not in cur_dir: dirs_only.append(cur_dir) else: indexer, show_dir, indexer_id, show_name = self.split_extra_show( cur_dir) if indexer and show_dir and not indexer_id: dirs_only.append(cur_dir) if not show_dir or not indexer_id or not show_name: continue indexer_id_given.append( (int(indexer), show_dir, int(indexer_id), show_name)) # if they want me to prompt for settings then I will just carry on to the newShow page if prompt_for_settings and shows_to_add: return self.newShow(shows_to_add[0], shows_to_add[1:]) # if they don't want me to prompt for settings then I can just add all the nfo shows now num_added = 0 for cur_show in indexer_id_given: indexer, show_dir, indexer_id, show_name = cur_show if indexer is not None and indexer_id is not None: # add the show app.show_queue_scheduler.action.addShow( indexer, indexer_id, show_dir, default_status=app.STATUS_DEFAULT, quality=app.QUALITY_DEFAULT, season_folders=app.SEASON_FOLDERS_DEFAULT, subtitles=app.SUBTITLES_DEFAULT, anime=app.ANIME_DEFAULT, scene=app.SCENE_DEFAULT, default_status_after=app.STATUS_DEFAULT_AFTER) num_added += 1 if num_added: ui.notifications.message( 'Shows Added', 'Automatically added {quantity} from their existing metadata files' .format(quantity=num_added)) # if we're done then go home if not dirs_only: return self.redirect('/home/') # for the remaining shows we need to prompt for each one, so forward this on to the newShow page return self.newShow(dirs_only[0], dirs_only[1:])
def addShowByID(self, indexername=None, seriesid=None, show_name=None, which_series=None, indexer_lang=None, root_dir=None, default_status=None, quality_preset=None, any_qualities=None, best_qualities=None, season_folders=None, subtitles=None, full_show_path=None, other_shows=None, skip_show=None, provided_indexer=None, anime=None, scene=None, blacklist=None, whitelist=None, default_status_after=None, configure_show_options=False): """ Add's a new show with provided show options by indexer_id. Currently only TVDB and IMDB id's supported. """ series_id = seriesid if indexername != 'tvdb': series_id = helpers.get_tvdb_from_id(seriesid, indexername.upper()) if not series_id: logger.log(u'Unable to to find tvdb ID to add %s' % show_name) ui.notifications.error( 'Unable to add %s' % show_name, 'Could not add %s. We were unable to locate the tvdb id at this time.' % show_name) return if Show.find_by_id(app.showList, INDEXER_TVDBV2, series_id): return # Sanitize the parameter allowed_qualities and preferred_qualities. As these would normally be passed as lists if any_qualities: any_qualities = any_qualities.split(',') else: any_qualities = [] if best_qualities: best_qualities = best_qualities.split(',') else: best_qualities = [] # If configure_show_options is enabled let's use the provided settings configure_show_options = config.checkbox_to_value( configure_show_options) if configure_show_options: # prepare the inputs for passing along scene = config.checkbox_to_value(scene) anime = config.checkbox_to_value(anime) season_folders = config.checkbox_to_value(season_folders) subtitles = config.checkbox_to_value(subtitles) if whitelist: whitelist = short_group_names(whitelist) if blacklist: blacklist = short_group_names(blacklist) if not any_qualities: any_qualities = [] if not best_qualities or try_int(quality_preset, None): best_qualities = [] if not isinstance(any_qualities, list): any_qualities = [any_qualities] if not isinstance(best_qualities, list): best_qualities = [best_qualities] quality = Quality.combine_qualities( [int(q) for q in any_qualities], [int(q) for q in best_qualities]) location = root_dir else: default_status = app.STATUS_DEFAULT quality = app.QUALITY_DEFAULT season_folders = app.SEASON_FOLDERS_DEFAULT subtitles = app.SUBTITLES_DEFAULT anime = app.ANIME_DEFAULT scene = app.SCENE_DEFAULT default_status_after = app.STATUS_DEFAULT_AFTER if app.ROOT_DIRS: root_dirs = app.ROOT_DIRS location = root_dirs[int(root_dirs[0]) + 1] else: location = None if not location: logger.log( u'There was an error creating the show, ' u'no root directory setting found', logger.WARNING) return 'No root directories setup, please go back and add one.' show_name = get_showname_from_indexer(INDEXER_TVDBV2, series_id) show_dir = None # add the show app.show_queue_scheduler.action.addShow(INDEXER_TVDBV2, int(series_id), show_dir, int(default_status), quality, season_folders, indexer_lang, subtitles, anime, scene, None, blacklist, whitelist, int(default_status_after), root_dir=location) ui.notifications.message( 'Show added', 'Adding the specified show {0}'.format(show_name)) # done adding show return self.redirect('/home/')
def addExistingShows(self, shows_to_add=None, promptForSettings=None): """ Receives a dir list and add them. Adds the ones with given TVDB IDs first, then forwards along to the newShow page. """ prompt_for_settings = promptForSettings # grab a list of other shows to add, if provided if not shows_to_add: shows_to_add = [] elif not isinstance(shows_to_add, list): shows_to_add = [shows_to_add] shows_to_add = decode_shows(shows_to_add) prompt_for_settings = config.checkbox_to_value(prompt_for_settings) indexer_id_given = [] dirs_only = [] # separate all the ones with Indexer IDs for cur_dir in shows_to_add: if '|' not in cur_dir: # 'series_dir' dirs_only.append(cur_dir) else: indexer, show_dir, indexer_id, show_name = self.split_extra_show(cur_dir) if indexer and show_dir and not indexer_id: # 'indexer_id|show_dir' or 'indexer_id|show_dir|show_name' dirs_only.append(cur_dir) continue if not (show_dir and indexer_id and show_name): # 'indexer_id' continue # 'indexer_id|show_dir|series_id|series_name' indexer_id_given.append((int(indexer), show_dir, int(indexer_id), show_name)) # if they want me to prompt for settings then I will just carry on to the newShow page if prompt_for_settings and shows_to_add: return json_response( redirect='/addShows/newShow/', params=[ ('show_to_add' if not i else 'other_shows', cur_dir) for i, cur_dir in enumerate(shows_to_add) ] ) # if they don't want me to prompt for settings then I can just add all the nfo shows now num_added = 0 for cur_show in indexer_id_given: indexer, show_dir, indexer_id, show_name = cur_show if indexer is not None and indexer_id is not None: # add the show app.show_queue_scheduler.action.addShow( indexer, indexer_id, show_dir, default_status=app.STATUS_DEFAULT, quality=app.QUALITY_DEFAULT, season_folders=app.SEASON_FOLDERS_DEFAULT, subtitles=app.SUBTITLES_DEFAULT, anime=app.ANIME_DEFAULT, scene=app.SCENE_DEFAULT, default_status_after=app.STATUS_DEFAULT_AFTER ) num_added += 1 if num_added: ui.notifications.message('Shows Added', 'Automatically added {quantity} from their existing metadata files'.format(quantity=num_added)) # if we're done then go home if not dirs_only: return json_response(redirect='/home/') # for the remaining shows we need to prompt for each one, so forward this on to the newShow page return json_response( redirect='/addShows/newShow/', params=[ ('show_to_add' if not i else 'other_shows', cur_dir) for i, cur_dir in enumerate(dirs_only) ] )
def addShowByID(self, indexername=None, seriesid=None, show_name=None, which_series=None, indexer_lang=None, root_dir=None, default_status=None, quality_preset=None, any_qualities=None, best_qualities=None, season_folders=None, subtitles=None, full_show_path=None, other_shows=None, skip_show=None, provided_indexer=None, anime=None, scene=None, blacklist=None, whitelist=None, default_status_after=None, configure_show_options=False): """ Add's a new show with provided show options by indexer_id. Currently only TVDB and IMDB id's supported. """ series_id = seriesid if indexername != 'tvdb': series_id = helpers.get_tvdb_from_id(seriesid, indexername.upper()) if not series_id: log.info('Unable to find tvdb ID to add {name}', {'name': show_name}) ui.notifications.error( 'Unable to add {0}'.format(show_name), 'Could not add {0}. We were unable to locate the tvdb id at this time.'.format(show_name) ) return json_response( result=False, message='Unable to find tvdb ID to add {show}'.format(show=show_name) ) if Show.find_by_id(app.showList, INDEXER_TVDBV2, series_id): return json_response( result=False, message='Show already exists' ) # Sanitize the parameter allowed_qualities and preferred_qualities. As these would normally be passed as lists if any_qualities: any_qualities = any_qualities.split(',') else: any_qualities = [] if best_qualities: best_qualities = best_qualities.split(',') else: best_qualities = [] # If configure_show_options is enabled let's use the provided settings configure_show_options = config.checkbox_to_value(configure_show_options) if configure_show_options: # prepare the inputs for passing along scene = config.checkbox_to_value(scene) anime = config.checkbox_to_value(anime) season_folders = config.checkbox_to_value(season_folders) subtitles = config.checkbox_to_value(subtitles) if whitelist: whitelist = short_group_names(whitelist) if blacklist: blacklist = short_group_names(blacklist) if not any_qualities: any_qualities = [] if not best_qualities or try_int(quality_preset, None): best_qualities = [] if not isinstance(any_qualities, list): any_qualities = [any_qualities] if not isinstance(best_qualities, list): best_qualities = [best_qualities] quality = Quality.combine_qualities([int(q) for q in any_qualities], [int(q) for q in best_qualities]) location = root_dir else: default_status = app.STATUS_DEFAULT quality = app.QUALITY_DEFAULT season_folders = app.SEASON_FOLDERS_DEFAULT subtitles = app.SUBTITLES_DEFAULT anime = app.ANIME_DEFAULT scene = app.SCENE_DEFAULT default_status_after = app.STATUS_DEFAULT_AFTER if app.ROOT_DIRS: root_dirs = app.ROOT_DIRS location = root_dirs[int(root_dirs[0]) + 1] else: location = None if not location: log.warning('There was an error creating the show, no root directory setting found') return json_response( result=False, message='No root directories set up, please go back and add one.' ) show_name = get_showname_from_indexer(INDEXER_TVDBV2, series_id) show_dir = None # add the show app.show_queue_scheduler.action.addShow(INDEXER_TVDBV2, int(series_id), show_dir, int(default_status), quality, season_folders, indexer_lang, subtitles, anime, scene, None, blacklist, whitelist, int(default_status_after), root_dir=location) ui.notifications.message('Show added', 'Adding the specified show {0}'.format(show_name)) # done adding show return json_response( message='Adding the specified show {0}'.format(show_name), redirect='home' )
def addShowByID(self, showslug=None, show_name=None, which_series=None, indexer_lang=None, root_dir=None, default_status=None, quality_preset=None, any_qualities=None, best_qualities=None, season_folders=None, subtitles=None, full_show_path=None, other_shows=None, skip_show=None, provided_indexer=None, anime=None, scene=None, blacklist=None, whitelist=None, default_status_after=None, configure_show_options=False): """ Add's a new show with provided show options by indexer_id. Currently only TVDB and IMDB id's supported. """ identifier = SeriesIdentifier.from_slug(showslug) series_id = identifier.id indexername = identifier.indexer.slug if identifier.indexer.slug != 'tvdb': series_id = helpers.get_tvdb_from_id(identifier.id, indexername.upper()) if not series_id: log.info('Unable to find tvdb ID to add {name}', {'name': show_name}) ui.notifications.error( 'Unable to add {0}'.format(show_name), 'Could not add {0}. We were unable to locate the tvdb id at this time.'.format(show_name) ) return json_response( result=False, message='Unable to find tvdb ID to add {show}'.format(show=show_name) ) if Series.find_by_identifier(identifier): return json_response( result=False, message='Show already exists' ) # Sanitize the parameter allowed_qualities and preferred_qualities. As these would normally be passed as lists if any_qualities: any_qualities = any_qualities.split(',') else: any_qualities = [] if best_qualities: best_qualities = best_qualities.split(',') else: best_qualities = [] # If configure_show_options is enabled let's use the provided settings configure_show_options = config.checkbox_to_value(configure_show_options) if configure_show_options: # prepare the inputs for passing along scene = config.checkbox_to_value(scene) anime = config.checkbox_to_value(anime) season_folders = config.checkbox_to_value(season_folders) subtitles = config.checkbox_to_value(subtitles) if whitelist: whitelist = short_group_names(whitelist) if blacklist: blacklist = short_group_names(blacklist) if not any_qualities: any_qualities = [] if not best_qualities or try_int(quality_preset, None): best_qualities = [] if not isinstance(any_qualities, list): any_qualities = [any_qualities] if not isinstance(best_qualities, list): best_qualities = [best_qualities] quality = {'allowed': any_qualities, 'preferred': best_qualities} location = root_dir else: default_status = app.STATUS_DEFAULT allowed, preferred = Quality.split_quality(int(app.QUALITY_DEFAULT)) quality = {'allowed': allowed, 'preferred': preferred} season_folders = app.SEASON_FOLDERS_DEFAULT subtitles = app.SUBTITLES_DEFAULT anime = app.ANIME_DEFAULT scene = app.SCENE_DEFAULT default_status_after = app.STATUS_DEFAULT_AFTER if app.ROOT_DIRS: root_dirs = app.ROOT_DIRS location = root_dirs[int(root_dirs[0]) + 1] else: location = None if not location: log.warning('There was an error creating the show, no root directory setting found') return json_response( result=False, message='No root directories set up, please go back and add one.' ) show_name = get_showname_from_indexer(INDEXER_TVDBV2, series_id) show_dir = None # add the show app.show_queue_scheduler.action.addShow(INDEXER_TVDBV2, int(series_id), show_dir, default_status=int(default_status), quality=quality, season_folders=season_folders, lang=indexer_lang, subtitles=subtitles, anime=anime, scene=scene, paused=None, blacklist=blacklist, whitelist=whitelist, default_status_after=int(default_status_after), root_dir=location) ui.notifications.message('Show added', 'Adding the specified show {0}'.format(show_name)) # done adding show return json_response( message='Adding the specified show {0}'.format(show_name), redirect='home' )
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', layout_wide=None, 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_auth_type=0, git_username=None, git_password=None, git_token=None, display_all_seasons=None, subliminal_log=None, privacy_level='normal', fanart_background=None, fanart_background_opacity=None, dbdebug=None, fallback_plex_enable=1, fallback_plex_notifications=1, fallback_plex_timeout=3, web_root=None, ssl_ca_bundle=None): results = [] # Misc app.DOWNLOAD_URL = download_url app.INDEXER_DEFAULT_LANGUAGE = indexerDefaultLang app.EP_DEFAULT_DELETED_STATUS = int(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_AUTH_TYPE = int(git_auth_type) app.GIT_USERNAME = git_username app.GIT_PASSWORD = git_password app.GIT_TOKEN = git_token app.GIT_RESET = config.checkbox_to_value(git_reset) app.GIT_RESET_BRANCHES = [helpers.to_text(branch) for branch in helpers.ensure_list(git_reset_branches)] if app.GIT_PATH != git_path: app.GIT_PATH = git_path config.change_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.SSL_CA_BUNDLE = ssl_ca_bundle # app.LOG_DIR is set in config.change_LOG_DIR() app.COMING_EPS_MISSED_RANGE = int(coming_eps_missed_range) 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 = 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.WEB_ROOT = web_root app.DEBUG = config.checkbox_to_value(debug) app.DBDEBUG = config.checkbox_to_value(dbdebug) app.WEB_LOG = config.checkbox_to_value(web_log) app.SUBLIMINAL_LOG = config.checkbox_to_value(subliminal_log) # Added for tvdb / plex fallback app.FALLBACK_PLEX_ENABLE = config.checkbox_to_value(fallback_plex_enable) app.FALLBACK_PLEX_NOTIFICATIONS = config.checkbox_to_value(fallback_plex_notifications) app.FALLBACK_PLEX_TIMEOUT = try_int(fallback_plex_timeout) if not config.change_LOG_DIR(log_dir): results += ['Unable to create directory {dir}, ' 'log directory not changed.'.format(dir=os.path.normpath(log_dir))] # Reconfigure the logger logger.reconfigure() # Validate github credentials try: if app.GIT_AUTH_TYPE == 0: github_client.authenticate(app.GIT_USERNAME, app.GIT_PASSWORD) else: github = github_client.token_authenticate(app.GIT_TOKEN) if app.GIT_USERNAME and app.GIT_USERNAME != github_client.get_user(gh=github): app.GIT_USERNAME = github_client.get_user(gh=github) 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=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=os.path.normpath(https_key))] app.HANDLE_REVERSE_PROXY = config.checkbox_to_value(handle_reverse_proxy) config.change_theme(theme_name) app.LAYOUT_WIDE = config.checkbox_to_value(layout_wide) app.FANART_BACKGROUND = config.checkbox_to_value(fanart_background) app.FANART_BACKGROUND_OPACITY = fanart_background_opacity app.DEFAULT_PAGE = default_page app.instance.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/general/')
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, remove_from_client=None, randomize_providers=None, use_failed_downloads=None, delete_failed=None, propers_search_days=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, torrent_checker_frequency=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, torrent_seed_location=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=os.path.normpath(nzb_dir))] if not config.change_TORRENT_DIR(torrent_dir): results += ['Unable to create directory {dir}, dir not changed.'.format(dir=os.path.normpath(torrent_dir))] config.change_DAILYSEARCH_FREQUENCY(dailysearch_frequency) config.change_TORRENT_CHECKER_FREQUENCY(torrent_checker_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) if app.TORRENT_METHOD != 'blackhole' and app.TORRENT_METHOD in ('transmission', 'deluge', 'deluged'): config.change_remove_from_client(remove_from_client) else: config.change_remove_from_client('false') app.IGNORE_WORDS = [_.strip() for _ in ignore_words.split(',')] if ignore_words else [] app.PREFERRED_WORDS = [_.strip() for _ in preferred_words.split(',')] if preferred_words else [] app.UNDESIRED_WORDS = [_.strip() for _ in undesired_words.split(',')] if undesired_words else [] app.TRACKERS_LIST = [_.strip() for _ in trackers_list.split(',')] if trackers_list else [] app.REQUIRE_WORDS = [_.strip() for _ in require_words.split(',')] if require_words else [] app.IGNORED_SUBS_LIST = [_.strip() for _ in ignored_subs_list.split(',')] 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.PROPERS_SEARCH_DAYS = try_int(propers_search_days, 2) config.change_PROPERS_FREQUENCY(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.TORRENT_SEED_LOCATION = torrent_seed_location.rstrip('/\\') app.instance.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/search/')
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, api_key=cur_key, cat_ids=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].api_key = cur_key newznab_provider_dict[cur_id].cat_ids = split_and_strip( 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) # Update the custom newznab provider list NewznabProvider.save_newnab_providers() 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) # Update the torrentrss provider list app.TORRENTRSS_PROVIDERS = [ provider.name for provider in app.torrentRssProviderList ] 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 providers.sorted_provider_list() 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 cur_torrent_provider in [ prov for prov in providers.sorted_provider_list() if prov.provider_type == GenericProvider.TORRENT ]: if hasattr(cur_torrent_provider, 'custom_url'): try: cur_torrent_provider.custom_url = str( kwargs['{id}_custom_url'.format( id=cur_torrent_provider.get_id())]).strip() except (AttributeError, KeyError): cur_torrent_provider.custom_url = None # these exceptions are actually catching unselected checkboxes if hasattr(cur_torrent_provider, 'minseed'): try: cur_torrent_provider.minseed = int( str(kwargs['{id}_minseed'.format( id=cur_torrent_provider.get_id())]).strip()) except (AttributeError, KeyError): cur_torrent_provider.minseed = 0 # these exceptions are actually catching unselected checkboxes if hasattr(cur_torrent_provider, 'minleech'): try: cur_torrent_provider.minleech = int( str(kwargs['{id}_minleech'.format( id=cur_torrent_provider.get_id())]).strip()) except (AttributeError, KeyError): cur_torrent_provider.minleech = 0 # these exceptions are actually catching unselected checkboxes if hasattr(cur_torrent_provider, 'ratio'): try: ratio = float( str(kwargs['{id}_ratio'.format( id=cur_torrent_provider.get_id())]).strip()) cur_torrent_provider.ratio = (ratio, -1)[ratio < 0] except (AttributeError, KeyError, ValueError): cur_torrent_provider.ratio = None # these exceptions are actually catching unselected checkboxes if hasattr(cur_torrent_provider, 'digest'): try: cur_torrent_provider.digest = str( kwargs['{id}_digest'.format( id=cur_torrent_provider.get_id())]).strip() except (AttributeError, KeyError): cur_torrent_provider.digest = None # these exceptions are actually catching unselected checkboxes if hasattr(cur_torrent_provider, 'hash'): try: cur_torrent_provider.hash = str(kwargs['{id}_hash'.format( id=cur_torrent_provider.get_id())]).strip() except (AttributeError, KeyError): cur_torrent_provider.hash = None # these exceptions are actually catching unselected checkboxes if hasattr(cur_torrent_provider, 'api_key'): try: cur_torrent_provider.api_key = str( kwargs['{id}_api_key'.format( id=cur_torrent_provider.get_id())]).strip() except (AttributeError, KeyError): cur_torrent_provider.api_key = None # these exceptions are actually catching unselected checkboxes if hasattr(cur_torrent_provider, 'username'): try: cur_torrent_provider.username = str( kwargs['{id}_username'.format( id=cur_torrent_provider.get_id())]).strip() except (AttributeError, KeyError): cur_torrent_provider.username = None # these exceptions are actually catching unselected checkboxes if hasattr(cur_torrent_provider, 'password'): try: cur_torrent_provider.password = str( kwargs['{id}_password'.format( id=cur_torrent_provider.get_id())]).strip() except (AttributeError, KeyError): cur_torrent_provider.password = None # these exceptions are actually catching unselected checkboxes if hasattr(cur_torrent_provider, 'passkey'): try: cur_torrent_provider.passkey = str( kwargs['{id}_passkey'.format( id=cur_torrent_provider.get_id())]).strip() except (AttributeError, KeyError): cur_torrent_provider.passkey = None # these exceptions are actually catching unselected checkboxes if hasattr(cur_torrent_provider, 'pin'): try: cur_torrent_provider.pin = str(kwargs['{id}_pin'.format( id=cur_torrent_provider.get_id())]).strip() except (AttributeError, KeyError): cur_torrent_provider.pin = None # these exceptions are actually catching unselected checkboxes if hasattr(cur_torrent_provider, 'confirmed'): try: cur_torrent_provider.confirmed = config.checkbox_to_value( kwargs['{id}_confirmed'.format( id=cur_torrent_provider.get_id())]) except (AttributeError, KeyError): cur_torrent_provider.confirmed = 0 # these exceptions are actually catching unselected checkboxes if hasattr(cur_torrent_provider, 'ranked'): try: cur_torrent_provider.ranked = config.checkbox_to_value( kwargs['{id}_ranked'.format( id=cur_torrent_provider.get_id())]) except (AttributeError, KeyError): cur_torrent_provider.ranked = 0 # these exceptions are actually catching unselected checkboxes if hasattr(cur_torrent_provider, 'engrelease'): try: cur_torrent_provider.engrelease = config.checkbox_to_value( kwargs['{id}_engrelease'.format( id=cur_torrent_provider.get_id())]) except (AttributeError, KeyError): cur_torrent_provider.engrelease = 0 # these exceptions are actually catching unselected checkboxes if hasattr(cur_torrent_provider, 'onlyspasearch'): try: cur_torrent_provider.onlyspasearch = config.checkbox_to_value( kwargs['{id}_onlyspasearch'.format( id=cur_torrent_provider.get_id())]) except (AttributeError, KeyError): cur_torrent_provider.onlyspasearch = 0 # these exceptions are actually catching unselected checkboxes if hasattr(cur_torrent_provider, 'sorting'): try: cur_torrent_provider.sorting = str( kwargs['{id}_sorting'.format( id=cur_torrent_provider.get_id())]).strip() except (AttributeError, KeyError): cur_torrent_provider.sorting = 'seeders' # these exceptions are actually catching unselected checkboxes if hasattr(cur_torrent_provider, 'freeleech'): try: cur_torrent_provider.freeleech = config.checkbox_to_value( kwargs['{id}_freeleech'.format( id=cur_torrent_provider.get_id())]) except (AttributeError, KeyError): cur_torrent_provider.freeleech = 0 # these exceptions are actually catching unselected checkboxes if hasattr(cur_torrent_provider, 'search_mode'): try: cur_torrent_provider.search_mode = str( kwargs['{id}_search_mode'.format( id=cur_torrent_provider.get_id())]).strip() except (AttributeError, KeyError): cur_torrent_provider.search_mode = 'eponly' # these exceptions are actually catching unselected checkboxes if hasattr(cur_torrent_provider, 'search_fallback'): try: cur_torrent_provider.search_fallback = config.checkbox_to_value( kwargs['{id}_search_fallback'.format( id=cur_torrent_provider.get_id())]) except (AttributeError, KeyError): cur_torrent_provider.search_fallback = 0 # these exceptions are catching unselected checkboxes if hasattr(cur_torrent_provider, 'enable_daily'): try: cur_torrent_provider.enable_daily = config.checkbox_to_value( kwargs['{id}_enable_daily'.format( id=cur_torrent_provider.get_id())]) except (AttributeError, KeyError): cur_torrent_provider.enable_daily = 0 # these exceptions are actually catching unselected checkboxes if hasattr(cur_torrent_provider, 'enable_manualsearch'): try: cur_torrent_provider.enable_manualsearch = config.checkbox_to_value( kwargs['{id}_enable_manualsearch'.format( id=cur_torrent_provider.get_id())]) except (AttributeError, KeyError): cur_torrent_provider.enable_manualsearch = 0 # these exceptions are actually catching unselected checkboxes if hasattr(cur_torrent_provider, 'enable_backlog'): try: cur_torrent_provider.enable_backlog = config.checkbox_to_value( kwargs['{id}_enable_backlog'.format( id=cur_torrent_provider.get_id())]) except (AttributeError, KeyError): cur_torrent_provider.enable_backlog = 0 # these exceptions are actually catching unselected checkboxes if hasattr(cur_torrent_provider, 'cat'): try: cur_torrent_provider.cat = int( str(kwargs['{id}_cat'.format( id=cur_torrent_provider.get_id())]).strip()) except (AttributeError, KeyError): cur_torrent_provider.cat = 0 # these exceptions are actually catching unselected checkboxes if hasattr(cur_torrent_provider, 'subtitle'): try: cur_torrent_provider.subtitle = config.checkbox_to_value( kwargs['{id}_subtitle'.format( id=cur_torrent_provider.get_id())]) except (AttributeError, KeyError): cur_torrent_provider.subtitle = 0 # these exceptions are actually catching unselected checkboxes if cur_torrent_provider.enable_cookies: try: cur_torrent_provider.cookies = str( kwargs['{id}_cookies'.format( id=cur_torrent_provider.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 cur_nzb_provider in [ prov for prov in providers.sorted_provider_list() if prov.provider_type == GenericProvider.NZB ]: # We don't want to overwrite the api key, as that's not available in the second tab for newznab providers. if hasattr(cur_nzb_provider, 'api_key') and not isinstance( cur_nzb_provider, NewznabProvider): try: cur_nzb_provider.api_key = str( kwargs['{id}_api_key'.format( id=cur_nzb_provider.get_id())]).strip() except (AttributeError, KeyError): cur_nzb_provider.api_key = None # these exceptions are actually catching unselected checkboxes if hasattr(cur_nzb_provider, 'username'): try: cur_nzb_provider.username = str( kwargs['{id}_username'.format( id=cur_nzb_provider.get_id())]).strip() except (AttributeError, KeyError): cur_nzb_provider.username = None # these exceptions are actually catching unselected checkboxes if hasattr(cur_nzb_provider, 'search_mode'): try: cur_nzb_provider.search_mode = str( kwargs['{id}_search_mode'.format( id=cur_nzb_provider.get_id())]).strip() except (AttributeError, KeyError): cur_nzb_provider.search_mode = 'eponly' # these exceptions are actually catching unselected checkboxes if hasattr(cur_nzb_provider, 'search_fallback'): try: cur_nzb_provider.search_fallback = config.checkbox_to_value( kwargs['{id}_search_fallback'.format( id=cur_nzb_provider.get_id())]) except (AttributeError, KeyError): cur_nzb_provider.search_fallback = 0 # these exceptions are actually catching unselected checkboxes if hasattr(cur_nzb_provider, 'enable_daily'): try: cur_nzb_provider.enable_daily = config.checkbox_to_value( kwargs['{id}_enable_daily'.format( id=cur_nzb_provider.get_id())]) except (AttributeError, KeyError): cur_nzb_provider.enable_daily = 0 # these exceptions are actually catching unselected checkboxes if hasattr(cur_nzb_provider, 'enable_manualsearch'): try: cur_nzb_provider.enable_manualsearch = config.checkbox_to_value( kwargs['{id}_enable_manualsearch'.format( id=cur_nzb_provider.get_id())]) except (AttributeError, KeyError): cur_nzb_provider.enable_manualsearch = 0 # these exceptions are actually catching unselected checkboxes if hasattr(cur_nzb_provider, 'enable_backlog'): try: cur_nzb_provider.enable_backlog = config.checkbox_to_value( kwargs['{id}_enable_backlog'.format( id=cur_nzb_provider.get_id())]) except (AttributeError, KeyError): cur_nzb_provider.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.instance.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/providers/')
def addNewShow(self, whichSeries=None, indexer_lang=None, rootDir=None, defaultStatus=None, quality_preset=None, allowed_qualities=None, preferred_qualities=None, season_folders=None, subtitles=None, fullShowPath=None, other_shows=None, skipShow=None, providedIndexer=None, anime=None, scene=None, blacklist=None, whitelist=None, defaultStatusAfter=None): """ Receive tvdb id, dir, and other options and create a show from them. If extra show dirs are provided then it forwards back to newShow, if not it goes to /home. """ provided_indexer = providedIndexer indexer_lang = app.INDEXER_DEFAULT_LANGUAGE if not indexer_lang else indexer_lang # grab our list of other dirs if given if not other_shows: other_shows = [] elif not isinstance(other_shows, list): other_shows = [other_shows] other_shows = decode_shows(other_shows) def finishAddShow(): # if there are no extra shows then go home if not other_shows: return json_response(redirect='/home/') # go to add the next show return json_response( redirect='/addShows/newShow/', params=[ ('show_to_add' if not i else 'other_shows', cur_dir) for i, cur_dir in enumerate(other_shows) ] ) # if we're skipping then behave accordingly if skipShow: return finishAddShow() # sanity check on our inputs if (not rootDir and not fullShowPath) or not whichSeries: error_msg = 'Missing params, no Indexer ID or folder: {series!r} and {root!r}/{path!r}'.format( series=whichSeries, root=rootDir, path=fullShowPath) log.error(error_msg) return json_response( result=False, message=error_msg, redirect='/home/' ) # figure out what show we're adding and where series_pieces = whichSeries.split('|') if (whichSeries and rootDir) or (whichSeries and fullShowPath and len(series_pieces) > 1): if len(series_pieces) < 6: log.error('Unable to add show due to show selection. Not enough arguments: {pieces!r}', {'pieces': series_pieces}) ui.notifications.error('Unknown error. Unable to add show due to problem with show selection.') return json_response( result=False, message='Unable to add show due to show selection. Not enough arguments: {0!r}'.format(series_pieces), redirect='/addShows/existingShows/' ) indexer = int(series_pieces[1]) indexer_id = int(series_pieces[3]) show_name = series_pieces[4] else: # if no indexer was provided use the default indexer set in General settings if not provided_indexer: provided_indexer = app.INDEXER_DEFAULT indexer = int(provided_indexer) indexer_id = int(whichSeries) show_name = os.path.basename(os.path.normpath(fullShowPath)) # use the whole path if it's given, or else append the show name to the root dir to get the full show path if fullShowPath: show_dir = os.path.normpath(fullShowPath) else: show_dir = os.path.join(rootDir, sanitize_filename(show_name)) # blanket policy - if the dir exists you should have used 'add existing show' numbnuts if os.path.isdir(show_dir) and not fullShowPath: ui.notifications.error('Unable to add show', 'Folder {path} exists already'.format(path=show_dir)) return json_response( result=False, message='Unable to add show: Folder {path} exists already'.format(path=show_dir), redirect='/addShows/existingShows/' ) # don't create show dir if config says not to if app.ADD_SHOWS_WO_DIR: log.info('Skipping initial creation of {path} due to config.ini setting', {'path': show_dir}) else: dir_exists = helpers.make_dir(show_dir) if not dir_exists: log.error("Unable to create the folder {path}, can't add the show", {'path': show_dir}) ui.notifications.error('Unable to add show', 'Unable to create the folder {path}, can\'t add the show'.format(path=show_dir)) # Don't redirect to default page because user wants to see the new show return json_response( result=False, message='Unable to add show: Unable to create the folder {path}'.format(path=show_dir), redirect='/home/' ) else: helpers.chmod_as_parent(show_dir) # prepare the inputs for passing along scene = config.checkbox_to_value(scene) anime = config.checkbox_to_value(anime) season_folders = config.checkbox_to_value(season_folders) subtitles = config.checkbox_to_value(subtitles) if whitelist: if not isinstance(whitelist, list): whitelist = [whitelist] whitelist = short_group_names(whitelist) if blacklist: if not isinstance(blacklist, list): blacklist = [blacklist] blacklist = short_group_names(blacklist) if not allowed_qualities: allowed_qualities = [] if not preferred_qualities or try_int(quality_preset, None): preferred_qualities = [] if not isinstance(allowed_qualities, list): allowed_qualities = [allowed_qualities] if not isinstance(preferred_qualities, list): preferred_qualities = [preferred_qualities] new_quality = Quality.combine_qualities([int(q) for q in allowed_qualities], [int(q) for q in preferred_qualities]) # add the show app.show_queue_scheduler.action.addShow(indexer, indexer_id, show_dir, int(defaultStatus), new_quality, season_folders, indexer_lang, subtitles, anime, scene, None, blacklist, whitelist, int(defaultStatusAfter)) ui.notifications.message('Show added', 'Adding the specified show into {path}'.format(path=show_dir)) return finishAddShow()
def _set_common_settings(provider, **kwargs): if hasattr(provider, 'username'): try: provider.username = str(kwargs['{id}_username'.format(id=provider.get_id())]).strip() except (AttributeError, KeyError): provider.username = None # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'api_key'): try: provider.api_key = str(kwargs['{id}_api_key'.format(id=provider.get_id())]).strip() except (AttributeError, KeyError): pass if hasattr(provider, 'search_mode'): try: provider.search_mode = str(kwargs['{id}_search_mode'.format(id=provider.get_id())]).strip() except (AttributeError, KeyError): provider.search_mode = 'eponly' # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'search_fallback'): try: provider.search_fallback = config.checkbox_to_value( kwargs['{id}_search_fallback'.format(id=provider.get_id())]) except (AttributeError, KeyError): provider.search_fallback = 0 # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'enable_daily'): try: provider.enable_daily = config.checkbox_to_value( kwargs['{id}_enable_daily'.format(id=provider.get_id())]) except (AttributeError, KeyError): provider.enable_daily = 0 # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'enable_backlog'): try: provider.enable_backlog = config.checkbox_to_value( kwargs['{id}_enable_backlog'.format(id=provider.get_id())]) except (AttributeError, KeyError): provider.enable_backlog = 0 # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'enable_manualsearch'): try: provider.enable_manualsearch = config.checkbox_to_value( kwargs['{id}_enable_manualsearch'.format(id=provider.get_id())]) except (AttributeError, KeyError): provider.enable_manualsearch = 0 # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'enable_search_delay'): try: provider.enable_search_delay = config.checkbox_to_value( kwargs['{id}_enable_search_delay'.format(id=provider.get_id())]) except (AttributeError, KeyError): provider.enable_search_delay = 0 # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'search_delay'): try: search_delay = float(str(kwargs['{id}_search_delay'.format(id=provider.get_id())]).strip()) provider.search_delay = (int(search_delay * 60), 30)[search_delay < 0.5] except (AttributeError, KeyError, ValueError): provider.search_delay = 480 # these exceptions are actually catching unselected checkboxes
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, remove_from_client=None, randomize_providers=None, use_failed_downloads=None, delete_failed=None, propers_search_days=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, torrent_checker_frequency=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, torrent_seed_location=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=os.path.normpath(nzb_dir)) ] if not config.change_TORRENT_DIR(torrent_dir): results += [ 'Unable to create directory {dir}, dir not changed.'.format( dir=os.path.normpath(torrent_dir)) ] config.change_DAILYSEARCH_FREQUENCY(dailysearch_frequency) config.change_TORRENT_CHECKER_FREQUENCY(torrent_checker_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) if app.TORRENT_METHOD != 'blackhole' and app.TORRENT_METHOD in ( 'transmission', 'deluge', 'deluged'): config.change_remove_from_client(remove_from_client) else: config.change_remove_from_client('false') app.IGNORE_WORDS = [_.strip() for _ in ignore_words.split(',') ] if ignore_words else [] app.PREFERRED_WORDS = [_.strip() for _ in preferred_words.split(',') ] if preferred_words else [] app.UNDESIRED_WORDS = [_.strip() for _ in undesired_words.split(',') ] if undesired_words else [] app.TRACKERS_LIST = [_.strip() for _ in trackers_list.split(',') ] if trackers_list else [] app.REQUIRE_WORDS = [_.strip() for _ in require_words.split(',') ] if require_words else [] app.IGNORED_SUBS_LIST = [ _.strip() for _ in ignored_subs_list.split(',') ] 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.PROPERS_SEARCH_DAYS = try_int(propers_search_days, 2) config.change_PROPERS_FREQUENCY(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.TORRENT_SEED_LOCATION = torrent_seed_location.rstrip('/\\') app.instance.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/search/')
def _set_torrent_settings(provider, **kwargs): if hasattr(provider, 'custom_url'): try: provider.custom_url = str(kwargs['{id}_custom_url'.format(id=provider.get_id())]).strip() except (AttributeError, KeyError): provider.custom_url = None # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'minseed'): try: provider.minseed = int(str(kwargs['{id}_minseed'.format(id=provider.get_id())]).strip()) except (AttributeError, KeyError, ValueError): provider.minseed = 1 # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'minleech'): try: provider.minleech = int(str(kwargs['{id}_minleech'.format(id=provider.get_id())]).strip()) except (AttributeError, KeyError, ValueError): provider.minleech = 0 # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'ratio'): try: ratio = float(str(kwargs['{id}_ratio'.format(id=provider.get_id())]).strip()) provider.ratio = (ratio, -1)[ratio < 0] except (AttributeError, KeyError, ValueError): provider.ratio = '' # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'digest'): try: provider.digest = str(kwargs['{id}_digest'.format(id=provider.get_id())]).strip() except (AttributeError, KeyError): provider.digest = None # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'hash'): try: provider.hash = str(kwargs['{id}_hash'.format(id=provider.get_id())]).strip() except (AttributeError, KeyError): provider.hash = None # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'password'): try: provider.password = str(kwargs['{id}_password'.format(id=provider.get_id())]).strip() except (AttributeError, KeyError): provider.password = None # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'passkey'): try: provider.passkey = str(kwargs['{id}_passkey'.format(id=provider.get_id())]).strip() except (AttributeError, KeyError): provider.passkey = None # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'pin'): try: provider.pin = str(kwargs['{id}_pin'.format(id=provider.get_id())]).strip() except (AttributeError, KeyError): provider.pin = None # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'confirmed'): try: provider.confirmed = config.checkbox_to_value( kwargs['{id}_confirmed'.format(id=provider.get_id())]) except (AttributeError, KeyError): provider.confirmed = 0 # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'ranked'): try: provider.ranked = config.checkbox_to_value( kwargs['{id}_ranked'.format(id=provider.get_id())]) except (AttributeError, KeyError): provider.ranked = 0 # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'engrelease'): try: provider.engrelease = config.checkbox_to_value( kwargs['{id}_engrelease'.format(id=provider.get_id())]) except (AttributeError, KeyError): provider.engrelease = 0 # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'onlyspasearch'): try: provider.onlyspasearch = config.checkbox_to_value( kwargs['{id}_onlyspasearch'.format(id=provider.get_id())]) except (AttributeError, KeyError): provider.onlyspasearch = 0 # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'sorting'): try: provider.sorting = str(kwargs['{id}_sorting'.format(id=provider.get_id())]).strip() except (AttributeError, KeyError): provider.sorting = 'seeders' # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'freeleech'): try: provider.freeleech = config.checkbox_to_value( kwargs['{id}_freeleech'.format(id=provider.get_id())]) except (AttributeError, KeyError): provider.freeleech = 0 # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'cat'): try: provider.cat = int(str(kwargs['{id}_cat'.format(id=provider.get_id())]).strip()) except (AttributeError, KeyError): provider.cat = 0 # these exceptions are actually catching unselected checkboxes if hasattr(provider, 'subtitle'): try: provider.subtitle = config.checkbox_to_value( kwargs['{id}_subtitle'.format(id=provider.get_id())]) except (AttributeError, KeyError): provider.subtitle = 0 # these exceptions are actually catching unselected checkboxes if provider.enable_cookies: try: provider.cookies = str(kwargs['{id}_cookies'.format(id=provider.get_id())]).strip() except (AttributeError, KeyError): # I don't want to configure a default value here, as it can also # be configured intially as a custom rss torrent provider pass
def addNewShow(self, whichSeries=None, indexer_lang=None, rootDir=None, defaultStatus=None, quality_preset=None, allowed_qualities=None, preferred_qualities=None, season_folders=None, subtitles=None, fullShowPath=None, other_shows=None, skipShow=None, providedIndexer=None, anime=None, scene=None, blacklist=None, whitelist=None, defaultStatusAfter=None): """ Receive tvdb id, dir, and other options and create a show from them. If extra show dirs are provided then it forwards back to newShow, if not it goes to /home. """ provided_indexer = providedIndexer indexer_lang = app.INDEXER_DEFAULT_LANGUAGE if not indexer_lang else indexer_lang # grab our list of other dirs if given if not other_shows: other_shows = [] elif not isinstance(other_shows, list): other_shows = [other_shows] def finishAddShow(): # if there are no extra shows then go home if not other_shows: return json_redirect('/home/') # go to add the next show return json_redirect( '/addShows/newShow/', [('show_to_add' if not i else 'other_shows', cur_dir) for i, cur_dir in enumerate(other_shows)]) # if we're skipping then behave accordingly if skipShow: return finishAddShow() # sanity check on our inputs if (not rootDir and not fullShowPath) or not whichSeries: return 'Missing params, no Indexer ID or folder:{series!r} and {root!r}/{path!r}'.format( series=whichSeries, root=rootDir, path=fullShowPath) # figure out what show we're adding and where series_pieces = whichSeries.split('|') if (whichSeries and rootDir) or (whichSeries and fullShowPath and len(series_pieces) > 1): if len(series_pieces) < 6: logger.log( u'Unable to add show due to show selection. Not enough arguments: %s' % (repr(series_pieces)), logger.ERROR) ui.notifications.error( 'Unknown error. Unable to add show due to problem with show selection.' ) return json_redirect('/addShows/existingShows/') indexer = int(series_pieces[1]) indexer_id = int(series_pieces[3]) show_name = series_pieces[4] else: # if no indexer was provided use the default indexer set in General settings if not provided_indexer: provided_indexer = app.INDEXER_DEFAULT indexer = int(provided_indexer) indexer_id = int(whichSeries) show_name = os.path.basename(os.path.normpath(fullShowPath)) # use the whole path if it's given, or else append the show name to the root dir to get the full show path if fullShowPath: show_dir = os.path.normpath(fullShowPath) else: show_dir = os.path.join(rootDir, sanitize_filename(show_name)) # blanket policy - if the dir exists you should have used 'add existing show' numbnuts if os.path.isdir(show_dir) and not fullShowPath: ui.notifications.error( 'Unable to add show', 'Folder {path} exists already'.format(path=show_dir)) return json_redirect('/addShows/existingShows/') # don't create show dir if config says not to if app.ADD_SHOWS_WO_DIR: logger.log( u'Skipping initial creation of {path} due to config.ini setting' .format(path=show_dir)) else: dir_exists = helpers.make_dir(show_dir) if not dir_exists: logger.log( u'Unable to create the folder {path}, can\'t add the show'. format(path=show_dir), logger.ERROR) ui.notifications.error( 'Unable to add show', 'Unable to create the folder {path}, can\'t add the show'. format(path=show_dir)) # Don't redirect to default page because user wants to see the new show return json_redirect('/home/') else: helpers.chmod_as_parent(show_dir) # prepare the inputs for passing along scene = config.checkbox_to_value(scene) anime = config.checkbox_to_value(anime) season_folders = config.checkbox_to_value(season_folders) subtitles = config.checkbox_to_value(subtitles) if whitelist: whitelist = short_group_names(whitelist) if blacklist: blacklist = short_group_names(blacklist) if not allowed_qualities: allowed_qualities = [] if not preferred_qualities or try_int(quality_preset, None): preferred_qualities = [] if not isinstance(allowed_qualities, list): allowed_qualities = [allowed_qualities] if not isinstance(preferred_qualities, list): preferred_qualities = [preferred_qualities] new_quality = Quality.combine_qualities( [int(q) for q in allowed_qualities], [int(q) for q in preferred_qualities]) # add the show app.show_queue_scheduler.action.addShow(indexer, indexer_id, show_dir, int(defaultStatus), new_quality, season_folders, indexer_lang, subtitles, anime, scene, None, blacklist, whitelist, int(defaultStatusAfter)) ui.notifications.message( 'Show added', 'Adding the specified show into {path}'.format(path=show_dir)) return finishAddShow()
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', layout_wide=None, 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_auth_type=0, git_username=None, git_password=None, git_token=None, subliminal_log=None, privacy_level='normal', fanart_background=None, fanart_background_opacity=None, dbdebug=None, fallback_plex_enable=1, fallback_plex_notifications=1, fallback_plex_timeout=3, web_root=None, ssl_ca_bundle=None): results = [] # Misc app.INDEXER_DEFAULT_LANGUAGE = indexerDefaultLang app.EP_DEFAULT_DELETED_STATUS = int(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_AUTH_TYPE = int(git_auth_type) app.GIT_USERNAME = git_username app.GIT_PASSWORD = git_password app.GIT_TOKEN = git_token app.GIT_RESET = config.checkbox_to_value(git_reset) app.GIT_RESET_BRANCHES = [ helpers.to_text(branch) for branch in helpers.ensure_list(git_reset_branches) ] if app.GIT_PATH != git_path: app.GIT_PATH = git_path config.change_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.SSL_CA_BUNDLE = ssl_ca_bundle # app.LOG_DIR is set in config.change_LOG_DIR() app.COMING_EPS_MISSED_RANGE = int(coming_eps_missed_range) app.NOTIFY_ON_LOGIN = config.checkbox_to_value(notify_on_login) app.WEB_PORT = int(web_port) app.WEB_IPV6 = config.checkbox_to_value(web_ipv6) app.ENCRYPTION_VERSION = config.checkbox_to_value(encryption_version) app.WEB_USERNAME = web_username app.WEB_PASSWORD = web_password app.WEB_ROOT = web_root app.DEBUG = config.checkbox_to_value(debug) app.DBDEBUG = config.checkbox_to_value(dbdebug) app.WEB_LOG = config.checkbox_to_value(web_log) app.SUBLIMINAL_LOG = config.checkbox_to_value(subliminal_log) # Added for tvdb / plex fallback app.FALLBACK_PLEX_ENABLE = config.checkbox_to_value( fallback_plex_enable) app.FALLBACK_PLEX_NOTIFICATIONS = config.checkbox_to_value( fallback_plex_notifications) app.FALLBACK_PLEX_TIMEOUT = try_int(fallback_plex_timeout) if not config.change_LOG_DIR(log_dir): results += [ 'Unable to create directory {dir}, ' 'log directory not changed.'.format( dir=os.path.normpath(log_dir)) ] # Reconfigure the logger logger.reconfigure() # Validate github credentials try: if app.GIT_AUTH_TYPE == 0: github_client.authenticate(app.GIT_USERNAME, app.GIT_PASSWORD) else: github = github_client.token_authenticate(app.GIT_TOKEN) if app.GIT_USERNAME and app.GIT_USERNAME != github_client.get_user( gh=github): app.GIT_USERNAME = github_client.get_user(gh=github) 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=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=os.path.normpath(https_key)) ] app.HANDLE_REVERSE_PROXY = config.checkbox_to_value( handle_reverse_proxy) config.change_theme(theme_name) app.LAYOUT_WIDE = config.checkbox_to_value(layout_wide) app.FANART_BACKGROUND = config.checkbox_to_value(fanart_background) app.FANART_BACKGROUND_OPACITY = fanart_background_opacity app.DEFAULT_PAGE = default_page app.instance.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/general/')