INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Expression for the number of discs in an album?  (Read 3828 times)

newHAPPYuser2015

  • World Citizen
  • ***
  • Posts: 111
Expression for the number of discs in an album?
« on: September 16, 2015, 12:40:16 pm »

Can anyone think of an expression that would return the number of discs from which one has songs in an album? For example, if I have several songs from discs 1 and 3 in a 3-cd album such an expression would output ''2'' for that album. Is it possible at all?

Thanks
Logged

ferday

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1732
Re: Expression for the number of discs in an album?
« Reply #1 on: September 16, 2015, 08:37:42 pm »

Sure...there's still some manual tagging to do though, as MC needs to "know" that an album has multi discs.  At minimum you'd need the total discs field and total tracks field filled out properly

I'm away from MC for a while so Blgentry will likely beat me to the punch, but it will likely be quite a complex expression.  I'm pretty sure it's possible though
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: Expression for the number of discs in an album?
« Reply #2 on: September 16, 2015, 09:48:50 pm »

Possible, yes. But, in practice, it is pretty difficult to do this.

Expressions can't easily calculate stats. Each expression works on an individual file.  There is no way to tell an expression to look at, and calculate something about, an entire "set" of files.  And, there is no "for each" type of statement so iterate through sets of files either.  To do so, you have to load and save global variables which look at every single file in your Library (or all of those that result from a search), which can be fiddly to implement and can lead to stale results if you don't fully understand the concepts behind it. I'd recommend you start with MrC's Stats thread:
https://yabb.jriver.com/interact/index.php?topic=77826.0

And read through the other threads linked from the Global Variables stub on the wiki:
http://wiki.jriver.com/index.php/Global_Variables

And decide if this is something you want to pursue.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Expression for the number of discs in an album?
« Reply #3 on: September 16, 2015, 10:07:45 pm »

You can do this with essentially identical logic to how I described how to solve your "total tracks in multi-disc albums" request in this thread:

http://yabb.jriver.com/interact/index.php?topic=100174.msg694391#msg694391

For the View in step 2 of that thread, use this expression as the Import/Export instead:

Code: [Select]
[Media Type]=[Audio] playlistid==788130232 [=save(0,v_discs[album artist (auto)][album])1]=1 [=save(math(1+load(v_discs[album artist (auto)][album])),v_discs[album artist (auto)][album])1]=1
Again, substitute your Smartlist from Step 1 for the Smartlist ID in the expression above.

I'm happy to help with these kinds of things, but this is quite a few in a short time.  Good luck with the project you are pursuing. :)

Brian.
Logged

BryanC

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2662
Re: Expression for the number of discs in an album?
« Reply #4 on: September 17, 2015, 12:52:35 pm »

snip

Isn't this a good usage scenario for ~expand? I've never used it before but intuitively it seems like it would do the trick. Expand to every track in the complete album and then return the highest disc number from that set of files.
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: Expression for the number of discs in an album?
« Reply #5 on: September 17, 2015, 03:52:00 pm »

^ He doesn't want the highest Disc number.  He wants the total number of Discs in an Album.  If he has songs from Disc 1 and Disc 4 of a 6 disk set, he wants the answer to be "2"; because he has songs from 2 of the discs.  So, counting the number of distinct discs per album in his library.

Brian.
Logged
Pages: [1]   Go Up