1. Adrian Sampson
  2. beets


Adrian Sampson  committed 2c5efe6 Merge

Merge pull request #274 from pedros/album_template_fields

Perform template field substitution on albums

  • Participants
  • Parent commits 7b452fd, 65fb782
  • Branches default

Comments (0)

Files changed (2)

File beets/library.py

View file
         mapping['artpath'] = displayable_path(mapping['artpath'])
         mapping['path'] = displayable_path(self.item_dir())
+        # Get values from plugins.
+        for key, value in plugins.template_values(self).iteritems():
+            mapping[key] = value
         # Get template functions.
         funcs = DefaultTemplateFunctions().functions()

File docs/plugins/writing.rst

View file
 With this plugin enabled, templates can reference ``$disc_and_track`` as they
 can any standard metadata field.
+Note that the above idiom expects the argument ``item`` to be an
+actual *track* item. If you'd like to provide a template field for
+*albums*, you'll need to check the argument::
+    @MyPlugin.template_field('field')
+    def _tmpl_field(album):
+        """Return stuff.
+        """
+        if isinstance(album, beets.library.Album):
+            return 'stuff'
 Extend MediaFile