Kodi Community Forum

Full Version: String.Contains brackets "[" or parentheses "("
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Does anyone know a way to do a string.contains or string.startswith and check for a string with parentheses

Basically, I want to check if a property contains "ActivateWindow(music"
for instance:
Code:
condition="Skin.StartsWith(ListItem.Property(path),ActivateWindow(music)"

Is this at all possible? I've try escaping \ and wrapping it in quotes "" and also urlencoding %28 but nothing I've tried works.
Code:
condition="String.StartsWith(ListItem.Property(path),ActivateWindow(music))"

Wink

Untested but your example had a missing parentheses and used Skin instead of String.

If that doesn't work you can split it into multiple conditions like
Code:
String.StartsWith(ListItem.Property(path),ActivateWindow) + String.Contains(ListItem.Property(path),music)

Edit:
Sorry, it's not a missing parentheses, but yeah it does not work. You have to split the condition.
(2019-03-19, 15:08)sualfred Wrote: [ -> ]
Code:
condition="String.StartsWith(ListItem.Property(path),ActivateWindow(music))"

Wink

Untested but your example had a missing parentheses and used Skin instead of String.

If that doesn't work you can split it into multiple conditions like
Code:
String.StartsWith(ListItem.Property(path),ActivateWindow) + String.Contains(ListItem.Property(path),music)

Edit:
Sorry, it's not a missing parentheses, but yeah it does not work. You have to split the condition.
Yeah that was just a typo in the post. I had used String.startswith in my code.

The missing parenthesis is on purpose because I'm looking for things like ActivateWindow(music,musicdb://albums,return) and so on - basically trying to get content target from path.

Splitting it doesn't work because then I get the wrong target for things like musicvideos
I know hacky, but that will work for that case:
Code:
String.StartsWith(ListItem.Property(path),ActivateWindow) + String.Contains(ListItem.Property(path),music) + !String.Contains(ListItem.Property(path),musicvideo)

Or use the library node, which is what I do in a few cases:
Code:
String.StartsWith(ListItem.Property(path),ActivateWindow) + [String.Contains(ListItem.Property(path),musicdb://) | String.Contains(ListItem.Property(path),library://music)]
I've been using it like so:
Code:
<expression name="IsKnownMenuEntryPath">String.IsEqual(ListItem.Property(path), ActivateWindow(home,return)) | String.IsEqual(ListItem.Property(path), ActivateWindow(1110,return)) | String.IsEqual(ListItem.Property(path), ActivateWindow(1111,return)) | String.IsEqual(ListItem.Property(path), ActivateWindow(1112,return)) | String.IsEqual(ListItem.Property(path), ActivateWindow(1113,return)) | String.IsEqual(ListItem.Property(path), ActivateWindow(1114,return)) | String.IsEqual(ListItem.Property(path), ActivateWindow(1115,return)) | String.IsEqual(ListItem.Property(path), ActivateWindow(1106,return))</expression>

Since kodi didn't receive the contains ones very well....having 3 contains checks for each sounds like a lot of calculation time... :|
(2019-03-19, 16:47)sualfred Wrote: [ -> ]Or use the library node, which is what I do in a few cases:
Code:
String.StartsWith(ListItem.Property(path),ActivateWindow) + [String.Contains(ListItem.Property(path),musicdb://) | String.Contains(ListItem.Property(path),library://music)]

Yeah, that's my current implementation:
Code:
[String.Contains(Container(211).ListItem.Property(path),musicdb://) | String.Contains(Container(211).ListItem.Property(path),library://music) | String.Contains(Container(211).ListItem.Property(path),sources://music) | String.Contains(Container(211).ListItem.Property(path),plugin://plugin.audio)]

My main problem is how to handle music playlists because there is nothing that identifies them other than "ActivateWindow(Music"