why is this adding square brackets/how do you remove them?

All about user-defined episode / movie format expressions
Post Reply
DevXen
Power User
Posts: 132
Joined: 12 Oct 2014, 21:15

why is this adding square brackets/how do you remove them?

Post by DevXen »

A few things i've noticed have Square brakcets added like: {info.SpokenLanguages.displayLanguage}

which shows as: [English]

also {genres} shows: [Drama], [Drama, Fantasy], etc

I have tried several things for the last couple hours, from: .replace(), to .replaceAll(), to .replaceTrailingBrackets(). etc

I just can't find anything that will work.
DavidRTurner
Power User
Posts: 85
Joined: 01 Feb 2014, 16:59

Re: why is this adding square brackets/how do you remove the

Post by DavidRTurner »

DevXen wrote:A few things i've noticed have Square brakcets added like: {info.SpokenLanguages.displayLanguage}

which shows as: [English]

also {genres} shows: [Drama], [Drama, Fantasy], etc

I have tried several things for the last couple hours, from: .replace(), to .replaceAll(), to .replaceTrailingBrackets(). etc

I just can't find anything that will work.
The brackets define a Groovy "list", and are inherently part of the returned data.
They're not really 'there', so you can't replace them as such.

I found this snippet, which still leaves all the list items, but loses the brackets:

Code: Select all

{genres.collect { i -> "$i" }.join(', ')}
User avatar
rednoah
The Source
Posts: 19011
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: why is this adding square brackets/how do you remove the

Post by rednoah »

What you're seeing is the Default String Representation of that List Object.

If you want something else you need to build the String yourself:

e.g.

Code: Select all

{genres.join(', ')}
:idea: Please read the FAQ and How to Request Help.
DevXen
Power User
Posts: 132
Joined: 12 Oct 2014, 21:15

Re: why is this adding square brackets/how do you remove the

Post by DevXen »

rednoah wrote:What you're seeing is the Default String Representation of that List Object.

If you want something else you need to build the String yourself:

e.g.

Code: Select all

{genres.join(', ')}

ok. thank you.
is there any way to use .displayLanguage with audios.language?

I'm trying to do an any{}{} that checks the encoded language, and if that isn't there, then it'll check the info.SpokenLanguage
Where this works: (info.SpokenLanguages.displayLanguage)

This doesn't:
audios.language.displayLanguage
{audios.language.displayLanguage.join(', ')}
{audios.language..join(', ').displayLanguage}

or does displayLanguage ONLY work with SpokenLanguage?
if that's the case, i'm sure, i could setup a locale csv file to check to get the language names.

Edit: I did end up setting up a locale csv file to match the correct language names
Last edited by DevXen on 05 Feb 2015, 05:12, edited 1 time in total.
DevXen
Power User
Posts: 132
Joined: 12 Oct 2014, 21:15

Re: why is this adding square brackets/how do you remove the

Post by DevXen »

I'm also having issues with:

Code: Select all

{def map=[/rifftrax/:'RiffTrax','Mini-Series':'Mini']; file.path.lower().replaceAll(/[\W]/, "").matchAll(/monstervision|rifftrax/).findResults{ map[it] }.sort{ map.values().indexOf(it)}}
showing the [] when the match isn't found. and i haven't been able to get it to stop. i did try the .join(',') but that just caused it to fail all together.

Okay, I think I might have it working by adding:

Code: Select all

.replaceAll("\\[|\\]", "")
But now it says ScriptException: java.lang.NullPointerException: Cannot invoke method to replaceAll() on null object.
Post Reply