Using template functions with the inline plugin

I was wondering if it is possible to use template functions with the inline plugin. I want to use %the{} to get the proper first initial of an artist. Something like:

item_fields:
    initial: (albumartist_sort or artist_sort or albumartist or artist or '_')[0].upper()

But I would like to use the %the{} template function on the various artist fields first.

Hello! There is no easy/convenient way, but the fact is that it’s possible to do anything in inline snippets because they can run arbitrary Python code. Using the multi-line syntax, you can do something like this:

import beets.plugins
the_func = beets.plugins.template_funcs()['the']
return the('some string')
2 Likes

Changed my code to

initial: |
    import beets.plugins
    the_func = beets.plugins.template_funcs()['the']
    the_artist = the_func(albumartist_sort or artist_sort or albumartist or artist or '_')
    return the_artist[0].upper()

And this works like a charm. Thanks!

1 Like