From 8d2fda790bf72df06b05aa2a3125a1f0fcd33437 Mon Sep 17 00:00:00 2001 From: Diego Moreda Date: Sat, 5 Dec 2015 13:28:56 +0100 Subject: [PATCH] Add config option for human vs raw track duration * Add "format_raw_length" global configuration option to allow the user to toggle between human-readable (default) or raw formatting of track durations. --- beets/config_default.yaml | 1 + beets/library.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/beets/config_default.yaml b/beets/config_default.yaml index ba58debe7..545fa9638 100644 --- a/beets/config_default.yaml +++ b/beets/config_default.yaml @@ -65,6 +65,7 @@ ui: format_item: $artist - $album - $title format_album: $albumartist - $album time_format: '%Y-%m-%d %H:%M:%S' +format_raw_length: no sort_album: albumartist+ album+ sort_item: artist+ album+ disc+ track+ diff --git a/beets/library.py b/beets/library.py index 13b0b92fa..77c4bf8ab 100644 --- a/beets/library.py +++ b/beets/library.py @@ -200,7 +200,11 @@ class DurationType(types.Float): query = dbcore.query.DurationQuery def format(self, value): - return beets.ui.human_seconds_short(value or 0.0) + # TODO: decide if documenting format_raw_length + if not beets.config['format_raw_length'].get(bool): + return beets.ui.human_seconds_short(value or 0.0) + else: + return value def parse(self, string): try: