Author Topic: MusicBee functions for virtual tags cheatsheet  (Read 28760 times)

boroda

  • Sr. Member
  • ****
  • Posts: 4595
Code
$DateCreated("<URL>")

$TagContainsAnyString("<URL>",tag_name,string1|string2|etc.)

$TagContainsAllStrings("<URL>",tag_name,string1|string2|etc.)

quotes allow to take into account parenthesis in URL

quotes don't work, they must be removed, all works just fine without quotes, no matter what characters URL contains.

hiccup

  • Sr. Member
  • ****
  • Posts: 7781
$TagContainsAnyString(<URL>,tag_name,string1|string2|etc.)

… no matter what characters URL contains.
I don't think I understand the construction of that function.
Why is <URL> needed?
And should it be kept exactly like that, or could it be replaced with another tag?

Wouldn't something like this do the same and be more consistent with other functions?:
$TagContainsAnyString(<tag>,string1|string2|etc.)

boroda

  • Sr. Member
  • ****
  • Posts: 4595
you are quite right, of course it's better. unfortunately some tags cannot be used that way, e.g. <Lyrics>. tag tools plugin supports for more number of tags (you can see the full list of tags in any plugin command, e.g. 'copy tag') than mb through the usage of <Tag name> construction.

hiccup

  • Sr. Member
  • ****
  • Posts: 7781
you are quite right, of course it's better. unfortunately…
O.k.
I updated the sheet and the explanations by adding these new functions.
I think it's looking good, but let me know if you have any comment.

hiccup

  • Sr. Member
  • ****
  • Posts: 7781
you are quite right, of course it's better. unfortunately some tags cannot be used that way, e.g. <Lyrics>. tag tools plugin supports for more number of tags (you can see the full list of tags in any plugin command, e.g. 'copy tag') than mb through the usage of <Tag name> construction.
Just another thought:

Perhaps change these functions from:
$TagContainsAnyString and $TagContainsAllStrings
to simply:
$ContainsAny and $ContainsAll

That would line up more nicely with the existing $Contains function?

boroda

  • Sr. Member
  • ****
  • Posts: 4595
i wanted to emphasize that these 2 functions search for strings in a given tag (and in tag only).  

mb native function $Contains can be used not only for tags, these are still correct usage: $Contains(the door open,<Artist>) or $Contains(my sample text,sample), though the latter usage (with only static text) is useless.

hiccup

  • Sr. Member
  • ****
  • Posts: 7781
mb native function $Contains can be used not only for tags, these are still correct usage: $Contains(the door open,<Artist>) or $Contains(my sample text,sample), though the latter usage (with only static text) is useless.
Hmm, I'm starting to regret asking about this ;-)
So where in my sheet it says:  $Contains(<field>,search-value)
<field> is not strictly correct, since the <> indicates an existing tag should be used, while it could also be a string (text).

And in the two new functions you recently provided, the actual tag to be used must not be embraced with '< >'

I'll probably need to reconsider how I use, name and explain entities as 'field', 'string' '< >' etc. in the sheet and the explanations.
I'm guessing it won't be easy for a newBee (or myself in a few weeks) to understand or remember the exact requirements and possibilities of all this.
Last Edit: August 27, 2022, 07:58:07 PM by hiccup

boroda

  • Sr. Member
  • ****
  • Posts: 4595
i'm not 100% sure, it's better to ask Steven about this, but i suppose that template editor just suggests the most important function templates. but (probably) you can use everywhere literal value instead of <Tag name> and, vice versa, you can use everywhere <Tag name> instead of literal value. BUT! i haven't checked this thoroughly.

boroda

  • Sr. Member
  • ****
  • Posts: 4595
again, i'm not 100% sure, but i think that using quotes allow place commas, angle brackets and parenthesis inside literal values. without quotes commas are treated as function parameter separator, angle brackets are treated as tag names boundaries and parenthesis are treated as function parameter boundaries.
Last Edit: August 27, 2022, 07:19:38 PM by boroda

hiccup

  • Sr. Member
  • ****
  • Posts: 7781
again, i'm not 100% sure, but i think that…
I'll have to chew a bit on that to try to fully understand. (not being a coder, and not being well-versed in the lingo)
And, perhaps Steven can confirm or contribute to this, so I can then try to mould all the info into some texts and explanations that mortals like me will be able to understand ;-)
Last Edit: August 27, 2022, 07:44:03 PM by hiccup

boroda

  • Sr. Member
  • ****
  • Posts: 4595
again, i'm not 100% sure, but i think that using quotes allow place commas, angle brackets and parenthesis inside literal values. without quotes commas are treated as function parameter separator, angle brackets are treated as tag names boundaries and parenthesis are treated as function parameter boundaries.
no, it's not very difficult to understand, i mean that: $Contains(String1,String2,<Title>) probably can't be correctly parsed because it's treated as function with 3 parameters, but $Contains("String1,String2",<Title>) probably will be parsed correctly as function with 2 parameters: 1st parameter - literal "String1,String2" and 2nd parameter - tag <Title>. and so on.

hiccup

  • Sr. Member
  • ****
  • Posts: 7781
no, it's not very difficult to understand, i mean that: $Contains(String1,String2,<Title>) probably can't be correctly parsed because it's treated as function with 3 parameters, but $Contains("String1,String2",<Title>) probably will be parsed correctly as function with 2 parameters: 1st parameter - literal "String1,String2" and 2nd parameter - tag <Title>. and so on.
Haha, you are hurting my brain on this Saturday night.
You mention: "String1,String2"
Isn't that factually one string?
I mean, the comma there triggers no special treatment? Or does it?

boroda

  • Sr. Member
  • ****
  • Posts: 4595
You mention: "String1,String2"
Isn't that factually one string?
I mean, the comma there triggers no special treatment?
YES! that's what i mean. and quotes probably will be omitted, when passing to the function. it seems that it's safe to use something like $Contains("<Title>,text1)",<Title>), where:

<Title>,text1) is 1st literal parameter

second <Title> is 2nd paremeter, tag name.

but i haven't checked this for all native functions, only for some functions, and i don't remember, which functions i've checked.

hiccup

  • Sr. Member
  • ****
  • Posts: 7781
it seems that it's safe to use something like $Contains("<Title>,text1)",<Title>), where:
<Title>,text1) is 1st literal parameter
second <Title> is 2nd paremeter, tag name.
Huh, no matching brackets there? Is that intentional for your example?

boroda

  • Sr. Member
  • ****
  • Posts: 4595
the closing bracket inside quotes is a part of 1st parameter (part of string), brackets inside quoted literal may not be balanced, second closing bracket is the end of function parameters. maybe it's allowed to use balanced brackets inside literal without quotes.

all this must be carefully checked or confirmed by Steven.