Commit Graph

16 Commits

Author SHA1 Message Date
Christopher Larson
5bc11ea736 inline: make the album/item available directly
There have been multiple requests, in the past, for the ability to use
plugin fields in inline fields. This has not previously been available.
From what I can tell, it was intentionally left unavailable due to
performance concerns.

The way the item fields are made available to the inline python code
means that all fields are looked up, whether they're actually used by
the code or not. Doing that for all computed fields would be a
performance concern.

I don't believe there's a good way to postpone the field computation, as
python eval and compile requires that globals be a dictionary, not a
mapping. Instead, we can make available the album or item model object
to the code directly, and let the code access the fields it needs via
that object, resulting in postponing the computation of the fields until
they're actually accessed.

This is a simple approach that makes the computed and plugin fields
available to inline python, which allows for more code reuse, as well as
more options for shifting logic out of templates and into python code.
The object is available as `db_obj`.

Examples:

    item_fields:
      test_file_size: db_obj.filesize

    album_fields:
      test_album_path: db_obj.path
      # If the missing plugin is enabled
      test_album_missing: db_obj.missing

Signed-off-by: Christopher Larson <kergoth@gmail.com>
2026-04-15 11:59:19 -07:00
Šarūnas Nejus
9352a79e41 Replace percent formatting 2025-08-30 22:35:00 +01:00
Šarūnas Nejus
ab5acaabb3 Reformat all docs using docstrfmt 2025-08-10 16:25:05 +01:00
Šarūnas Nejus
769dcdc88a Docs: fix linting issues 2025-08-10 16:16:02 +01:00
Diego Moreda
47ceb492dc Add docs note for custom-field sorting, fix typo
* Add note about ordering when sorting by custom-fields on query.rst.
* Fix typo on inline.rst.
2015-11-25 19:15:01 +01:00
Fabrice Laporte
2cd76b6714 docs: add plugin name in "how to configure" sentences 2014-10-28 23:23:10 +01:00
Fabrice Laporte
cb350de2ea harmonize all plugins docs
Add a configuration section that lists all options for each plugin.
List options in alphabetic order.
Mention the default value for each option.
Use same sentences to describe concepts common to different plugins eg 'auto
option, install description
2014-10-26 22:29:10 +01:00
Wieland Hoffmann
e4af04e3be docs/inline.rst: The `[paths] section is now paths:` 2013-08-06 10:41:05 +02:00
Adrian Sampson
3b438b7778 inline: rename "pathfields" to "item_fields" 2013-05-28 23:20:19 -07:00
Adrian Sampson
0176e10ccf inline: allow album field definitions
Under the album_field heading.
2013-05-28 23:10:47 -07:00
Fabrice Laporte
e8be4d5ba9 Update inline plugin doc by providing an example about how to define a field depending on 'path' attribute. 2013-03-27 23:19:15 +01:00
Adrian Sampson
f7bef39769 GH-72: use function bodies instead of special var 2013-01-05 17:48:00 -08:00
Adrian Sampson
11e1fd1bd8 document new Confit-based configuration 2012-12-20 21:56:47 -08:00
Adrian Sampson
0cab7bd8de inline: fix example in docs (use albumartist)
Previously, the example used the track artist ($artist) for the initial
directory component.
2012-08-07 09:59:00 -07:00
Adrian Sampson
2a38fcce6a typo in inline plugin docs 2012-04-20 09:58:02 -07:00
Adrian Sampson
890021008a inline plugin: define template fields in config (#169) 2011-12-27 14:43:58 -08:00