mirror of
https://github.com/beetbox/beets.git
synced 2026-01-02 14:03:12 +01:00
catch a few tagging failure modes
This commit is contained in:
parent
0377a0c1e5
commit
cdeaeb9760
2 changed files with 11 additions and 4 deletions
|
|
@ -31,6 +31,8 @@ from beets import library, mediafile
|
|||
LENGTH_TOLERANCE = 30
|
||||
|
||||
class AutotagError(Exception): pass
|
||||
class InsufficientMetadataError(AutotagError): pass
|
||||
class UnknownAlbumError(AutotagError): pass
|
||||
class UnorderedTracksError(AutotagError): pass
|
||||
|
||||
def albums_in_dir(path, lib=None):
|
||||
|
|
@ -244,13 +246,18 @@ def tag_album(items):
|
|||
- The current metadata: an (artist, album) tuple.
|
||||
- The inferred metadata dictionary.
|
||||
- The distance between the current and new metadata.
|
||||
May raise an UnorderedTracksError if existing metadata is
|
||||
insufficient.
|
||||
May raise an AutotagError if existing metadata is insufficient.
|
||||
"""
|
||||
# Get current and candidate metadata.
|
||||
cur_artist, cur_album = current_metadata(items)
|
||||
if not cur_artist or not cur_album:
|
||||
raise InsufficientMetadataError()
|
||||
info = mb.match_album(cur_artist, cur_album, len(items))
|
||||
|
||||
# Make sure the album has the correct number of tracks.
|
||||
if len(items) != len(info['tracks']):
|
||||
raise UnknownAlbumError()
|
||||
|
||||
# Put items in order.
|
||||
#fixme need to try ordering tracks for every candidate album
|
||||
items = order_items(items, info['tracks'])
|
||||
|
|
|
|||
4
bts
4
bts
|
|
@ -59,8 +59,8 @@ def tag_album(items, lib):
|
|||
# Infer tags.
|
||||
try:
|
||||
items, (cur_artist, cur_album), info, dist = autotag.tag_album(items)
|
||||
except autotag.UnorderedTracksError:
|
||||
print "Tracks could not be ordered."
|
||||
except autotag.AutotagError:
|
||||
print "Untaggable album:", os.path.dirname(items[0].path)
|
||||
return
|
||||
|
||||
# Show what we're about to do.
|
||||
|
|
|
|||
Loading…
Reference in a new issue