# I need some help getting the full potential out of beets

**URL:** <https://discourse.beets.io/t/i-need-some-help-getting-the-full-potential-out-of-beets/58>\
**Category:** Help\
**Created:** [April 11, 2017, 12:10pm UTC](https://discourse.beets.io/t/i-need-some-help-getting-the-full-potential-out-of-beets/58 "2017-04-11T12:10:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Horrorente](https://avatars.discourse-cdn.com/v4/letter/h/fbc32d/32.png) [@Horrorente](https://discourse.beets.io/u/Horrorente)\
**Post date:** [April 11, 2017, 12:10pm UTC](https://discourse.beets.io/t/i-need-some-help-getting-the-full-potential-out-of-beets/58/1 "2017-04-11T12:10:21Z")

</div>

I’ve set up a working version of beets, but there are still some functions that I’m missing or I’m not comfortable with the way they work. It might be that beets is not able to cover those functions the way I want, but I also feel I haven’t really understood the full potential of beets yet. Those are the things I want to achive:

- I would like to use “genre categories” for organizing my music. This means being able to tag my music with distinct and even multiple genres, but then organizing them into a category (for example tag an album with the genres “Psychedelic Rock” and “Stoner Rock”, but then move that album into the “Rock” folder). Lastgenre only let’s me canonicalize my genres. The bucket plugin seemed interesting, but the way I understood it I can’t define my own buckets (for example put everything from [“Tech House”, “Deep House”, “Drum And Bass”, “Techno”] into the bucket “Electronic”). Is there a way around this?
- Is there a way to replace fields with another value? I feel like the [last.fm](http://last.fm) genres don’t necessarily follow the wikipedia list of genres, so using the lastgenre plugin will skip the genre “metal” as this is not a distinct genre (or I whitelist it, but then I have a “heavy metal” and a “metal” folder). Is there a way to generally replace the “metal” genre field with “Heavy Metal”?
- I have lots of albums in a lossless format, but I would like to keep a lossy version, too. Is there a way to automatically rename the lossless albums on importing? I tried using the if condition in my path settings like this: `default: $genre/%if{$format=="FLAC", $albumartist - $album (lossless), $albumartist - $album}/$track. $title`, however, beets is putting “(lossless)” behind every album now (even behind lossy formats). **EDIT: Apparently the if condition only checks for nonempty / nonzero values and doesn’t allow boolean operators. Found a solution by using the inline plugin instead.**
- Is there a way to conveniently convert music on import? I would like to convert everything that is not in the opus format to opus. At best, the convert plugin should convert all formats to opus, but keep all files that are in lossless format (and import them, too), while replacing all other formats (like mp3).

I feel like the inline plugin is quite powerful and might be able to cover my first points. I’m going to take a deeper look into that. Besides that, do you have any tips on how to implement my whishes?

And for the sake of completeness, here’s my full config file:

```
directoy: ~/Music
library: ~/.config/beets/library.db
plugins: discogs embedart fetchart lastgenre convert

import:
    move: yes
    copy: yes
    write: yes

paths:
    default: $genre/$albumartist - $album/$track. $title
    singleton: $genre/$artist - $title
    comp: $genre/$album/$track. $title

lastgenre:
    auto: yes
    canonical: yes
    whitelist: ~/.config/beets/whitelist.yaml
    canonical: ~/.config/beets/genres-tree.yaml
    force: yes
    
convert:
    auto: no
    command: ffmpeg -i $source -acodec libopus -b:a 128k -vbr on -compression_level 10 $dest
    extension: opus

```

Thanks!

---

<div class="post-metadata">

**Author:** ![adrian](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/adrian/32/4_2.png) [@adrian](https://discourse.beets.io/u/adrian)\
**Post date:** [April 11, 2017, 5:46pm UTC](https://discourse.beets.io/t/i-need-some-help-getting-the-full-potential-out-of-beets/58/2 "2017-04-11T17:46:05Z")

</div>

For categorizing genres, you might try an inline that looks like this:

```auto
gencat: |
    return {
      'Stoner Rock': 'Rock',
      'Psychedelic Rock': 'Rock',
    }.get(genre, genre)

```

That is, look up the names you want to shorten in a map you declare.

For straight-up replacements, you might try the `rewrite` plugin.

Finally, the `convert` plugin has an `auto` option that, I think, does exactly what you want. Give that a try!

---

<div class="post-metadata">

**Author:** ![MonGMZ](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/mongmz/32/54_2.png) [@MonGMZ](https://discourse.beets.io/u/MonGMZ)\
**Post date:** [August 1, 2017, 2:04pm UTC](https://discourse.beets.io/t/i-need-some-help-getting-the-full-potential-out-of-beets/58/3 "2017-08-01T14:04:46Z")

</div>

Hello,  
I am new to beets and I find it great but I have the same need as Horrorente. I’ve been takien a look at the documentation of the inline plugin and I feel a bit lost. It would be great if we could configure the lastgenre plugin to store the full genre in the usual tag %genre% and create/update a new %cartegory% tag with the canonical/whitelisted version of genre. If someone knows of a tutorial more in depth of the inline plugin to understand better how to use it I would deeply appreciate it.

Thanks for all the great work from the devs.

---

<div class="post-metadata">

**Author:** ![adrian](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/adrian/32/4_2.png) [@adrian](https://discourse.beets.io/u/adrian)\
**Post date:** [August 1, 2017, 2:41pm UTC](https://discourse.beets.io/t/i-need-some-help-getting-the-full-potential-out-of-beets/58/4 "2017-08-01T14:41:48Z")

</div>

Hi! Have you tried the configuration listing from my previous comment? Did that work?

---

<div class="post-metadata">

**Author:** ![kyrios](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/kyrios/32/242_2.png) [@kyrios](https://discourse.beets.io/u/kyrios)\
**Post date:** [May 22, 2019, 8:24am UTC](https://discourse.beets.io/t/i-need-some-help-getting-the-full-potential-out-of-beets/58/5 "2019-05-22T08:24:49Z")

</div>

> [@Horrorente](#):
>
> a way to replace fields with another value

Did you find a a way to replace fields with another value?  
Trying to do the same thing to replace some genres like the one you mention metal with heavy metal, rock with hard rock, pop with latin pop etc…

---

<div class="post-metadata">

**Author:** ![FlibrJibr](https://avatars.discourse-cdn.com/v4/letter/f/0ea827/32.png) [@FlibrJibr](https://discourse.beets.io/u/FlibrJibr)\
**Post date:** [August 16, 2019, 6:17pm UTC](https://discourse.beets.io/t/i-need-some-help-getting-the-full-potential-out-of-beets/58/6 "2019-08-16T18:17:06Z")

</div>

> [@Horrorente](#):
>
> I would like to use “genre categories” for organizing my music.

I’ve been looking at doing exactly this, and indeed had come up with the following using the _`inline`_ plugin:

```
top_genre: |
        if genre:
            genres = genre.split(';')
            return genres[-1]
        else:
            return '_none_'

```

…with the _`lastgenre`_ configuration:

```
lastgenre:
    auto: yes
    canonical: yes
    count: 3
    force: no
    min_weight: 25
    prefer_specific: yes
    source: album
    separator: '; '
    whitelist: yes

```

…where I was obtaining genres using specificity, and the inline function returns the last (i.e. _least_) specific genre to be the ‘top’ (level) or ‘parent’ genre.

The problem I ran in to (very quickly) is the sheer inconsistency with which music is ‘tagged’ with genres!

… (because it is open to all potential forms of people’s _‘personal interpretations’_, stupidity and/or outright sabotage.)

For example, I had a couple of tracks by _Pennywise_ which ended up tagged with the genres:  
– `Punk Rock; Punk; Electronic`  
… my only assumption here is that someone (or rather, a _lot_ of people, since _last.fm_ no doubt use some form of aggregation-algorithm or community voting) was thinking along the lines of:  
_“Well… they play \*electric\* guitars so the music must be considered to be ‘electronic’, right?!”_&nbsp; 🤦‍♂️

So, working now with the principal that (ultimately) only _you_ know how you want to categorise your music (a very _beets_ philosophy) I was planning to use a _[flex-attibute](https://beets.readthedocs.io/en/stable/guides/advanced.html#store-any-data-you-like)_ on items to store an organisational genre tag (_‘org\_genre’_, or whatever) which is then (thankfully) automatically available to the path-formats.

Populating this field may seem like a labour intensive task, but given that beets’ powerful search capabilities are available to the _`modify`_ command it becomes considerably easier to do _en masse_

e.g. `beet modify genre:rock org_genre="rock"`

– note that the query here returns all items whose genre field _contains_ the word ‘rock’, so `'alternatvie rock'`, `'industrial rock'`, `'progressive rock`’ … etc. etc.

Jut bear in mind that there’s always going to be a lot of ‘gotcha’ situations when tracks have multiple genres, such as `'alternative metal; alternative rock; nu-metal'` … so picking/filtering which to tag with which (in this case `'metal'` or `'rock'`) may still be an exercise of patience and persistence!

😉

---

<div class="post-metadata">

**Author:** ![Moonbase59](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.beets.io/moonbase59/32/299_2.png) [@Moonbase59](https://discourse.beets.io/u/Moonbase59)\
**Post date:** [September 23, 2019, 12:52pm UTC](https://discourse.beets.io/t/i-need-some-help-getting-the-full-potential-out-of-beets/58/7 "2019-09-23T12:52:10Z")

</div>

It might be worth considering using the “grouping” tag for this, which I’ve been doing for quite some years now. This is supported if you use MusicBrainz Picard and have [fdemmer’s last.fm.ng plugin](https://github.com/fdemmer/Picard-Last.fm.ng-Plugin) enabled.

It would place `Rock` in the _grouping_, and either `Rock; Progressive Rock` or just `Progressive Rock` in the _genre_, depending on configuration.

Maybe something like this logic could be introduced into beets’ last.fm plugin? I quite like fdemmer’s plugin, since it allows things like

- adding extra info from last.fm like grouping, genre, artist country, mood
- specifying personal whitelists
- specifying which genre tags should be translated into others
- specifying casing exceptions (“Aor"→"AOR”)
- getting decades (“1990s”)

I don’t know if using _grouping_ might have adverse effects with classical music, simply because I have none. But I can tell that using the _grouping_ helps me to have a “basic genre” (kinda bucket/category) and replicating the _one_ genre kept in _grouping_ as the _first_ genre in the multivalue _genre_ field even keeps it compatible with older software that has no _grouping_ field (like when searching for “genre contains …”).

And of course it’d be a great plus if beets would handle this the same way Picard + last.fm.ng does. 🙂

And I like beets’ “genre/subgenre tree” much better than anything else—in combination with said changes it would simply rock, since it could “consolidate” subgenres into their “official” more generic genre.
