From 43e9044843645d9d91a082c327ce66c38700ff20 Mon Sep 17 00:00:00 2001 From: Tom Jaspers Date: Sat, 31 Jan 2015 22:11:43 +0100 Subject: [PATCH] Duplicate album-import summary shows old/new filesize E.g.: Old: 13 items, MP3, 256kbps, 44:32, 101MB New: 13 items, MP3, 320kbps, 44:31, 128MB Fix #1291 --- beets/library.py | 5 +++++ beets/ui/commands.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/beets/library.py b/beets/library.py index d521fc4a8..9b4d8ad27 100644 --- a/beets/library.py +++ b/beets/library.py @@ -595,6 +595,11 @@ class Item(LibModel): """ return int(os.path.getmtime(syspath(self.path))) + def filesize(self): + """Returns the size, in bytes, of the file. + """ + return os.path.getsize(syspath(self.path)) + # Model methods. def remove(self, delete=False, with_album=True): diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 219f9cd73..b8f492a9e 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -439,8 +439,10 @@ def summarize_items(items, singleton): 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)