Samplerate - how to generate path without decimal?

Hi,

I’m having a bit of trouble trying to track down why my ‘my_samplerate’ item_field reports with 1 decimal place, ie ‘44.0’ or ‘96.0’ as opposed to just 44 or 96. I’m wanting the following [16-44];

Shellac / 1000 Hurts (2000) [FLAC CD 16-44] [TG211CD] / 01 - Prayer To God.flac

but receive this [16-44.0];

Shellac / 1000 Hurts (2000) [FLAC CD 16-44.0] [TG211CD] / 01 - Prayer To God.flac

from the following path:

default: $albumartist/$album (%if{$original_year,$original_year}) %aunique{albumartist album year, albumtype label catalognum albumdisambig}%if{$albumdisambig,($albumdisambig $year)}[$format $media $bitdepth-$my_samplerate] [$catalognum]/%if{$multidisc,Disc $disc-}/$track-$title

and item_fields:

item_fields:
my_samplerate: round((samplerate / 1000), 0)

which should round it to zero decimal places… or more than likely I’m missing something? My full config.yaml can be found here;

https://github.com/bretthabel/beets-config/blob/master/config.yaml

Any help most appreciated!

Brett.

I think you just want round(samplerate / 1000). Otherwise, you get a float back, which will have the .0.

Thanks Adrian, I did have this originally as you’ve suggested;

item_fields:
my_samplerate: round(samplerate / 1000)

But it returned the same result [FLAC CD 16-44.0] which is why I tried to force it to ‘0’ decimal places. I’ll give it another go tonight and report back.

Thanks again.

So, just changed it back to…

round(samplerate / 1000)

but same issue persists. Odd. Latest config.yaml here; https://github.com/bretthabel/beets-config/blob/master/config.yaml

Any help most appreciated!

Weird! To help narrow it down, you might try experimenting at the Python console. For example:

>>> 44100 / 1000
44.1
>>> round(44100 / 1000)
44
>>> round(44100 / 1000, 0)
44.0
>>> int(44100 / 1000)
44
>>> str(int(44100 / 1000))
'44'

I’m not sure why round isn’t working, but maybe try str(int(...)) just in case?

2 Likes

Using;

my_samplerate: str(int(samplerate / 1000))

Worked!

Thanks Adrian. Still rather odd that round wasn’t working.

1 Like