Kodi Community Forum

Full Version: Add regexp support to Infolabels
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I plan to extend Infolabels to support regexp. I'm thinking of something like
Code:
$REGEXP[Some.Infolabel, regexp, prefix, postfix]
What do you think, do we need more than that or is this sufficient?
I had a look at the code and think using something like
Code:
$INFO[Some.Infolabel, prefix, postfix, °regexp°]
will be easier to handle. If some one would like to use "°" he has to use $DEGREE like it is with $COMMA for "," now.
The only thing I'm worried about with this is that these things are read/generated every frame, so any additional processing slows things down.

Now, ideally it would be only updated when the info is updated, but this would require a rewrite of the infomanager (not necessarily a bad thing, but there is much to think about).

I guess the degree symbols are to get around the "]" termination issue?

How are you going to choose the resulting group from the regexp?

Cheers,
Jonathan
Quote:The only thing I'm worried about with this is that these things are read/generated every frame, so any additional processing slows things down. Now, ideally it would be only updated when the info is updated, but this would require a rewrite of the infomanager (not necessarily a bad thing, but there is much to think about).
I agree. It will slow down if you make use of regexp in a lot of labels. I have no time for a rewrite - sorry - but yes, that would be the cleanest solution.

I came up with this becuase I need to split the Title-Tag of my mp3 files (extract version of song and featuring artists). At the moment I have my own patch which creates 2 new infolabels for this information, but I thought a more general solution which might be used by other xbmc users too whould be better.

At the moment I'm testing first version of regexp. I'll post a patch when it is done. Then you can have a look at it and discuss if it gets into xbmc or not.
Sounds good.

Let's see what the impact of it is before we start thinking about rewrites Wink

Cheers,
Jonathan
Had to pause yesterday, my wife does not like my new project :p

Function is implemented as follows:
Code:
$INFO[Some.Infolabel, prefix, postfix, regexp]
I added $CLSQRBR as replacement for "]" (like $COMMA for ",").
Works fine so far, I can not notice any performance issues while using it in skin (8 regexp in Home.xml at the same time).
Quote:How are you going to choose the resulting group from the regexp?
I didn't implement this feature at the moment (first group is chosen every time) since I think it is not needed. Or do you see a need for that? If so, I can add it.

I plan to upload the patch after final testing this evening.
No need at all. The first group is fine.
Patch submitted to sf - ID 1576940.