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: Output parentheses in foobar (Read 6742 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Output parentheses in foobar

I want to output the albumname, then the year inside of parentheses. If the info exists. Like this:

Serpent's Egg (1988)

this is my "code":

[%album% %date%]

but I can't write "(%date%)", 'cause then the year doesn't show at all. Maybe there's a way of showing these special signs?

Output parentheses in foobar

Reply #1
Surround the special characters with single quotes to denote them as literal values.

Code: [Select]
[%album% '('%date%')']


Edit:  I assume you're talking about the playlist view in the Default UI?

Output parentheses in foobar

Reply #2
Surround the special characters with single quotes to denote them as literal values.

Code: [Select]
[%album% '('%date%')']


Edit:  I assume you're talking about the playlist view in the Default UI?


Yes, thank you, it works beautifully =).

Output parentheses in foobar

Reply #3
These and other basics are explained in the title-formatting introduction available on the Knowledgebase.

Output parentheses in foobar

Reply #4
Sorry to hijack this thread, I have been trying to find an answer in many sources including the Title Formatting reference sources but no luck so far  :

I have album names formatted this way
Albumname (Hires) or Albumname [2015 deluxe edition]
and I would like to be able to remap these names to albumname only, striping whatever is between the parenthesis or brackets,
typically to use the original albumname in foo_run or WSH panel queries.
I am sure this issue must have been raised somewhere already, but can anyone give me a clue on how I could do that ?

Thanks for your help

Output parentheses in foobar

Reply #5
I have album names formatted this way
Albumname (Hires) or Albumname [2015 deluxe edition]
and I would like to be able to remap these names to albumname only, striping whatever is between the parenthesis or brackets


Gather and select the ones with brackets. Alt+Enter for Properties. Right-click --> Automatically fill values. Source --> Other..., fill in %album%. Set Pattern as e.g. %album% [%releaseversion%]

Output parentheses in foobar

Reply #6
I have album names formatted this way
Albumname (Hires) or Albumname [2015 deluxe edition]
and I would like to be able to remap these names to albumname only, striping whatever is between the parenthesis or brackets


Gather and select the ones with brackets. Alt+Enter for Properties. Right-click --> Automatically fill values. Source --> Other..., fill in %album%. Set Pattern as e.g. %album% [%releaseversion%]


Thanks for the quick answer, it makes perfect sense, but is there a way to achieve the same result without actually retagging everything, typically via functions such as:

$puts(char,'()$puts(tag,%tag%)$puts(spacer,$strchr($get(tag),$get(char)))
$trim($left($get(tag),$sub($get(spacer),1)))

What I'd like to trim is always at the end of the %album% tag.
For instance, WSH panel Allmusic queries will not return anything if I use the current %album% tag, I am trying to send albumname instead without the content between parenthesis.

Output parentheses in foobar

Reply #7
Why exactly do you NOT want to separate them?

Those things are not part of the ALBUM string to begin with and they are causing problems for you. Why would you want to create a last minute guesswork fix instead of actually fixing your tags? And sure, it should be doable. At the cost of a lot of pointless work which still could give false positives (as the closest approximation of cutting these would be based on whether it has ' (' or ' [' in it, which can occur in a normal album title as well).

Output parentheses in foobar

Reply #8
Why exactly do you NOT want to separate them?

Those things are not part of the ALBUM string to begin with and they are causing problems for you. Why would you want to create a last minute guesswork fix instead of actually fixing your tags? And sure, it should be doable. At the cost of a lot of pointless work which still could give false positives (as the closest approximation of cutting these would be based on whether it has ' (' or ' [' in it, which can occur in a normal album title as well).



Well I guess it depends on your definition of an album, in 95% of cases, the album tag including elements on the release is the most significant way to describe the album and what I prefer to see in the playlists  / album list etc, so adding a %releaseversion% tag everywhere adds complexity in most of my use cases.

In addition to that, many apps do not implement such a tag. Typicallly I am a heavy squeezebox user and I do not want to see my 5 versions of an album as a single one with each track repeated five times. So in the end, retagging everythuing might be the purist approach, but for me the remedy could well be worse than the cure   

That's the reason why I am trying to find a workaround, typically being able to build queries with the album tag stripped of the content within parenthesis whenever there is one. Finding the first parenthesis in the tag and striping what is after this character is a good approximation of what I am looking for, even though it might not work as expected in a few instances.


Output parentheses in foobar

Reply #10
Code: [Select]
$puts(i,$strchr(%album%,'('))$ifgreater($get(i),0,$substr(%album%,0,$sub($get(i),2)),%album%)


that will only work for (  i'm too lazy to add in support for [ as well.

Output parentheses in foobar

Reply #11
is there a way to achieve the same result without actually retagging everything


Oh, you want only to display everything before first occurrence of a certain character?


Yes, to be more specific, I'd like to be able to modify the value returned by the album tag in order to use that in WSH panel or foo run script. For instance, if I have a script that queries Last FM or All music sites, I must build the query based on the original album name "Abbey Road" and not on the actual value of the album tag "Abbey Road (2009 remaster)".

A simple way to achieve that would be to to take the album tag value, and strip it of everything after the first (
So I am looking for a title formatting expression to do that
Still, if anyone has an alternative way to do that, please chime in

Output parentheses in foobar

Reply #12
Code: [Select]
$puts(i,$strchr(%album%,'('))$ifgreater($get(i),0,$substr(%album%,0,$sub($get(i),2)),%album%)


that will only work for (  i'm too lazy to add in support for [ as well.


Thanks a lot for this,

as many of my use cases for this expression would be as input for WSH panel samples you actually designed (thanks a lot for this great work by the way, this is what makes foobar a completely different beast from the other music apps around), I might as well ask the question directly: if I input this formula in the %album% mapping parameter of WSH panel, do you think this is going to work ? I cannot test that right away, sorry...

Output parentheses in foobar

Reply #13
of course it will work. i thought the dialog was clear enough already...



edit: here's an example...

http://i.imgur.com/YkSWNPt.jpg

Output parentheses in foobar

Reply #14
My way would be:
Code: [Select]
$left(%album%,$sub($strstr(%album%,' ('),1))

For () and []:
Code: [Select]
$left($left(%album%,$sub($strstr(%album%,' ('),1)),$sub($strstr(%album%,' ['),1))

I'd warn you though that there are a decent number of albums that contain these by default and will be caught as false positives.

I'm not familiar with squeezebox, but in my experience if a device is incapable of handling custom titleformatting I just won't bother relying on tags altogether (as they usually don't have support for stuff like multivalue genre tags either, to give an example). Instead I generate a folder structure using foobar and copy that over to the device. I primarily listen on PC though and have specific needs unlike most users.

Output parentheses in foobar

Reply #15
My way would be:
Code: [Select]
$left(%album%,$sub($strstr(%album%,' ('),1))

For () and []:
Code: [Select]
$left($left(%album%,$sub($strstr(%album%,' ('),1)),$sub($strstr(%album%,' ['),1))

I'd warn you though that there are a decent number of albums that contain these by default and will be caught as false positives.

I'm not familiar with squeezebox, but in my experience if a device is incapable of handling custom titleformatting I just won't bother relying on tags altogether (as they usually don't have support for stuff like multivalue genre tags either, to give an example). Instead I generate a folder structure using foobar and copy that over to the device. I primarily listen on PC though and have specific needs unlike most users.


Both solutions actually work, sheer bliss   
Thanks a lot to all of you!