mirror of
https://github.com/beetbox/beets.git
synced 2026-02-23 07:44:38 +01:00
summarize_items(): work even with 0 items
It crashed on empty albums. Fix #1357
This commit is contained in:
parent
cf3388fae7
commit
18fc0cd3de
1 changed files with 7 additions and 8 deletions
|
|
@ -426,8 +426,6 @@ def summarize_items(items, singleton):
|
|||
this is an album or single-item import (if the latter, them `items`
|
||||
should only have one element).
|
||||
"""
|
||||
assert items, "summarizing zero items"
|
||||
|
||||
summary_parts = []
|
||||
if not singleton:
|
||||
summary_parts.append("{0} items".format(len(items)))
|
||||
|
|
@ -443,12 +441,13 @@ def summarize_items(items, singleton):
|
|||
for fmt, count in format_counts.iteritems():
|
||||
summary_parts.append('{0} {1}'.format(fmt, count))
|
||||
|
||||
average_bitrate = sum([item.bitrate for item in items]) / len(items)
|
||||
total_duration = sum([item.length for item in items])
|
||||
total_filesize = sum([item.filesize for item in items])
|
||||
summary_parts.append('{0}kbps'.format(int(average_bitrate / 1000)))
|
||||
summary_parts.append(ui.human_seconds_short(total_duration))
|
||||
summary_parts.append(ui.human_bytes(total_filesize))
|
||||
if items:
|
||||
average_bitrate = sum([item.bitrate for item in items]) / len(items)
|
||||
total_duration = sum([item.length for item in items])
|
||||
total_filesize = sum([item.filesize for item in items])
|
||||
summary_parts.append('{0}kbps'.format(int(average_bitrate / 1000)))
|
||||
summary_parts.append(ui.human_seconds_short(total_duration))
|
||||
summary_parts.append(ui.human_bytes(total_filesize))
|
||||
|
||||
return ', '.join(summary_parts)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue