From 5904959b8a5e9e9649d237b960ea1e7b7e46763d Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sun, 2 Jun 2013 16:49:10 -0700 Subject: [PATCH] item templates now expand all fields A user noticed that $id wasn't being expanded. There's no good reason for that. --- beets/library.py | 8 +++++--- docs/changelog.rst | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/beets/library.py b/beets/library.py index d1b0b6d09..f8aaaaad2 100644 --- a/beets/library.py +++ b/beets/library.py @@ -399,7 +399,7 @@ class Item(object): # Build the mapping for substitution in the template, # beginning with the values from the database. mapping = {} - for key in ITEM_KEYS_META: + for key in ITEM_KEYS: # Get the values from either the item or its album. if key in ALBUM_KEYS_ITEM and album is not None: # From album. @@ -411,8 +411,10 @@ class Item(object): value = format_for_path(value, key, pathmod) mapping[key] = value - # Additional fields in non-sanitized case. - if not sanitize: + # Include the path if we're not sanitizing to construct a path. + if sanitize: + del mapping['path'] + else: mapping['path'] = displayable_path(self.path) # Use the album artist if the track artist is not set and diff --git a/docs/changelog.rst b/docs/changelog.rst index 0f8b08b51..9d6984912 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -51,6 +51,8 @@ Changelog ``beet modify artpath=...`` works). Thanks to Lucas Duailibe. * :doc:`/plugins/zero`: Fix a crash when nulling out a field that contains None. +* Templates can now refer to non-tag item fields (e.g., ``$id`` and + ``$album_id``). * Various UI enhancements to the importer due to Tai Lee: * More consistent format and colorization of album and track metadata.