Author Topic: Different info in panel displays based on genre or other tag information  (Read 2090 times)

Pickles7853

  • Full Member
  • ***
  • Posts: 149
Thanks hiccup!  Much better than my poor attempt.
I tested the expressions for a while and I think I found a couple of corner cases where the first RegEx might fail.

(Unknown.*?(?=\s-\s|$))
What is the purpose of the anything expression highlighted in red.  By definition, nothing can be in between the tags and the dashes (besides \s).  So if the tag is empty the output should be "Unknown - " or "Unknown$".  This should take care of one corner case: "Breaking Benjamin - Unknown Soldier".

I am not really sure how to handle the second one though.  "Crossfade - The Unknown"

hiccup

  • Hero Member
  • *****
  • Posts: 9107
(Unknown.*?(?=\s-\s|$))
What is the purpose of the anything expression highlighted in red.
The question mark here makes the expression 'lazy'.
https://regex101.com/r/N3em2X/1


Quote from: Pickles7853
By definition, nothing can be in between the tags and the dashes (besides \s).  So if the tag is empty the output should be "Unknown - " or "Unknown$".  This should take care of one corner case: "Breaking Benjamin - Unknown Soldier".
I am not really sure how to handle the second one though.  "Crossfade - The Unknown"
Good point.
I'll see if I can think of something that addresses such cases. (not today though ;-)
Last Edit: June 03, 2025, 08:50:14 PM by hiccup

Pickles7853

  • Full Member
  • ***
  • Posts: 149
That's OK.  I don't mind jumping in again.
Since there are only four possible positions for an unknown in the worse case, it was easier just to brute force it.
EG: I tested all possible combinations of Unknown for "X - X - X - X".

$Trim($RxReplace($RxReplace($If(<Album Library>=1,<AlbLib1>,$If(<Album Library>=2,<AlbLib2>,$If(<Album Library>=3,<AlbLib3>,$If(<Album Library>=4,<AlbLib4>,)))),"(^Unknown(?= - )|(?<= - )Unknown(?= - )|(?<= - )Unknown$)",""),"((?<!\w\s)-\s|\s-(?!\s\w)|(-(?=\s-)))",""))
Last Edit: June 03, 2025, 11:01:20 PM by Pickles7853

tjinc

  • Sr. Member
  • ****
  • Posts: 822
I think you have made an incorrect assumption here:
Quote
if the tag is empty the output should be "Unknown - " or "Unknown$"
When a tag is empty, the output in a virtual tag is "Unknown Tagname" (not just "Unknown").


The example of "Unknown Soldier" is going to be a problem here as the string "Unknown XXX" is exactly what we are looking to delete - I don't have a solution for that.

The example "The Unknown" is easier:
Code
$RxReplace($RxReplace(<Expression>,"((?<=\s-\s)|^)Unknown.+?(\s-\s|$)",""),"\s-\s$","")
(I've just used <Expression> as the string we are parsing to make it easier to read.)

tjinc

  • Sr. Member
  • ****
  • Posts: 822
I also feel that we should apologise to Maxo for hijacking their thread and turning it into a Virtual tag/RegEx lovefest.

@Maxo - I hope you have made some progress in finding a suitable way forward for your setup.

Pickles7853

  • Full Member
  • ***
  • Posts: 149
Oh!  That's what the .*? was for in hiccups code.  I see.  Yeah that is going to be a problem...
None of code I posted above is worth anything then.

I do not think <title> is one of the fields he was interested in so maybe hiccups original code would be OK?
Not likely to run into "Unknown" as the tag text from <composer>, <sound team>, or any of the other tags he is using.

@ note: Also sorry for hijacking!  Just trying to make it better
He has not responded to any of this.  I am starting to wonder if we are just spinning our own wheels for no reason.

@ tjinc: Well there is good news in all this.  The issue is cropping up because of the RegEx.  If needed we have the behemoth macro as a fallback as it is immune to this particular problem.
Last Edit: June 03, 2025, 11:18:54 PM by Pickles7853

hiccup

  • Hero Member
  • *****
  • Posts: 9107
I have modified the virtual tag's regex so that album or song titles that have words before 'Unknown' will not get removed.
(and made some improvement on how it handles dashes and spaces)

I haven't found an easy way to also accommodate for titles that start with 'Unknown ...'.
I think it can be done, but it will be difficult and time-consuming, and will probably also complicate things for the user.

It's probably also very rare that a user will be using 'Album' or 'Title' tags for this, and has albums or songs that begin with 'Unknown ...'.
(my own library is pretty large and varied, and it has zero of those)
edit, I made a mistake when searching for those, and I see I actually have 1 album and some 8 tracks that begin with 'Unknown'.

So I'm going to leave it at this, and the solution that I posted here will remain my proposed solution for this challenge.
(unless somebody finds an important flaw or oversight)
Last Edit: June 05, 2025, 07:54:15 AM by hiccup