Author Topic: <album duration> tag format  (Read 189 times)

DrRoboculous

  • Newbie
  • *
  • Posts: 18
Is it possible to change the way it shows the <album duration> tag from like this format: hh:mm to this: "1 hour, 34 minutes" ? And if the album duration is only 34 minutes then it only shows "34 minutes" as opposed to "    hour, 34 minutes" or like " 2 hour,     minutes" if the thing is exactly 2 hours long. I was able to find one post about it that seemed like the guy was asking for the same thing here. But none of that helped and the Additional Tagging Tools plugin doesn't do what i'm trying to do. Like i want the words "hour" & "minute" in there. Like how it displays the total album duration time in the Playlists tab using the Album and Tracks view. Like this here. It seems like this should be possible by throwing in a couple of quotation marks in the right place using the right function code but i haven't been able to figure it out.
Thanks again in advance, everybody.

The Incredible Boom Boom

  • Jr. Member
  • **
  • Posts: 106
There's not an internal way to change the format, so you'd have to make a wishlist request (which I'd support.)

Below is a break down of the code given in your linked thread. This is to link to a list of MB functions and this is the link to the Additional Tagging & Reporting Tools plugins page, where, if you scroll to the bottom half, you can find additional functions, all from which you can use to figure out your desired result.

Code
$If(
    $Div($Split(<Album Duration>,:,1),60)<1,

         <Album Duration>,

    $RoundDown($Div($Split(<Album Duration>,:,1),60),0)
    :
    $Pad($Mod($Split(<Album Duration>,:,1),60),2)
    :
    $Split(<Album Duration>,:,2)
)
<Album Duration>=94 minutes (1 hour, 34 minutes)
Code
$Div($Split(<Album Duration>,:,1),60)<1,
...using the colon as a delimiter to split the tag into the first (minutes) of two sections (minutes:seconds) and then divides that number (94) by 60 (94/60=1.56666667) to check if it's less than 1 (which it isn't.) So, we move to the third block of code.

Code
$RoundDown($Div($Split(<Album Duration>,:,1),60),0)
:
$Pad($Mod($Split(<Album Duration>,:,1),60),2)
:
$Split(<Album Duration>,:,2)
The first line is where the number of hours (!) is displayed by taking the total number of minutes (94), dividing by 60 (94/60=1.56666667) and then rounding that number down (1) and using 0 spaces after the decimal.

The third one is where the number of minutes (!) is displayed by again taking the total number of minutes (94), dividing by 60 (94/60=1.56666667), but using Modulus to get the the remainder (34) and then Padding it by 2 digits in case only a single digit is returned.

The last line is the number of seconds (minutes:seconds)

-------------------------------------------------------------------------------------------------

Hopefully that block of code now makes more sense and from here it should be easier to figure out where you want to place "hours" and "minutes" in your Virtual Tag.

DrRoboculous

  • Newbie
  • *
  • Posts: 18
Dude, i really appreciate you breaking down that code for me but, while it does make more sense now, i still have no idea where to put the "hours"and "minutes" in there. I tried putting that code from the previous post into a virtual tag but it didn't change anything. It worked, but the Album Duration still read in the same format & it looked exactly the same as it did just using the existing <Album Duration> tag. And i downloaded & tried to use the Additional Tagging Tools plugin but the code & method for a making virtual tag described in the other post doesn't do anything except give me the result "SYNTAX ERROR" and the ATT plugin doesn't even have <Album Duration> anywhere in any of the fields. It doesn't have all the fields that exist in MusicBee itself.
  
  And as far as i can figure out, the ATT plugin is used for tagging individual files/albums. So if i wanted the Library tab in MusicBee to read in that format ["x hours, x minutes"] on my Albums view  i would have to go through and tag individually every album in my library, as opposed to it just showing the information automatically the way it does now using the tag <Album Duration>. Am i right about that?

  Trust me, this is embarrassing - that i spent literally 5 hours last night trying to figure this out but failed at every turn. I messed around with the virtual tags in MusicBee itself and tried making new ones with the Additional Tagging Tools plugin but everything i tried either just didn't work at all -(like getting "syntax error" or "fail" messages)- or the code itself would work but just end up displaying album duration in exactly the same format.

  And from the first part of your post it seems like what i'm trying to do isn't possible, so i should just post a future feature request, but then you're saying it is possible to do with the ATT plugin? Sorry; i know i'm a dumbass but, this kind of stuff drives me crazy! I'm starting to feel that coding is like calculus: half of it is just very logical and straightforward but the other half is you have to already know all the correct formulas to plug the variables into.

Anyway, I really do appreciate you breaking it down for me & helping but . . . i guess i'm kind of dense.  :-\


