From 3d0c0b1873f965b816dab5123429ad55b932e319 Mon Sep 17 00:00:00 2001 From: Kim Wittenburg <5wittenb@informatik.uni-hamburg.de> Date: Thu, 6 Sep 2018 15:41:56 +0200 Subject: [PATCH] Use censored Names --- beetsplug/itunes.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/beetsplug/itunes.py b/beetsplug/itunes.py index 850f958..78623c1 100644 --- a/beetsplug/itunes.py +++ b/beetsplug/itunes.py @@ -77,6 +77,7 @@ class iTunesPlugin(BeetsPlugin): 'sanitize_searches': True, # Whether to remove parenthesized and braced text from searches 'artwork': False, # Whether to also download artwork from iTunes. Does not work well with fetchart 'method': 'lookup', # Valid values: 'search', 'lookup', 'both', 'lookup (search fallback)' + 'censored_names': False, }) if self.method in ['lookup', 'lookup (search fallback)', 'both']: self.register_listener('import_task_start', self.scan_track_ids) @@ -111,6 +112,10 @@ class iTunesPlugin(BeetsPlugin): @property def sanitize_searches(self): return self.config['sanitize_searches'] + + @property + def use_censored_names(self): + return self.config['censored_names'] def scan_track_ids(self, session, task): self._log.debug("Scanning track IDs") @@ -268,7 +273,8 @@ class iTunesPlugin(BeetsPlugin): year = int(album.release_date[0:4]) month = int(album.release_date[5:7]) day = int(album.release_date[8:10]) - info = AlbumInfo(album.collection_name, + collection_name = album.collection_censored_name if self.use_censored_names and hasattr(album, 'collection_censored_name') else album.collection_name + info = AlbumInfo(collection_name, album.collection_id, album.artist_name, album.artist_id, @@ -296,7 +302,7 @@ class iTunesPlugin(BeetsPlugin): original_day = day, # See original_year data_source = "iTunes", data_url = album.collection_view_url) - info.album_sort = sort_string(album.collection_name) + info.album_sort = sort_string(collection_name) info.itunes_content_id = album.collection_id info.itunes_artist_id = album.artist_id info.genre = album.primary_genre_name @@ -306,7 +312,9 @@ class iTunesPlugin(BeetsPlugin): return info def make_track_info(self, track, index): - info = TrackInfo(track.track_name, + track_name = track.track_censored_name if self.use_censored_names and hasattr(track, 'track_censored_name') else track.track_name + collection_name = track.collection_censored_name if self.use_censored_names and hasattr(track, 'collection_censored_name') else track.collection_name + info = TrackInfo(track_name, track.track_id, artist = track.artist_name, artist_id = track.artist_id, @@ -326,8 +334,8 @@ class iTunesPlugin(BeetsPlugin): composer_sort = None, arranger = None, track_alt = None) - info.title_sort = sort_string(track.track_name) - info.album_sort = sort_string(track.collection_name) + info.title_sort = sort_string(track_name) + info.album_sort = sort_string(collection_name) info.itunes_content_id = track.track_id info.itunes_artist_id = track.artist_id info.genre = track.primary_genre_name