diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 29b9c6fc..cde807b9 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -692,25 +692,56 @@
Post-Processing
- + +
- +
- - - - - + + + + +
as .jpg
Use $Artist/$artist, $Album/$album, $Year/$year
- - + +
diff --git a/headphones/__init__.py b/headphones/__init__.py index d5bcb6e7..1f3452ae 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -109,6 +109,7 @@ LOSSLESS_BITRATE_FROM = None LOSSLESS_BITRATE_TO = None ADD_ARTISTS = False CORRECT_METADATA = False +FREEZE_DB = False MOVE_FILES = False RENAME_FILES = False CLEANUP_FILES = False @@ -356,7 +357,7 @@ def initialize(): global __INITIALIZED__, FULL_PATH, PROG_DIR, VERBOSE, QUIET, DAEMON, SYS_PLATFORM, DATA_DIR, CONFIG_FILE, CFG, CONFIG_VERSION, LOG_DIR, CACHE_DIR, \ HTTP_PORT, HTTP_HOST, HTTP_USERNAME, HTTP_PASSWORD, HTTP_ROOT, HTTP_PROXY, LAUNCH_BROWSER, API_ENABLED, API_KEY, GIT_PATH, GIT_USER, GIT_BRANCH, DO_NOT_OVERRIDE_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, \ + LOSSLESS_DESTINATION_DIR, PREFERRED_QUALITY, PREFERRED_BITRATE, DETECT_BITRATE, ADD_ARTISTS, CORRECT_METADATA, FREEZE_DB, MOVE_FILES, \ RENAME_FILES, FOLDER_FORMAT, FILE_FORMAT, FILE_UNDERSCORES, CLEANUP_FILES, KEEP_NFO, INCLUDE_EXTRAS, EXTRAS, AUTOWANT_UPCOMING, AUTOWANT_ALL, KEEP_TORRENT_FILES, PREFER_TORRENTS, OPEN_MAGNET_LINKS, \ ADD_ALBUM_ART, ALBUM_ART_FORMAT, EMBED_ALBUM_ART, EMBED_LYRICS, REPLACE_EXISTING_FOLDERS, DOWNLOAD_DIR, BLACKHOLE, BLACKHOLE_DIR, USENET_RETENTION, SEARCH_INTERVAL, \ TORRENTBLACKHOLE_DIR, NUMBEROFSEEDERS, KAT, KAT_PROXY_URL, KAT_RATIO, PIRATEBAY, PIRATEBAY_PROXY_URL, PIRATEBAY_RATIO, MININOVA, MININOVA_RATIO, WAFFLES, WAFFLES_UID, WAFFLES_PASSKEY, WAFFLES_RATIO, \ @@ -437,6 +438,7 @@ def initialize(): LOSSLESS_BITRATE_TO = check_setting_int(CFG, 'General', 'lossless_bitrate_to', '') ADD_ARTISTS = bool(check_setting_int(CFG, 'General', 'auto_add_artists', 1)) CORRECT_METADATA = bool(check_setting_int(CFG, 'General', 'correct_metadata', 0)) + FREEZE_DB = bool(check_setting_int(CFG, 'General', 'freeze_db', 0)) MOVE_FILES = bool(check_setting_int(CFG, 'General', 'move_files', 0)) RENAME_FILES = bool(check_setting_int(CFG, 'General', 'rename_files', 0)) FOLDER_FORMAT = check_setting_str(CFG, 'General', 'folder_format', 'Artist/Album [Year]') @@ -882,6 +884,7 @@ def config_write(): new_config['General']['lossless_bitrate_to'] = LOSSLESS_BITRATE_TO new_config['General']['auto_add_artists'] = int(ADD_ARTISTS) new_config['General']['correct_metadata'] = int(CORRECT_METADATA) + new_config['General']['freeze_db'] = int(FREEZE_DB) new_config['General']['move_files'] = int(MOVE_FILES) new_config['General']['rename_files'] = int(RENAME_FILES) new_config['General']['folder_format'] = FOLDER_FORMAT diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py index 212f7055..979defb1 100644 --- a/headphones/postprocessor.py +++ b/headphones/postprocessor.py @@ -62,31 +62,41 @@ def verify(albumid, albumpath, Kind=None, forced=False): tracks = myDB.select('SELECT * from tracks WHERE AlbumID=?', [albumid]) if not release or not tracks: - #the result of a manual post-process on an album that hasn't been inserted - #from an RSS feed or etc - #TODO: This should be a call to a class method.. copied it out of importer with only minor changes - #TODO: odd things can happen when there are diacritic characters in the folder name, need to translate them? release_list = None + # Fetch album information from MusicBrainz try: release_list = mb.getReleaseGroup(albumid) except Exception, e: - logger.error('Unable to get release information for manual album with rgid: %s. Error: %s' % (albumid, e)) + logger.error('Unable to get release information for manual album with rgid: %s. Error: %s', albumid, e) return if not release_list: - logger.error('Unable to get release information for manual album with rgid: %s' % albumid) + logger.error('Unable to get release information for manual album with rgid: %s', albumid) return - # Since we're just using this to create the bare minimum information to insert an artist/album combo, use the first release + # Since we're just using this to create the bare minimum information to + # insert an artist/album combo, use the first release releaseid = release_list[0]['id'] - release_dict = mb.getRelease(releaseid) if not release_dict: - logger.error('Unable to get release information for manual album with rgid: %s. Cannot continue' % albumid) + logger.error('Unable to get release information for manual album with rgid: %s. Cannot continue', albumid) return + # Check if the artist is added to the database. In case the database is + # frozen during post processing, new artists will not be processed. This + # prevents new artists from appearing suddenly. In case forced is True, + # this check is skipped, since it is assumed the user wants this. + if headphones.FREEZE_DB and not forced: + artist = myDB.select("SELECT ArtistName, ArtistID FROM artists WHERE ArtistId=? OR ArtistName=?", [release_dict['artist_id'], release_dict['artist_name']]) + + if not artist: + logger.warn("Continuing would add new artist '%s', but " \ + "database is frozen. Will skip album with rgid: %s", + release_dict['artist_name'], albumid) + return + logger.info(u"Now adding/updating artist: " + release_dict['artist_name']) if release_dict['artist_name'].startswith('The '): @@ -94,7 +104,6 @@ def verify(albumid, albumpath, Kind=None, forced=False): else: sortname = release_dict['artist_name'] - controlValueDict = {"ArtistID": release_dict['artist_id']} newValueDict = {"ArtistName": release_dict['artist_name'], "ArtistSortName": sortname, diff --git a/headphones/webserve.py b/headphones/webserve.py index 3d3ab296..a76dd223 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -1044,6 +1044,7 @@ class WebInterface(object): "detect_bitrate" : checked(headphones.DETECT_BITRATE), "lossless_bitrate_from" : headphones.LOSSLESS_BITRATE_FROM, "lossless_bitrate_to" : headphones.LOSSLESS_BITRATE_TO, + "freeze_db" : checked(headphones.FREEZE_DB), "move_files" : checked(headphones.MOVE_FILES), "rename_files" : checked(headphones.RENAME_FILES), "correct_metadata" : checked(headphones.CORRECT_METADATA), @@ -1180,7 +1181,7 @@ class WebInterface(object): sab_category=None, nzbget_host=None, nzbget_username=None, nzbget_password=None, nzbget_category=None, nzbget_priority=0, transmission_host=None, transmission_username=None, transmission_password=None, utorrent_host=None, utorrent_username=None, utorrent_password=None, utorrent_label=None,nzb_downloader=0, torrent_downloader=0, download_dir=None, blackhole_dir=None, usenet_retention=None, use_headphones_indexer=0, newznab=0, newznab_host=None, newznab_apikey=None, newznab_enabled=0, nzbsorg=0, nzbsorg_uid=None, nzbsorg_hash=None, omgwtfnzbs=0, omgwtfnzbs_uid=None, omgwtfnzbs_apikey=None, - 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, + preferred_words=None, required_words=None, ignored_words=None, preferred_quality=0, preferred_bitrate=None, detect_bitrate=0, freeze_db=0, move_files=0, torrentblackhole_dir=None, download_torrent_dir=None, numberofseeders=None, use_piratebay=0, piratebay_proxy_url=None, piratebay_ratio=None, use_kat=0, kat_proxy_url=None, kat_ratio=None, use_mininova=0, mininova_ratio=None, waffles=0, waffles_uid=None, waffles_passkey=None, waffles_ratio=None, whatcd=0, whatcd_username=None, whatcd_password=None, whatcd_ratio=None, rutracker=0, rutracker_user=None, rutracker_password=None, rutracker_ratio=None, rename_files=0, correct_metadata=0, cleanup_files=0, keep_nfo=0, add_album_art=0, album_art_format=None, embed_album_art=0, embed_lyrics=0, replace_existing_folders=False, 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, other=0, djmix=0, mixtape_street=0, broadcast=0, interview=0, demo=0, @@ -1276,6 +1277,7 @@ class WebInterface(object): headphones.DETECT_BITRATE = detect_bitrate headphones.LOSSLESS_BITRATE_FROM = lossless_bitrate_from headphones.LOSSLESS_BITRATE_TO = lossless_bitrate_to + headphones.FREEZE_DB = freeze_db headphones.MOVE_FILES = move_files headphones.CORRECT_METADATA = correct_metadata headphones.RENAME_FILES = rename_files