EDIT:  i just went and tried using the code to make a virtual tag and this was the best i was able to guess:
Code
$If($Div($Split(<Album Duration>,:,1,"min."),60)<1,<Album Duration>,$RoundDown($Div($Split(<Album Duration>,:,1,"hr."),60),0):$Pad($Mod($Split(<Album Duration>,:,1,"min."),60),2):$Split(<Album Duration>,:,2,"sec."))
And i tried just replacing all the "1"'s to "hr." or whatever instead of putting it after. I took out commas & quote marks & stuff like that and put them back in in several different configurations.
Obviously none of that worked.   :-[
I tried though!  :-X
Last Edit: August 02, 2020, 12:12:29 AM by DrRoboculous

The Incredible Boom Boom

  • Jr. Member
  • **
  • Posts: 106
It worked, but the Album Duration still read in the same format & it looked exactly the same as it did just using the existing <Album Duration> tag. And i downloaded & tried to use the Additional Tagging Tools plugin but the code & method for a making virtual tag described in the other post doesn't do anything except give me the result "SYNTAX ERROR" and the ATT plugin doesn't even have <Album Duration> anywhere in any of the fields. It doesn't have all the fields that exist in MusicBee itself.

Right, the plugin adds extra functions not included with MB itself. <Album Duration> is a built-in function of the program already.
  
Quote
So if i wanted the Library tab in MusicBee to read in that format ["x hours, x minutes"] on my Albums view  i would have to go through and tag individually every album in my library, as opposed to it just showing the information automatically the way it does now using the tag <Album Duration>. Am i right about that?

Nope, all you need the plugin for are the $Mod() and $Div() functions. The equations do the math and then you add the words to get you the result you're looking for.

Quote
...half of it is just very logical and straightforward but the other half is you have to already know all the correct formulas to plug the variables into.

In this case, all that is already done for you and all you have to do is add the words to the right places. :) But, trust me, if you learn and understand it all, you won't stop with just changing the album duration and you'll be adding and changing MB in all sorts of ways to fit how you want it to look and function.


Quote
EDIT:  i just went and tried using the code to make a virtual tag and this was the best i was able to guess:
Code
$If($Div($Split(<Album Duration>,:,1,"min."),60)<1,<Album Duration>,$RoundDown($Div($Split(<Album Duration>,:,1,"hr."),60),0):$Pad($Mod($Split(<Album Duration>,:,1,"min."),60),2):$Split(<Album Duration>,:,2,"sec."))
And i tried just replacing all the "1"'s to "hr." or whatever instead of putting it after. I took out commas & quote marks & stuff like that and put them back in in several different configurations.
Obviously none of that worked.   :-[
I tried though!  :-X

It's very close, though, which is why I referred you to the MB functions page, which says Format as $Split(<Tag>,Split Value,#). That means you can only have three parameters inside the $Split() function. If you moved what you added outside the function, you'd start to see something different. Not quite what you want, but you'd start to see your changes manifest. Try pasting the below and going from there. Then look at the differences between what you had put and the below to see why things weren't working.

Code
$If($Div($Split(<Album Duration>,:,1),60)<1,<Album Duration>,$RoundDown($Div($Split(<Album Duration>,:,1),60),0)hours:$Pad($Mod($Split(<Album Duration>,:,1),60),2)minutes:$Split(<Album Duration>,:,2)seconds)

DrRoboculous

  • Newbie
  • *
  • Posts: 18
Ok, i've been playing around with this for a while now. I installed the ATT plugin, made sure it's in MusicBee properly & the menus for it appear & everything. Then I copied & pasted the last code you put in the last message into my virtual tag and I still got the same format [mm:ss]. The only thing i've been able to figure out after an hour & 1/2 is that if i add a parenthesis after the part in the code that says "hours" i end up with "36:48:36minutes:48seconds)" instead of "36:48". So, there's something going on there. Which still doesn't make any sense to me but hey; it's progress. But after moving & adding & deleting parenthesis around every way i can possibly think of, i still end up with some form of "36:48:36minutes:48seconds" or "36:48:36minutes:48(seconds)" or "(36:48):36minutes:48seconds" or "36:48(:36minutes:)(48seconds" or some nonsense like that. So i'm obviously missing something simple but important that i just don't understand. It doesn't seem to make a difference if i split the code into different paragraphs or lines or whatever. Spaces only seem to change the outcome sometimes.

  Can you just give me the answer?   ;)   I'm so close - i can feel it. Maybe it's just something like my OS? I'm running Windows 10. I don't have anything weird going on on my computer like some emulator or something. I'm using the latest download/update of MusicBee > i made sure of that.

  I appreciate you taking the time with me here but, i am about to jump out of my window. Which is only like a 5-foot fall but still! Thanks again.  :)

