# Strange issue with albumdisambig

**URL:** <https://discourse.beets.io/t/strange-issue-with-albumdisambig/1824>\
**Category:** Help\
**Created:** [August 8, 2021, 7:00pm UTC](https://discourse.beets.io/t/strange-issue-with-albumdisambig/1824 "2021-08-08T19:00:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pandatroubles](https://avatars.discourse-cdn.com/v4/letter/p/35a633/32.png) [@pandatroubles](https://discourse.beets.io/u/pandatroubles)\
**Post date:** [August 8, 2021, 7:00pm UTC](https://discourse.beets.io/t/strange-issue-with-albumdisambig/1824/1 "2021-08-08T19:00:38Z")

</div>

Hi! Me again. 😉

After #3852 was fixed, I am having a strange result with `albumdisambig`.

> <https://github.com/beetbox/beets/issues/3852>
>
> \### Problem
> If I try \`beet ls -a -f '$albumartist - (%if{$original\_year,$origin…al\_year,$year}) - $album%ifdef{albumdisambig, (%title{$albumdisambig}),}%ifdef{albumrating, ($albumrating),}' year:2021\` then beets will return the album rating for the albums that has the field defined. For albums without the rating, \`$albumrating\` is returned.
> 
> Example:
> \`\`\`
> Artist1 - (2021) - Albumname1 (2.0)
> Artist2 - (2021) - Albumname2 ($albumrating)
> \`\`\`
> 
> Further information on the forum:
> https://discourse.beets.io/t/album-rating-as-a-flexible-attribute-in-5-increments/1687/3
> 
> Comment from adrian:
> \_reading over the implementation of %ifdef, I can see now how it would be confused about types with a default value. That is, int or float fields will produce a '0' string for unset values through the formatter, which gets interpreted as non-missing. We clearly need better logic for this.\_
> 
> \### Setup
> 
> \* OS: Arch Linux
> \* beets version 1.5.0
> \* Python version 3.9.1
> \* plugins: edit, extrafiles, fetchart, importadded, importfeeds, info, inline, lastimport, mbcollection, mbsync, mpdstats, mpdupdate, originquery, scrub, smartplaylist, types, zero

A few examples below:

```auto
beet ls -f '%asciify{$albumartist}/%if{$original_year,$original_year,$year} - $album%ifdef{albumdisambig, ($albumdisambig),}%ifdef{u_type, [$u_type],}/%right{$disc,1}-$track - $title' album:"The Gereg" track:1

```

**Result:** `The HU/2019 - The Gereg (deluxe edition)/1-01 - The Gereg`

The above command gives me the expected output. I want “deluxe edition” capitalized, so I’ll change the command to this:

```auto
beet ls -f '%asciify{$albumartist}/%if{$original_year,$original_year,$year} - $album%ifdef{albumdisambig, (%title{$albumdisambig}),}%ifdef{u_type, [$u_type],}/%right{$disc,1}-$track - $title' album:"The Gereg" track:1

```

Again, I get the expected result, which is `The HU/2019 - The Gereg (Deluxe Edition)/1-01 - The Gereg`.

If I try an album that has `u_type` set, but empty `albumdisambig`, I get extra `()`, which is not expected.

```auto
beet ls -f '%asciify{$albumartist}/%if{$original_year,$original_year,$year} - $album%ifdef{albumdisambig, (%title{$albumdisambig}),}%ifdef{u_type, [$u_type],}/%right{$disc,1}-$track - $title' album:Nightmother track:1

```

**Result** : `Wormlight/2021 - Nightmother () [Bandcamp]/1-01 - Nightmother`

And if I try an album with empty `u_type` and empty `albumdisambig`, I see the same issue with extra `()` from `albumdisambig`, but there is no extra `[]` from `u_type`.

```auto
beet ls -f '%asciify{$albumartist}/%if{$original_year,$original_year,$year} - $album%ifdef{albumdisambig, (%title{$albumdisambig}),}%ifdef{u_type, [$u_type],}/%right{$disc,1}-$track - $title' album:Singularity track:1

```

**Result:** `Stortregn/2016 - Singularity ()/1-01 - Enlighten Salvation`

This leads be to believe the issue is with `albumdisambig`, but I am not sure why. 🙂

My installation is on Arch Linux:

```auto
╰─❯ beet --version
beets version 1.5.0
Python version 3.9.6
plugins: edit, fetchart, importadded, importfeeds, info, inline, lastimport, mbcollection, mbsync, mpdstats, mpdupdate, originquery, playlist, scrub, smartplaylist, types, zero

```

Thanks for reading!
