mirror of
https://github.com/beetbox/beets.git
synced 2025-12-19 15:13:44 +01:00
Delegate album_for_id to plugins if no MusicBrainz match is found
This commit is contained in:
parent
87dedaafad
commit
a82e3f9f52
3 changed files with 25 additions and 14 deletions
|
|
@ -167,11 +167,15 @@ TrackMatch = namedtuple('TrackMatch', ['distance', 'info'])
|
|||
# Aggregation of sources.
|
||||
|
||||
def _album_for_id(album_id):
|
||||
"""Get an album corresponding to a MusicBrainz release ID."""
|
||||
"""Get an album corresponding to a release ID."""
|
||||
out = None
|
||||
try:
|
||||
return mb.album_for_id(album_id)
|
||||
out = mb.album_for_id(album_id)
|
||||
except mb.MusicBrainzAPIError as exc:
|
||||
exc.log(log)
|
||||
if not out:
|
||||
out = plugins.album_for_id(album_id)
|
||||
return out
|
||||
|
||||
def _track_for_id(track_id):
|
||||
"""Get an item for a recording MBID."""
|
||||
|
|
|
|||
|
|
@ -99,6 +99,12 @@ class BeetsPlugin(object):
|
|||
"""
|
||||
return {}
|
||||
|
||||
def album_for_id(self, album_id):
|
||||
"""Should return an AlbumInfo object or None if no matching release
|
||||
was found.
|
||||
"""
|
||||
return None
|
||||
|
||||
|
||||
listeners = None
|
||||
|
||||
|
|
@ -263,6 +269,16 @@ def item_candidates(item, artist, title):
|
|||
out.extend(plugin.item_candidates(item, artist, title))
|
||||
return out
|
||||
|
||||
def album_for_id(album_id):
|
||||
out = None
|
||||
for plugin in find_plugins():
|
||||
try:
|
||||
out = plugin.album_for_id(album_id)
|
||||
except Exception as exc:
|
||||
exc.log(log)
|
||||
if out:
|
||||
return out
|
||||
|
||||
def configure(config):
|
||||
"""Sends the configuration object to each plugin."""
|
||||
for plugin in find_plugins():
|
||||
|
|
|
|||
|
|
@ -579,20 +579,11 @@ def manual_search(singleton):
|
|||
return artist.strip(), name.strip()
|
||||
|
||||
def manual_id(singleton):
|
||||
"""Input a MusicBrainz ID, either for an album ("release") or a
|
||||
track ("recording"). If no valid ID is entered, returns None.
|
||||
"""Input an ID, either for an album ("release") or a track ("recording").
|
||||
"""
|
||||
prompt = 'Enter MusicBrainz %s ID:' % \
|
||||
prompt = 'Enter %s ID:' % \
|
||||
('recording' if singleton else 'release')
|
||||
entry = input_(prompt).strip()
|
||||
|
||||
# Find the first thing that looks like a UUID/MBID.
|
||||
match = re.search('[a-f0-9]{8}(-[a-f0-9]{4}){3}-[a-f0-9]{12}', entry)
|
||||
if match:
|
||||
return match.group()
|
||||
else:
|
||||
log.error('Invalid MBID.')
|
||||
return None
|
||||
return input_(prompt).strip()
|
||||
|
||||
class TerminalImportSession(importer.ImportSession):
|
||||
"""An import session that runs in a terminal.
|
||||
|
|
|
|||
Loading…
Reference in a new issue