DrRoboculous

  • Newbie
  • *
  • Posts: 18
HANG ON A SECOND

I just used
Code
$If($Div($Split(<Album Duration>,:,1),60)<1,,<Album Duration>,$RoundDown($Div($Split(<Album Duration>,:,1),60),0)hours:)$Pad($Mod($Split(<Album Duration>,:,1),60),2)minutes:$Split(<Album Duration>,:,2)seconds
So i just added a comma after "<1," and added ")" after "hours". I think it's working now. I'll have to check a couple of different ways to see if it's actually working but hot damn! i am on to something.

DrRoboculous

  • Newbie
  • *
  • Posts: 18
Good Lord, I got it! Ok, I ended up with:
Code
$If($Div($Split(<Album Duration>,:,1),60)<1,,$RoundDown($Div($Split(<Album Duration>,:,1),60),0)"hr: ")$Pad($Mod($Split(<Album Duration>,:,1),60),2) min / $Split(<Album Duration>,:,2) sec
and that gives me a result of (for example): "3hr: 36 min / 48 sec" And i figured out how to change it around & tweak the wording of it without completely ruining the entire functioning code.  :o

  Thank you so much, man! I realize it might seem weird for me to get this worked up about this -and the solution was probably really obvious to a lot of users, to begin with- but honestly, I have so few wins in my life lately. [f*kin coronavirus].  And I think you gave me enough information to make me not want to literally rip my hair out but, I still feel like I was able to figure out the details myself and now I understand how & why it worked. Right now I feel a sense of accomplishment on par with that of killing a Dark Souls boss. 8)
  
Anyway, thanks again.
Last Edit: August 02, 2020, 05:56:19 AM by DrRoboculous

The Incredible Boom Boom

  • Jr. Member
  • **
  • Posts: 106
Congrats on figuring it out! If you make some notes on what is happening with the formulas, you can refer back to them the next time you want to change something tag-based within MusicBee. And again, be sure to reference the Functions page and the Additional Tagging & Reporting Tools functions as well. The MusicBee function syntax itself is basic enough (with the only problem being it's difficult to read once you start getting to multiple lines, since there is no formatting) and understanding it will help when you notice something else you want to do. For example...

Quote
Then I copied & pasted the last code you put in the last message into my virtual tag and I still got the same format [mm:ss].

The $If() functions works like this... $If(Criteria,True Result,False Result)
In the code I initially gave you, the Criteria is the check whether <Album Duration> is under one hour and if True Result, then it just displays the <Album Duration> tag (which is why the format didn't change when you were looking at a 34 minute album.) You could see the changes take effect when looking at an album longer than an hour, because the $If() function had reached the False Result parameter.

Quote
So i just added a comma after "<1," and added ")" after "hours".

Now hopefully you can "see" how the $If(Criteria,True Result,False Result) statement is giving you the result you want. Reading your code out loud will help ingrain it as well.

If the first split of <Album Duration> divided by 60 is less than 1, (interpret this comma as the word "then") don't display anything, (interpret this comma as the word "else") display the result of the first split of <Album Duration> divided by 60 then rounded down - display "hr:" - display the remainder of the first split of <Album Duration> divided by 60 then Pad by 2 digits - display "min / " - display the second split of <Album Duration> - display " sec"

A mouthful, but crucial to being able to make future changes.

Quote
Thank you so much, man! I realize it might seem weird for me to get this worked up about this -and the solution was probably really obvious to a lot of users, to begin with- but honestly, I have so few wins in my life lately. [f*kin coronavirus].  And I think you gave me enough information to make me not want to literally rip my hair out but, I still feel like I was able to figure out the details myself and now I understand how & why it worked. Right now I feel a sense of accomplishment on par with that of killing a Dark Souls boss.

Not a problem, bro. I've never gone up against a Dark Souls boss, lol, but I understand the recent life frustrations and glad you've been able to find some confidence in even the little things!

Not sure if you're fully ok with the result you have now, but the below will give you exactly what you requested earlier. Look at the changes I made, see if you can understand the flow and let me know if you have any more questions about it. One more thing - try to always use quotation marks whenever you're displaying text.

Code
$If($Div($Split(<Album Duration>,:,1),60)<1,,$RoundDown($Div($Split(<Album Duration>,:,1),60),0)" hour"$If($Pad($Split(<Album Duration>,:,1),3)>=120,"s",)", ")$Mod($Split(<Album Duration>,:,1),60)" minute"$If($Pad($Mod($Split(<Album Duration>,:,1),60),2)=01,,"s")
Last Edit: August 02, 2020, 06:26:50 PM by The Incredible Boom Boom