mirror of
https://github.com/beetbox/beets.git
synced 2025-12-27 02:52:33 +01:00
Add musicbrainz id option to importer
* Add '-m', '--musicbrainzid' option to the import command, allowing the user to specify a single MusicBrainz ID to be used for the candidate lookup instead of trying to find suitable candidates. * Modify lookup_candidates() of ImportTask and SingletonImportTask to use the musicbrainz id if present.
This commit is contained in:
parent
d4e11f0af9
commit
1c95b7c46f
2 changed files with 17 additions and 2 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue