File: inline.rst

package info (click to toggle)
beets 1.0~b14-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,876 kB
  • sloc: python: 12,200; makefile: 136
file content (32 lines) | stat: -rw-r--r-- 1,354 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Inline Plugin
=============

The ``inline`` plugin lets you use Python expressions to customize your path
formats. Using it, you can define template fields in your beets configuration
file and refer to them from your template strings in the ``[paths]`` section
(see :doc:`/reference/config/`).

To use inline field definitions, first enable the plugin by putting ``inline``
on your ``plugins`` line, like so::

    [beets]
    plugins: inline

Then, make a ``[pathfields]`` section in your config file. In this section,
every line defines a new template field; the key is the name of the field
(you'll use the name to refer to the field in your templates) and the value is a
Python expression. The expression has all of a track's fields in scope, so you
can refer to any normal attributes (such as ``artist`` or ``title``) as Python
variables. Here are a couple of examples::

    [pathfields]
    artist_initial: artist[0].upper() + u'.'
    disc_and_track: u'%02i.%02i' % (disc, track) if
                    disctotal > 1 else u'%02i' % (track)

(Note that the config file's syntax allows newlines in values if the subsequent
lines are indented.) These examples define ``$artist_initial`` and
``$disc_and_track`` fields that can be referenced in path templates like so::

    [paths]
    default: $artist_initial/$artist/$album/$disc_and_track $title