Question about conditional path formating

When seeing @oldsweatyman solution I thought I’ll post my final solution for conditional path formatting. It might be useful for others.

Most of my albums are FLAC 16-44
Since this would polute my list visually if it would be added to most of my albums I decided to come up with a solution that will only add
(MP3 bitrate)
or
(FLAC bitdepth-samplerate)
for albums that are MP3 or hires FLACs.

This could give a result like this:

Four Tet
2020 - Parallel (FLAC 24-44)
2003 - Rounds
2001 - Pause (MP3 278)

Since my inline code calculates the average album values this leads in very rare cases (where a FLAC album has mixed bit depth) to a result with a non existing bit depth, e.g.:

Talking Heads
1985 - Stop Making Sense (FLAC 23-48)

This is the inline section of my config file.

# Inline plugin template
item_fields:
  multidisc: 1 if disctotal > 1 else 0
  my_samplerate: round(samplerate / 1000)
  is_flac: 1 if format == "FLAC" else 0
album_fields:  
  format: |
       formatList = []
       for item in items:
           formatList.append(item.format)
       return formatList
  av_bitrate: |
       total = 0
       for item in items:
           total += item.bitrate
       return round(total / len(items) / 1000)
  album_bitdepth:  |
       total = 0
       for item in items:
           total += item.bitdepth
       return round(total / len(items))
  album_samplerate:  |
       total = 0
       for item in items:
           total += item.samplerate
       return round(total / len(items) / 1000)
  is_1644: |
       bd = 0
       sr = 0
       br = 0
       for item in items:
           bd += item.bitdepth
           sr += item.samplerate
           br += item.bitrate
       bd = round(bd / len(items))
       sr = round(sr / len(items) / 1000)
       br = round(br / len(items) / 1000)
       return 1 if bd == 16 and sr == 44 and br > 320 else 0

And my default path looks like this:

paths:
  default: 'Albums/%the{$albumartist}/%if{$original_year,$original_year} - $album %aunique{albumartist album year, albumdisambig}%if{$albumdisambig,($albumdisambig $year) }%if{$is_1644,,%if{$is_flac,($format $album_bitdepth-$album_samplerate),($format $av_bitrate)}}/%if{$multidisc,$disc-}$track - $title'

Hope this is useful!

2 Likes