def test_change_tv_download_dir(self): """ Test change_tv_download_dir """ sickbeard.TV_DOWNLOAD_DIR = '' self.assertTrue(config.change_tv_download_dir('cache')) self.assertFalse(config.change_tv_download_dir('/:/Downloads/Completed')) # INVALID self.assertTrue(config.change_tv_download_dir(''))
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, processor_follow_symlinks=None, del_rar_contents=None, process_automatically=None, no_delete=None, rename_episodes=None, airdate_episodes=None, file_timestamp_timezone=None, unpack=None, unpack_dir=None, unrar_tool=None, alt_unrar_tool=None, move_associated_files=None, delete_non_associated_files=None, sync_files=None, postpone_if_sync_files=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, use_icacls=None): results = [] if not config.change_tv_download_dir(tv_download_dir): results += [ "Unable to create directory " + ek(os.path.normpath, tv_download_dir) + ", dir not changed." ] config.change_postprocessor_frequency(autopostprocessor_frequency) config.change_process_automatically(process_automatically) sickbeard.USE_ICACLS = config.checkbox_to_value(use_icacls) config.change_unrar_tool(unrar_tool, alt_unrar_tool) unpack = try_int(unpack) if unpack == sickbeard.UNPACK_PROCESS_CONTENTS: sickbeard.UNPACK = int(self.isRarSupported() != 'not supported') if sickbeard.UNPACK != sickbeard.UNPACK_PROCESS_CONTENTS: results.append( _("Unpacking Not Supported, disabling unpack setting")) elif unpack in sickbeard.unpackStrings: sickbeard.UNPACK = unpack if not config.change_unpack_dir(unpack_dir): results += [ "Unable to change unpack directory to " + ek(os.path.normpath, unpack_dir) + ", check the logs." ] sickbeard.NO_DELETE = config.checkbox_to_value(no_delete) sickbeard.KEEP_PROCESSED_DIR = config.checkbox_to_value( keep_processed_dir) sickbeard.CREATE_MISSING_SHOW_DIRS = config.checkbox_to_value( create_missing_show_dirs) sickbeard.ADD_SHOWS_WO_DIR = config.checkbox_to_value(add_shows_wo_dir) sickbeard.PROCESS_METHOD = process_method sickbeard.PROCESSOR_FOLLOW_SYMLINKS = config.checkbox_to_value( processor_follow_symlinks) sickbeard.DELRARCONTENTS = config.checkbox_to_value(del_rar_contents) sickbeard.EXTRA_SCRIPTS = [ x.strip() for x in extra_scripts.split('|') if x.strip() ] sickbeard.RENAME_EPISODES = config.checkbox_to_value(rename_episodes) sickbeard.AIRDATE_EPISODES = config.checkbox_to_value(airdate_episodes) sickbeard.FILE_TIMESTAMP_TIMEZONE = file_timestamp_timezone sickbeard.MOVE_ASSOCIATED_FILES = config.checkbox_to_value( move_associated_files) sickbeard.DELETE_NON_ASSOCIATED_FILES = config.checkbox_to_value( delete_non_associated_files) sickbeard.SYNC_FILES = sync_files sickbeard.POSTPONE_IF_SYNC_FILES = config.checkbox_to_value( postpone_if_sync_files) sickbeard.ALLOWED_EXTENSIONS = ','.join( {x.strip() for x in allowed_extensions.split(',') if x.strip()}) sickbeard.NAMING_CUSTOM_ABD = config.checkbox_to_value( naming_custom_abd) sickbeard.NAMING_CUSTOM_SPORTS = config.checkbox_to_value( naming_custom_sports) sickbeard.NAMING_CUSTOM_ANIME = config.checkbox_to_value( naming_custom_anime) sickbeard.NAMING_STRIP_YEAR = config.checkbox_to_value( naming_strip_year) sickbeard.NFO_RENAME = config.checkbox_to_value(nfo_rename) sickbeard.METADATA_KODI = kodi_data sickbeard.METADATA_KODI_12PLUS = kodi_12plus_data sickbeard.METADATA_MEDIABROWSER = mediabrowser_data sickbeard.METADATA_PS3 = sony_ps3_data sickbeard.METADATA_WDTV = wdtv_data sickbeard.METADATA_TIVO = tivo_data sickbeard.METADATA_MEDE8ER = mede8er_data sickbeard.metadata_provider_dict['KODI'].set_config( sickbeard.METADATA_KODI) sickbeard.metadata_provider_dict['KODI 12+'].set_config( sickbeard.METADATA_KODI_12PLUS) sickbeard.metadata_provider_dict['MediaBrowser'].set_config( sickbeard.METADATA_MEDIABROWSER) sickbeard.metadata_provider_dict['Sony PS3'].set_config( sickbeard.METADATA_PS3) sickbeard.metadata_provider_dict['WDTV'].set_config( sickbeard.METADATA_WDTV) sickbeard.metadata_provider_dict['TIVO'].set_config( sickbeard.METADATA_TIVO) sickbeard.metadata_provider_dict['Mede8er'].set_config( sickbeard.METADATA_MEDE8ER) if self.isNamingValid(naming_pattern, naming_multi_ep, anime_type=naming_anime) != "invalid": sickbeard.NAMING_PATTERN = naming_pattern sickbeard.NAMING_MULTI_EP = try_int( naming_multi_ep, NAMING_LIMITED_EXTEND_E_PREFIXED) sickbeard.NAMING_FORCE_FOLDERS = naming.check_force_season_folders( ) else: results.append( _("You tried saving an invalid normal naming config, not saving your naming settings" )) if self.isNamingValid(naming_anime_pattern, naming_anime_multi_ep, anime_type=naming_anime) != "invalid": sickbeard.NAMING_ANIME_PATTERN = naming_anime_pattern sickbeard.NAMING_ANIME_MULTI_EP = try_int( naming_anime_multi_ep, NAMING_LIMITED_EXTEND_E_PREFIXED) sickbeard.NAMING_ANIME = try_int(naming_anime, 3) sickbeard.NAMING_FORCE_FOLDERS = naming.check_force_season_folders( ) else: results.append( _("You tried saving an invalid anime naming config, not saving your naming settings" )) if self.isNamingValid(naming_abd_pattern, None, abd=True) != "invalid": sickbeard.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": sickbeard.NAMING_SPORTS_PATTERN = naming_sports_pattern else: results.append( "You tried saving an invalid sports naming config, not saving your sports settings" ) sickbeard.save_config() if results: for x in results: logger.log(x, logger.WARNING) ui.notifications.error(_('Error(s) Saving Configuration'), '<br>\n'.join(results)) else: ui.notifications.message(_('Configuration Saved'), ek(os.path.join, sickbeard.CONFIG_FILE)) return self.redirect("/config/postProcessing/")