diff --git a/beets/autotag/__init__.py b/beets/autotag/__init__.py index e6588ee30..a9d5ab765 100644 --- a/beets/autotag/__init__.py +++ b/beets/autotag/__init__.py @@ -74,6 +74,8 @@ def apply_metadata(items, album_info): """ for index, (item, track_info) in enumerate(zip(items, album_info.tracks)): # Album, artist, track count. + if not item: + continue if track_info.artist: item.artist = track_info.artist else: diff --git a/beets/autotag/match.py b/beets/autotag/match.py index d6566c2dd..ce94e009a 100644 --- a/beets/autotag/match.py +++ b/beets/autotag/match.py @@ -365,7 +365,7 @@ def validate_candidate(items, tuple_dict, info): return # Make sure the album has the correct number of tracks. - if len(items) != len(info.tracks): + if len(items) > len(info.tracks): log.debug('Track count mismatch.') return diff --git a/beets/importer.py b/beets/importer.py index 2b24047bf..515e6a7be 100644 --- a/beets/importer.py +++ b/beets/importer.py @@ -107,7 +107,7 @@ def _duplicate_check(lib, task, recent=None): recent.add((artist, album)) # Look in the library. - cur_paths = set(i.path for i in task.items) + cur_paths = set(i.path for i in task.items if i) for album_cand in lib.albums(artist=artist): if album_cand.album == album: # Check whether the album is identical in contents, in which @@ -591,7 +591,7 @@ def apply_choices(config): if task.should_skip(): continue - items = task.items if task.is_album else [task.item] + items = [i for i in task.items if i] if task.is_album else [task.item] # Clear IDs in case the items are being re-tagged. for item in items: item.id = None @@ -644,7 +644,7 @@ def apply_choices(config): # Add new ones. if task.is_album: # Add an album. - album = lib.add_album(task.items) + album = lib.add_album([i for i in task.items if i]) task.album_id = album.id else: # Add tracks. diff --git a/beets/ui/commands.py b/beets/ui/commands.py index fdbd5a377..21ecd1017 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -154,7 +154,11 @@ def show_change(cur_artist, cur_album, items, info, dist, color=True): print_('(Similarity: %s)' % dist_string(dist, color)) # Tracks. + missing_tracks = [] for i, (item, track_info) in enumerate(zip(items, info.tracks)): + if not item: + missing_tracks.append((i, track_info)) + continue cur_track = unicode(item.track) new_track = unicode(i+1) cur_title = item.title @@ -179,6 +183,9 @@ def show_change(cur_artist, cur_album, items, info, dist, color=True): print_(u" * %s -> %s" % (cur_title, new_title)) elif cur_track != new_track: print_(u" * %s (%s -> %s)" % (item.title, cur_track, new_track)) + for i, track_info in missing_tracks: + print_(ui.colorize('red', u' * Missing track: %s (%d)' % \ + (track_info.title, i+1))) def show_item_change(item, info, dist, color): """Print out the change that would occur by tagging `item` with the