From faa4bd82ae37ab58741f7638a8db451abee9d53c Mon Sep 17 00:00:00 2001 From: Bas Stottelaar Date: Thu, 10 Sep 2015 20:37:21 +0200 Subject: [PATCH] Add advanced option to stop renaming folders. Refs #2281. --- headphones/config.py | 2 ++ headphones/postprocessor.py | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/headphones/config.py b/headphones/config.py index d6d4e653..97cc5e6c 100644 --- a/headphones/config.py +++ b/headphones/config.py @@ -205,6 +205,8 @@ _CONFIG_DEFINITIONS = { 'PUSHOVER_ONSNATCH': (int, 'Pushover', 0), 'PUSHOVER_PRIORITY': (int, 'Pushover', 0), 'RENAME_FILES': (int, 'General', 0), + 'RENAME_UNPROCESSED': (bool_int, 'General', 1), + 'RENAME_FROZEN': (bool_int, 'General', 1), 'REPLACE_EXISTING_FOLDERS': (int, 'General', 0), 'KEEP_ORIGINAL_FOLDER': (int, 'General', 0), 'REQUIRED_WORDS': (str, 'General', ''), diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index d94140e1..fc9b8fc7 100755 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -104,7 +104,10 @@ def verify(albumid, albumpath, Kind=None, forced=False, keep_original_folder=Fal myDB.action('UPDATE snatched SET status = "Frozen" WHERE status NOT LIKE "Seed%" and AlbumID=?', [albumid]) frozen = re.search(r' \(Frozen\)(?:\[\d+\])?', albumpath) if not frozen: - renameUnprocessedFolder(albumpath, tag="Frozen") + if headphones.CONFIG.RENAME_FROZEN: + renameUnprocessedFolder(albumpath, tag="Frozen") + else: + logger.warn(u"Won't rename %s to mark as 'Frozen', because it is disabled.", albumpath.decode(headphones.SYS_ENCODING, 'replace')) return logger.info(u"Now adding/updating artist: " + release_dict['artist_name']) @@ -269,11 +272,14 @@ def verify(albumid, albumpath, Kind=None, forced=False, keep_original_folder=Fal doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list, Kind, keep_original_folder) return - logger.warn(u'Could not identify album: %s. It may not be the intended album.' % albumpath.decode(headphones.SYS_ENCODING, 'replace')) + logger.warn(u'Could not identify album: %s. It may not be the intended album.', albumpath.decode(headphones.SYS_ENCODING, 'replace')) myDB.action('UPDATE snatched SET status = "Unprocessed" WHERE status NOT LIKE "Seed%" and AlbumID=?', [albumid]) processed = re.search(r' \(Unprocessed\)(?:\[\d+\])?', albumpath) if not processed: - renameUnprocessedFolder(albumpath, tag="Unprocessed") + if headphones.CONFIG.RENAME_UNPROCESSED: + renameUnprocessedFolder(albumpath, tag="Unprocessed") + else: + logger.warn(u"Won't rename %s to mark as 'Unprocessed', because it is disabled.", albumpath.decode(headphones.SYS_ENCODING, 'replace')) def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list, Kind=None, keep_original_folder=False):