diff --git a/beets/importer.py b/beets/importer.py index e0d69b968..413750ef3 100644 --- a/beets/importer.py +++ b/beets/importer.py @@ -581,8 +581,13 @@ class ImportTask(BaseImportTask): def lookup_candidates(self): """Retrieve and store candidates for this album. """ + # Use a MusicBrainz id directly if provided by the importer -m option. + mb_id = None + if config['import']['musicbrainz_id'].exists(): + mb_id = config['import']['musicbrainz_id'].get() + artist, album, candidates, recommendation = \ - autotag.tag_album(self.items) + autotag.tag_album(self.items, search_id=mb_id) self.cur_artist = artist self.cur_album = album self.candidates = candidates @@ -821,7 +826,13 @@ class SingletonImportTask(ImportTask): plugins.send('item_imported', lib=lib, item=item) def lookup_candidates(self): - candidates, recommendation = autotag.tag_item(self.item) + # Use a MusicBrainz id directly if provided by the importer -m option. + mb_id = None + if config['import']['musicbrainz_id'].exists(): + mb_id = config['import']['musicbrainz_id'].get() + + candidates, recommendation = autotag.tag_item(self.item, + search_id=mb_id) self.candidates = candidates self.rec = recommendation diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 773c10cae..6616cb1bc 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -1022,6 +1022,10 @@ import_cmd.parser.add_option( '--pretend', dest='pretend', action='store_true', help='just print the files to import' ) +import_cmd.parser.add_option( + '-m', '--musicbrainzid', dest='musicbrainz_id', + help='restrict the matching to a single MusicBrainz id' +) import_cmd.func = import_func default_commands.append(import_cmd)