Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Syntax for a custom column that only shows album artist if... (Read 1048 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Syntax for a custom column that only shows album artist if...

Hello, longtime user of Foobar2000, new member to the forum, brand new to scripting in Foobar.

I want to create a custom column that only displays the album artist if it's both not the same as the artist, and if it's not "Various Artists". If it's either of those, I want it to display "N/A" or really anything else. I'm tired of seeing this happen:



So far I have this:

Code: [Select]
$if($or(%album artist%==%artist%,%album artist%==Various Artists),N/A,%album artist%)

However, that just makes EVERY album artist appear as "N/A". And if I change it to an $xor, then, again, EVERY album artist shows, even if they're duplicates of the artist.

Any recommendations? I get the feeling I should maybe be using $and somewhere, or $not, but I don't know how to use them nested within the other functions.

Thanks!

Re: Syntax for a custom column that only shows album artist if...

Reply #1
Check if ALBUM ARTIST is the same as ARTIST:
Code: [Select]
$stricmp(%album artist%,%artist%)
Check if ALBUM ARTIST is NOT 'Various Artists':
Code: [Select]
$not($stricmp(%album artist%,Various Artists))
Check if both of the above is true at the same time:
Code: [Select]
$and(
$stricmp(%album artist%,%artist%),
$not($stricmp(%album artist%,Various Artists))
)
Decide what you want to do if that equals true or false:
Code: [Select]
$if(
$and(
$stricmp(%album artist%,%artist%),
$not($stricmp(%album artist%,Various Artists))
)
,TRUE,FALSE)
Show ALBUM ARTIST only if true, otherwise show nothing:
Code: [Select]
$if(
$and(
$stricmp(%album artist%,%artist%),
$not($stricmp(%album artist%,Various Artists))
)
,%album artist%,)
Also, you may want to check if ALBUM ARTIST even exists in the first place. Otherwise the above script would show the contents of ARTIST in case ALBUM ARTIST was missing.
Code: [Select]
$if($meta(album artist),
$if(
$and(
$stricmp(%album artist%,%artist%),
$not($stricmp(%album artist%,Various Artists))
)
,%album artist%,)
,)

Note these scipts are currently using $stricmp() for string comparison which is case-insensitive. You may use $strcmp() instead which is not.

Re: Syntax for a custom column that only shows album artist if...

Reply #2
Daeron, I like the way you built up the example code.

Re: Syntax for a custom column that only shows album artist if...

Reply #3
sic

I appreciate the help, and I agree with Jailhouse, that's a pretty thoughtful way of building it up. However, after removing the line breaks and pasting the code from the final example, now I'm only getting the duplicate artists showing up. Various Artists has stopped at least, so that's good, but the album artists that aren't duplicates are not showing, and as I said, the ones that are duplicates are the only ones showing.

Illustration with the default album artist/album on the far right:



What am I missing?

Re: Syntax for a custom column that only shows album artist if...

Reply #4
Hmm maybe I derailed myself while writing the explanation. This should work:
Code: [Select]
$if($meta(album artist),
$if(
$or(
$stricmp(%album artist%,%artist%),
$stricmp(%album artist%,Various Artists)
)
,,%album artist%)
,)
I changed $or() to $and(), removed the $not() in case of 'Various Artists' and moved %album artist% towards the end from the TRUE branch to the FALSE branch. It's mostly just adjusting the logic of the script to get the reverse of what I originally posted.

If this sudden switch is hard to follow I can go into details again, but it's largely the same building blocks that I posted earlier just used differently.

Re: Syntax for a custom column that only shows album artist if...

Reply #5
Thank you! That worked! I added in "N/A" where you left blanks, and now everything is displaying correctly!

I knew posting here was the right idea.  :D

 

Re: Syntax for a custom column that only shows album artist if...

Reply #6
Hmm maybe I derailed myself while writing the explanation. This should work:

This topic is of interest since I have a couple albums where there is a joint artist for albumartist (for duos and such), but unlike the OP's example my artist tags are separated into multiple values, one for each artist.

The formatting above does a strict comparison between strings and so misses the shared artist names. Is there a way for the formatting to be adapted to check for these cases?

Example properties from a track of one album:

Album Artist: Kiril Ribarski & Milica Sperovic-Ribarski
Artist Name: Kiril Ribarski; Milica Sperovic-Ribarski; Fritz Kreisler

In an effort to improve my track artist formatting so I don't have the mess below  :P