mirror of
https://github.com/beetbox/beets.git
synced 2025-12-15 04:55:10 +01:00
Final reshuffle to put summarize_items in beets.ui
Also improved duration display.
This commit is contained in:
parent
3ec7426a35
commit
4aa783f09d
3 changed files with 28 additions and 30 deletions
|
|
@ -989,3 +989,29 @@ def main(args=None):
|
|||
except KeyboardInterrupt:
|
||||
# Silently ignore ^C except in verbose mode.
|
||||
log.debug(traceback.format_exc())
|
||||
|
||||
|
||||
|
||||
def summarize_items(items):
|
||||
"""Produces a brief summary line for manually resolving duplicates during import.
|
||||
Accepts a list of tuples, one per item containing:
|
||||
(path, format, bitrate, duration)
|
||||
"""
|
||||
|
||||
summary_text = ""
|
||||
summary_text += "%d items. " % len(items)
|
||||
format_counts = {}
|
||||
for item in items:
|
||||
format_counts[item[1]] = format_counts.get(item[1],0) + 1;
|
||||
|
||||
for format, count in format_counts.iteritems():
|
||||
summary_text += '{count} {format}. '.format(format=format, count=count)
|
||||
|
||||
average_bitrate = sum([item[2] for item in items]) / len(items)
|
||||
total_duration = sum([item[3] for item in items])
|
||||
summary_text += '{bitrate}kbps average bitrate. '.format(bitrate=int(average_bitrate/1000))
|
||||
summary_text += '{length} total length. '.format(length=human_seconds_short(total_duration))
|
||||
|
||||
return summary_text
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -756,9 +756,9 @@ class TerminalImportSession(importer.ImportSession):
|
|||
# print some detail about the existing and new items so it can be an informed decision
|
||||
for duplicate in found_duplicates:
|
||||
old_items = [(item.path, item.format, item.bitrate, item.length) for item in duplicate.items()]
|
||||
print("OLD: " + util.summarize_items(old_items))
|
||||
print("OLD: " + ui.summarize_items(old_items))
|
||||
new_items = [(item.path, item.format, item.bitrate, item.length) for item in task.items]
|
||||
print("NEW: " + util.summarize_items(new_items))
|
||||
print("NEW: " + ui.summarize_items(new_items))
|
||||
|
||||
sel = ui.input_options(
|
||||
('Skip new', 'Keep both', 'Remove old')
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import traceback
|
|||
import subprocess
|
||||
import platform
|
||||
|
||||
|
||||
MAX_FILENAME_LENGTH = 200
|
||||
WINDOWS_MAGIC_PREFIX = u'\\\\?\\'
|
||||
|
||||
|
|
@ -658,30 +657,3 @@ def max_filename_length(path, limit=MAX_FILENAME_LENGTH):
|
|||
return min(res[9], limit)
|
||||
else:
|
||||
return limit
|
||||
|
||||
def summarize_items(items):
|
||||
"""Produces a brief summary line for manually resolving duplicates during import.
|
||||
Accepts a list of tuples, one per item containing:
|
||||
(path, format, bitrate, duration)
|
||||
"""
|
||||
|
||||
summary_text = ""
|
||||
summary_text += "%d items. " % len(items)
|
||||
format_counts = {}
|
||||
for item in items:
|
||||
format_counts[item[1]] = format_counts.get(item[1],0) + 1;
|
||||
|
||||
for format, count in format_counts.iteritems():
|
||||
summary_text += '{count} {format}. '.format(format=format, count=count)
|
||||
|
||||
average_bitrate = sum([item[2] for item in items]) / len(items)
|
||||
total_duration = sum([item[3] for item in items])
|
||||
summary_text += '{bitrate}K average bitrate. '.format(bitrate=int(average_bitrate/1000))
|
||||
summary_text += '{length}s total length. '.format(length=int(total_duration))
|
||||
|
||||
return summary_text
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue