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: How to define a compilation using Title Formatting? (Read 2658 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How to define a compilation using Title Formatting?

[I'm not sure if this is the right place for this]

I want to have a boolean OR that checks to see if %album% contains any of the following "Greatest", "Best of", "Boxed", "Various Artist", etc. IOW, I want the OR to return true if my conditions for a compilation are met. I will be using this in the context of foo_dop, but the syntax is the same as in other parts of Foobar.

I've been looking at Title Formatting trying to figure this out. One of the things I can't figure out is how to check a string, %album%, to see if a substring [one of the above I listed for example] is present?

Can someone give me an example of what this would look like? Thx.

How to define a compilation using Title Formatting?

Reply #1
Checking if ALBUM contains 'Greatest':
Code: [Select]
$strstr(%album%,Greatest)


Checking if ALBUM contains 'Greatest' OR 'Best of' OR 'Boxed':
Code: [Select]
$or(
$strstr(%album%,Greatest),
$strstr(%album%,Best of),
$strstr(%album%,Boxed)
)


Evaluation and returning either TRUE or FALSE:
Code: [Select]
$if(
$or(
$strstr(%album%,Greatest),
$strstr(%album%,Best of),
$strstr(%album%,Boxed)
)
,TRUE,FALSE)

How to define a compilation using Title Formatting?

Reply #2
Thx for your help!
Q:
1. Is there a difference between using %album% and $meta(album)?
2. I need the code to return 1 or nothing. i.e. Here is an example that worked. Although, the actual code that I got from some other source is this:
Code: [Select]
$if($stricmp($meta(album artist),various artists),1,%ipod_compilation%)
Unfortunately, I can't explain the difference
3. If you are familiar this foo_dop plug-in:
3a. The other thing I need to figure out is how to update the metadata so that the code I entered:
Code: [Select]
$if($or($strstr($meta(album),Greatest),$strstr($meta(album),Best of),$strstr($meta(album),Boxed)),1,)
Will replace the other code above. At the moment, when I click on Compilation in my Ipod Classic, I am still getting only results for "various Artist" which is what the first code does.

EDIT: These strstr functions above are case sensitive or not?

How to define a compilation using Title Formatting?

Reply #3
Is there a difference between using %album% and $meta(album)?

Some fields are remapped, for example %album artist% will, by default, return the first existing value it finds from either ALBUM ARTIST, ARTIST, COMPOSER, PERFORMER fields in order (wiki). Additionally there are components which take over specific meta, such as %rating% when using the Playback Statistics component. $meta(tag) results in directly referencing a single metadata field, with the remappings ignored.

I need the code to return 1 or nothing. i.e. Here is an example that worked. Although, the actual code that I got from some other source is this:
Code: [Select]
$if($stricmp($meta(album artist),various artists),1,%ipod_compilation%)

$if(condition,is_true,is_false)
$if($stricmp($meta(album artist),various artists),1,%ipod_compilation%)

This currently means in case the condition (ALBUM ARTIST containing 'various artists') evaluates true, you will write 1. If it evaluates false, you will return the contents of the %ipod_compilation% tag. Based on what you said, you don't want the latter to ever happen. Which means:

$if($stricmp($meta(album artist),various artists),1,)

3a. The other thing I need to figure out is how to update the metadata so that the code I entered:
Code: [Select]
$if($or($strstr($meta(album),Greatest),$strstr($meta(album),Best of),$strstr($meta(album),Boxed)),1,)
Will replace the other code above. At the moment, when I click on Compilation in my Ipod Classic, I am still getting only results for "various Artist" which is what the first code does.

Your script is working on its own. I'm not familiar with the component so I can't help other than saying you might need to manually update the database on your ipod, based solely on this picture. Did you enter your script to the compilation field or somewhere else?

These strstr functions above are case sensitive or not?

As stated on the wiki, case-sensitive: $strstr(), $strcmp(), case-insensitive: $stricmp().

---

Overall based on what you are trying to achieve, I would rather look into the usage of ALBUM ARTIST, fill your tags accordingly and make a script based on that. Your way is not exactly foolproof (you can easily find albums with multiple artists that you'd prefer to be grouped together but are not as they don't contain 'Best of' or anything similar in their album titles).

How to define a compilation using Title Formatting?

Reply #4
A side question: How do you integrate a view into Foobar? i.e. When I open up Foobar, the only thing I see is "Facets" and it is integrated into Foobar. I need to do this for iPod too.

How to define a compilation using Title Formatting?

Reply #5
Foobar currently has two user interfaces, Default UI and Columns UI. Some components can be integrated into both, some only supports one. Components that are not compatible with the specific UI can only be used in a separate window. Your component seems to be CUI only (check the tags at the bottom of the page).

Otherwise editing mode can be accessed by 'File/Preferences/Display/Default UI/Enable layout editing mode checkbox' for DUI or 'View/Layout/Live editing' if you are using CUI.

How to define a compilation using Title Formatting?

Reply #6
Thx for time and help! This is the code I ended up using:
Code: [Select]
$if($or($strstr($meta(album),Greatest),$strstr($meta(album),Best of),$strstr($meta(album),Boxed),$stricmp($meta(album artist),various artists)),1,)

1. I had to re-sync my entire music collection using foo_dop in order to implement it. I could not figure out how to update the metadata on the iPod w/o doing this unfortunately. It's not hard to do this, but very time consuming. i.e. 11,000 songs or so.
2. Of course, it missed things like "Box Sets" and a few other types of compilations.
3. And, I have a playlist/collection of Rolling Stone's 500 Greatest Songs of All Time that got picked by accident.
All in all, it's not a bad start. It just takes a hell of lot of time to test any new code in this manner! LOL

How to define a compilation using Title Formatting?

Reply #7
From what I've seen it can also synchronize based on a playlist of songs instead of all of them. But again, I don't have an iPod so can't be much of a help in that regard.

If you want to test the results of scripts fast, add a 'test' column to the playlist viewer and only make it visible for testing purposes. You can create a playlist and fill it with some songs that are meant to be marked by the script and some that aren't. Then you can compare results with expectation and adjust the script accordingly.

How to define a compilation using Title Formatting?

Reply #8
Here is a quirk of the iPod. Take the case of an artist in your collection that only has 1 album.
1. When you click on that artist int he artist view, you will not see that album to click on, but will see the tracks contained in that album instead.
2. This means that the code I used above "removes" all those artists from the artist view that only have 1 greatest hits/best of/etc. i.e. This listings will now only display under the Compilation View! If an artist has more than 1 album, than that artist will display under the artist view!