diff --git a/beetsplug/itunes.py b/beetsplug/itunes.py index 22efe47..9f7c08d 100644 --- a/beetsplug/itunes.py +++ b/beetsplug/itunes.py @@ -13,6 +13,8 @@ from beets.autotag.hooks import AlbumInfo, TrackInfo, Distance from beets.autotag.match import tag_album from beets.plugins import BeetsPlugin, sanitize_choices from beets.dbcore import types +from beets.importer import action +from beets.ui import print_, colorize from beets.ui.commands import PromptChoice AVAILABLE_COUNTRIES = ['DE', 'US', 'GB', 'FR', 'AU', 'CA', 'IT', 'JP', 'DZ', 'AO', 'AI', 'AG', 'AR', 'AM', 'AT', 'AZ', 'BS', 'BH', 'BD', 'BB', 'BY', 'BE', 'BZ', 'BM', 'BO', 'BW', 'BR', 'BN', 'BG', 'CM', 'KY', 'CL', 'CN', 'CO', 'CR', 'CI', 'HR', 'CY', 'CZ', 'DK', 'DM', 'DO', 'EC', 'EG', 'SV', 'EE', 'ET', 'FI', 'GH', 'GR', 'GD', 'GT', 'GY', 'HN', 'HK', 'HU', 'IS', 'IN', 'ID', 'IE', 'IL', 'JM', 'JO', 'KZ', 'KE', 'KR', 'KW', 'LV', 'LB', 'LY', 'LI', 'LT', 'LU', 'MO', 'MK', 'MG', 'MY', 'MV', 'ML', 'MT', 'MU', 'MX', 'MD', 'MS', 'MM', 'NP', 'NL', 'NZ', 'NI', 'NE', 'NG', 'NO', 'OM', 'PK', 'PA', 'PY', 'PE', 'PH', 'PL', 'PT', 'QA', 'RO', 'RU', 'KN', 'LC', 'VC', 'SA', 'SN', 'RS', 'SG', 'SK', 'SI', 'ZA', 'ES', 'LK', 'SR', 'SE', 'CH', 'TW', 'TZ', 'TH', 'TT', 'TN', 'TR', 'TC', 'UG', 'UA', 'AE', 'UY', 'UZ', 'VE', 'VN', 'VG', 'YE'] @@ -79,8 +81,7 @@ class iTunesPlugin(BeetsPlugin): self.force_search = False if self.method in ['lookup', 'lookup (search fallback)', 'both']: self.register_listener('import_task_start', self.scan_track_ids) - if self.method in ['lookup', 'lookup (search fallback)']: - self.register_listener('before_choose_candidate', self.add_prompt_choices) + self.register_listener('before_choose_candidate', self.add_prompt_choices) self.register_listener('import_task_apply', self.apply_itunes_metadata) if self.use_itunes_artwork: self.import_stages += [ self.fetch_artwork ] @@ -338,13 +339,28 @@ class iTunesPlugin(BeetsPlugin): return info def add_prompt_choices(self, session, task): - return [PromptChoice('c', 'searCh iTunes', self.prompt_search)] + choices = [] + + if self.method in ['lookup', 'lookup (search fallback)']: + choices += [PromptChoice('c', 'searCh iTunes', self.prompt_search)] + + no_itunes_matches = 0 + for match in task.candidates: + if match.info.data_source == 'iTunes': + no_itunes_matches += 1 + if no_itunes_matches == 1 and task.candidates[0].info.data_source == 'iTunes': + print_(colorize('text_highlight', 'This is the only iTunes Match')) + + return choices def prompt_search(self, session, task): self.force_search = True _, _, proposal = tag_album(task.items) return proposal - + + def noop(self, session, task): + pass + def decode_explicitness(advisory_string): return ['notExplicit', 'explicit', 'cleaned'].index(advisory_string)