mirror of
https://github.com/beetbox/beets.git
synced 2025-12-31 21:12:43 +01:00
show track lengths in difference display (#121)
This commit is contained in:
parent
531ebd19bb
commit
982f5849e2
3 changed files with 36 additions and 9 deletions
|
|
@ -297,7 +297,7 @@ def human_bytes(size):
|
|||
|
||||
def human_seconds(interval):
|
||||
"""Formats interval, a number of seconds, as a human-readable time
|
||||
interval.
|
||||
interval using English words.
|
||||
"""
|
||||
units = [
|
||||
(1, 'second'),
|
||||
|
|
@ -321,6 +321,13 @@ def human_seconds(interval):
|
|||
|
||||
return "%3.1f %ss" % (interval, suffix)
|
||||
|
||||
def human_seconds_short(interval):
|
||||
"""Formats a number of seconds as a short human-readable M:SS
|
||||
string.
|
||||
"""
|
||||
interval = int(interval)
|
||||
return u'%i:%02i' % (interval // 60, interval % 60)
|
||||
|
||||
# ANSI terminal colorization code heavily inspired by pygments:
|
||||
# http://dev.pocoo.org/hg/pygments-main/file/b2deea5b5030/pygments/console.py
|
||||
# (pygments is by Tim Hatch, Armin Ronacher, et al.)
|
||||
|
|
|
|||
|
|
@ -185,10 +185,18 @@ def show_change(cur_artist, cur_album, items, info, dist, color=True):
|
|||
if not item:
|
||||
missing_tracks.append((i, track_info))
|
||||
continue
|
||||
|
||||
# Get displayable LHS and RHS values.
|
||||
cur_track = unicode(item.track)
|
||||
new_track = unicode(i+1)
|
||||
cur_title = item.title
|
||||
new_title = track_info.title
|
||||
if item.length and track_info.length:
|
||||
cur_length = ui.human_seconds_short(item.length)
|
||||
new_length = ui.human_seconds_short(track_info.length)
|
||||
if color:
|
||||
cur_length = ui.colorize('red', cur_length)
|
||||
new_length = ui.colorize('red', new_length)
|
||||
|
||||
# Possibly colorize changes.
|
||||
if color:
|
||||
|
|
@ -201,14 +209,24 @@ def show_change(cur_artist, cur_album, items, info, dist, color=True):
|
|||
if not item.title.strip():
|
||||
cur_title = displayable_path(os.path.basename(item.path))
|
||||
|
||||
if cur_title != new_title and cur_track != new_track:
|
||||
print_(u" * %s (%s) -> %s (%s)" % (
|
||||
cur_title, cur_track, new_title, new_track
|
||||
))
|
||||
elif cur_title != new_title:
|
||||
print_(u" * %s -> %s" % (cur_title, new_title))
|
||||
elif cur_track != new_track:
|
||||
print_(u" * %s (%s -> %s)" % (item.title, cur_track, new_track))
|
||||
if cur_title != new_title:
|
||||
lhs, rhs = cur_title, new_title
|
||||
if cur_track != new_track:
|
||||
lhs += u' (%s)' % cur_track
|
||||
rhs += u' (%s)' % new_track
|
||||
print_(u" * %s -> %s" % (lhs, rhs))
|
||||
else:
|
||||
line = u' * %s' % item.title
|
||||
display = False
|
||||
if cur_track != new_track:
|
||||
display = True
|
||||
line += u' (%s -> %s)' % (cur_track, new_track)
|
||||
if item.length and track_info.length and \
|
||||
abs(item.length - track_info.length) > 2.0:
|
||||
display = True
|
||||
line += u' (%s -> %s)' % (cur_length, new_length)
|
||||
if display:
|
||||
print_(line)
|
||||
for i, track_info in missing_tracks:
|
||||
line = u' * Missing track: %s (%d)' % (track_info.title, i+1)
|
||||
if color:
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ Changelog
|
|||
albums.
|
||||
* The autotagger now also tolerates tracks whose track artists tags are set
|
||||
to "Various Artists".
|
||||
* When previewing metadata differences, the importer now shows discrepancies in
|
||||
track length.
|
||||
* Importing with ``import_delete`` enabled now cleans up empty directories that
|
||||
contained deleting imported music files.
|
||||
* Similarly, ``import_delete`` now causes original album art imported from the
|
||||
|
|
|
|||
Loading…
Reference in a new issue