Author Topic: Text Replacing - Remove 'The ' from Artist if radio text text is too long  (Read 3080 times)

South Coast FM Tech

  • Newbie
  • *
  • Posts: 29
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

Jan

  • Hero Member
  • *****
  • Posts: 1057
The new implementation of External text sources will bring javascript engine, ideal for tasks like this.

South Coast FM Tech

  • Newbie
  • *
  • Posts: 29
"new implementation of External text sources will bring JavaScript engine"

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

thanks, Rod

Jan

  • Hero Member
  • *****
  • Posts: 1057
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.

South Coast FM Tech

  • Newbie
  • *
  • Posts: 29
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!