Pira.cz Technical Forum

Magic RDS 4 => Configuration Options and Possibilities => Topic started by: South Coast FM Tech on April 24, 2022, 03:08:59 am

Title: Text Replacing - Remove 'The ' from Artist if radio text text is too long
Post by: South Coast FM Tech on April 24, 2022, 03:08:59 am
Hi Jan,

I'm already using %MATCHEDSTR% to truncate the radio text, as added in V4.0.34.
Change: %REGEXP%^.{0,64}  To: %CLEAR%%MATCHEDSTR%

Sometimes the 'Artist - Title' text is too long & thus the Title gets truncated.

In such cases, I'd like to remove 'The ' from the beginning of the Artist name (if it exists), so that more of the Title is shown.
 
Example: "The Miami Sound Machine - Words Get In The Way This Is A Very Long Title"
Becomes: "Miami Sound Machine - Words Get In The Way This Is A Very Long Title"

Is it possible to use Text Replacing to do this?

thanks, Rod
Title: Re: Text Replacing - Remove 'The ' from Artist if radio text text is too long
Post by: Jan on April 24, 2022, 08:59:02 am
The new implementation of External text sources will bring javascript engine, ideal for tasks like this.
Title: Re: Text Replacing - Remove 'The ' from Artist if radio text text is too long
Post by: South Coast FM Tech on April 25, 2022, 01:20:51 am
"new implementation of External text sources will bring JavaScript engine"

Sounds great! When do you anticipate that will be implemented?

thanks, Rod
Title: Re: Text Replacing - Remove 'The ' from Artist if radio text text is too long
Post by: Jan on May 01, 2022, 04:09:33 pm
OK, we released the JS support in advance.

In version 4.0.38 you may use this JS:

Code: [Select]
var t = '%TEXT%';
var srcName = '%SRC_NAME%';
var remove = 'The ';

if ((srcName == 'Source 1') || (srcName == 'TEST')) {
  if (t.length > 64) {
    if (t.indexOf(remove) == 0) {
      t = t.substring(remove.length);
    }
  }
}

return t;

Only edit the Source name from 'Source 1' to actual name, or entirely remove the srcName condition.
Title: Re: Text Replacing - Remove 'The ' from Artist if radio text text is too long
Post by: South Coast FM Tech on May 03, 2022, 03:05:56 am
Nice one, Jan. Works like a charm.

Seems the Javascript processing before the 'Text Replacing' process.

This really adds a whole new world of flexibility in text processing.

Well done & thanks!