diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 879503ac..ce895f75 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -498,6 +498,9 @@ Use: $Disc/$disc (disc #), $Track/$track (track #), $Title/$title, $Artist/$artist, $Album/$album and $Year/$year +
+ +
diff --git a/headphones/__init__.py b/headphones/__init__.py index 2e1416c8..d83fecc7 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -93,6 +93,7 @@ DESTINATION_DIR = None LOSSLESS_DESTINATION_DIR = None FOLDER_FORMAT = None FILE_FORMAT = None +FILE_UNDERSCORES = False PATH_TO_XML = None PREFERRED_QUALITY = None PREFERRED_BITRATE = None @@ -291,7 +292,7 @@ def initialize(): HTTP_PORT, HTTP_HOST, HTTP_USERNAME, HTTP_PASSWORD, HTTP_ROOT, HTTP_PROXY, LAUNCH_BROWSER, API_ENABLED, API_KEY, GIT_PATH, GIT_USER, GIT_BRANCH, \ CURRENT_VERSION, LATEST_VERSION, CHECK_GITHUB, CHECK_GITHUB_ON_STARTUP, CHECK_GITHUB_INTERVAL, MUSIC_DIR, DESTINATION_DIR, \ LOSSLESS_DESTINATION_DIR, PREFERRED_QUALITY, PREFERRED_BITRATE, DETECT_BITRATE, ADD_ARTISTS, CORRECT_METADATA, MOVE_FILES, \ - RENAME_FILES, FOLDER_FORMAT, FILE_FORMAT, CLEANUP_FILES, INCLUDE_EXTRAS, EXTRAS, AUTOWANT_UPCOMING, AUTOWANT_ALL, KEEP_TORRENT_FILES, \ + RENAME_FILES, FOLDER_FORMAT, FILE_FORMAT, FILE_UNDERSCORES, CLEANUP_FILES, INCLUDE_EXTRAS, EXTRAS, AUTOWANT_UPCOMING, AUTOWANT_ALL, KEEP_TORRENT_FILES, \ ADD_ALBUM_ART, ALBUM_ART_FORMAT, EMBED_ALBUM_ART, EMBED_LYRICS, DOWNLOAD_DIR, BLACKHOLE, BLACKHOLE_DIR, USENET_RETENTION, SEARCH_INTERVAL, \ TORRENTBLACKHOLE_DIR, NUMBEROFSEEDERS, ISOHUNT, KAT, PIRATEBAY, MININOVA, WAFFLES, WAFFLES_UID, WAFFLES_PASSKEY, \ RUTRACKER, RUTRACKER_USER, RUTRACKER_PASSWORD, WHATCD, WHATCD_USERNAME, WHATCD_PASSWORD, DOWNLOAD_TORRENT_DIR, \ @@ -373,6 +374,7 @@ def initialize(): RENAME_FILES = bool(check_setting_int(CFG, 'General', 'rename_files', 0)) FOLDER_FORMAT = check_setting_str(CFG, 'General', 'folder_format', 'Artist/Album [Year]') FILE_FORMAT = check_setting_str(CFG, 'General', 'file_format', 'Track Artist - Album [Year] - Title') + FILE_UNDERSCORES = bool(check_setting_int(CFG, 'General', 'file_underscores', 0)) CLEANUP_FILES = bool(check_setting_int(CFG, 'General', 'cleanup_files', 0)) ADD_ALBUM_ART = bool(check_setting_int(CFG, 'General', 'add_album_art', 0)) ALBUM_ART_FORMAT = check_setting_str(CFG, 'General', 'album_art_format', 'folder') @@ -726,6 +728,7 @@ def config_write(): new_config['General']['rename_files'] = int(RENAME_FILES) new_config['General']['folder_format'] = FOLDER_FORMAT new_config['General']['file_format'] = FILE_FORMAT + new_config['General']['file_underscores'] = int(FILE_UNDERSCORES) new_config['General']['cleanup_files'] = int(CLEANUP_FILES) new_config['General']['add_album_art'] = int(ADD_ALBUM_ART) new_config['General']['album_art_format'] = ALBUM_ART_FORMAT diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index da1f4624..72e6d591 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -464,6 +464,9 @@ def addAlbumArt(artwork, albumpath, release): album_art_name = album_art_name.replace('?','_').replace(':', '_').encode(headphones.SYS_ENCODING, 'replace') + if headphones.FILE_UNDERSCORES: + album_art_name = album_art_name.replace(' ', '_') + if album_art_name.startswith('.'): album_art_name = album_art_name.replace(0, '_') @@ -493,6 +496,10 @@ def moveFiles(albumpath, release, tracks): artist = release['ArtistName'].replace('/', '_') album = release['AlbumTitle'].replace('/', '_') + if headphones.FILE_UNDERSCORES: + artist = artist.replace(' ', '_') + album = album.replace(' ', '_') + releasetype = release['Type'].replace('/', '_') if release['ArtistName'].startswith('The '): @@ -832,6 +839,9 @@ def renameFiles(albumpath, downloaded_track_list, release): new_file_name = new_file_name.replace('?','_').replace(':', '_').encode(headphones.SYS_ENCODING, 'replace') + if headphones.FILE_UNDERSCORES: + new_file_name = new_file_name.replace(' ', '_') + if new_file_name.startswith('.'): new_file_name = new_file_name.replace(0, '_') diff --git a/headphones/webserve.py b/headphones/webserve.py index b77d8cf7..58353679 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -647,6 +647,7 @@ class WebInterface(object): "lossless_dest_dir" : headphones.LOSSLESS_DESTINATION_DIR, "folder_format" : headphones.FOLDER_FORMAT, "file_format" : headphones.FILE_FORMAT, + "file_underscores" : checked(headphones.FILE_UNDERSCORES), "include_extras" : checked(headphones.INCLUDE_EXTRAS), "autowant_upcoming" : checked(headphones.AUTOWANT_UPCOMING), "autowant_all" : checked(headphones.AUTOWANT_ALL), @@ -720,7 +721,7 @@ class WebInterface(object): preferred_words=None, required_words=None, ignored_words=None, preferred_quality=0, preferred_bitrate=None, detect_bitrate=0, move_files=0, torrentblackhole_dir=None, download_torrent_dir=None, numberofseeders=None, use_piratebay=0, use_isohunt=0, use_kat=0, use_mininova=0, waffles=0, waffles_uid=None, waffles_passkey=None, whatcd=0, whatcd_username=None, whatcd_password=None, rutracker=0, rutracker_user=None, rutracker_password=None, rename_files=0, correct_metadata=0, cleanup_files=0, add_album_art=0, album_art_format=None, embed_album_art=0, embed_lyrics=0, - destination_dir=None, lossless_destination_dir=None, folder_format=None, file_format=None, include_extras=0, single=0, ep=0, compilation=0, soundtrack=0, live=0, + destination_dir=None, lossless_destination_dir=None, folder_format=None, file_format=None, file_underscores=0, include_extras=0, single=0, ep=0, compilation=0, soundtrack=0, live=0, remix=0, spokenword=0, audiobook=0, autowant_upcoming=False, autowant_all=False, keep_torrent_files=False, interface=None, log_dir=None, cache_dir=None, music_encoder=0, encoder=None, xldprofile=None, bitrate=None, samplingfrequency=None, encoderfolder=None, advancedencoder=None, encoderoutputformat=None, encodervbrcbr=None, encoderquality=None, encoderlossless=0, delete_lossless_files=0, prowl_enabled=0, prowl_onsnatch=0, prowl_keys=None, prowl_priority=0, xbmc_enabled=0, xbmc_host=None, xbmc_username=None, xbmc_password=None, @@ -806,6 +807,7 @@ class WebInterface(object): headphones.LOSSLESS_DESTINATION_DIR = lossless_destination_dir headphones.FOLDER_FORMAT = folder_format headphones.FILE_FORMAT = file_format + headphones.FILE_UNDERSCORES = file_underscores headphones.INCLUDE_EXTRAS = include_extras headphones.AUTOWANT_UPCOMING = autowant_upcoming headphones.AUTOWANT_ALL = autowant_all