Generate differented kbps for Album/CD Folders with Inline Plugin

Hello, I like to save the average Bitrate (for lossy) or the bitdeth-samplerate (for lossless) Audio Files in the folder name. In addition I’m saving multic cd albums in a structure like Albumname/CD* - CD name [Bitrate or Bitdepth-samplerate].
But I have one album where CD1 is in FLAC and CD2 is in MP3 and there I noticed that the bitrate is calculated over the complete album. I have absolutely no clue how I should do that, because there are just that two options for album_fields an item_fields.

What I want is:

/ArtistEx/AlbumExample (2CD)/CD01 [FLAC 16-44]
/ArtistEx/AlbumExample (2CD)/CD02 [MP3 320kbps]

What I get is:

/ArtistEx/AlbumExample (2CD)/CD01 [FLAC 16-44]
/ArtistEx/AlbumExample (2CD)/CD02 [MP3 700kbps]

The CD with the MP3 just has 320kbps, but the average is generated over the whole album, including the FLACs. But I want that the average is generated only from the CD. Is this possible?

This is my actual Code:

   total = 0
      for item in items:
          total += item.bitrate
      bitrate = str(round(total / len(items) / 1000))
      kbps = "kbps"
     return bitrate + kbps

I had an idea to make something with the item.disc parameter, but I don’t know how and what.
So the question: Is this possible to do that as I want and if yes, any suggestions?

******* EDIT ********
Ok I’ve got a lazy “solution”.

   total = 0
   itemCount = 0
   for item in items:
       if item.bitrate < 400000:
           total += item.bitrate
   bitrate = str(round(total / itemCount / 1000))
   kbps = "kbps"
   return bitrate + kbps

Now before I use the bitrate for calculating, I’m checking if the bitrate is higher then 400kbps and then dividing it with the count of the used objects. This solves my problem there the lossless files get calculated in the average too.
But this solution is not really clean. If there is an album with CD1@320kbps and CD2€128kbps it will still calculate the average for both CDs. So my question for get the average for the files in just one CD folder is still present.

Hi! Interesting problem—you might consider just computing the average for items that match the current item’s disc.

total = 0
count = 0
for other_item in items:
    if other_item.disc == disc:
        total += 1
        count += other_item.bitrate
return str(total / count) + "kbps"

I just hammered that out to give you a rough idea, so it’s completely untested and probably wrong. :smiley:

Hey, thanks for your answer!

A solution like that was my initial idea this morning. But then I stopped because i don’t know how I should give the album_flied the information that I want just disc 1/2/x. So I need the possibility to give that function that information, maybe with an numeric parameter. But I don’t know how I should do that, is that even possible?

Oh right, of course! This would need to be a track-level attribute rather than an album-level attribute so it’s different for the different discs. I honestly can’t recall if there’s a way to get the album’s item list from an item-level attribute definition…

Ok, then I think there is no way for a solution without changing code on the Inline plugin, so I think I just accept my lazy solution.
But thanks that you tried to help me. And thanks to you and all the other contributors, beets is really useful for me.

1 Like