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.
why is this adding square brackets/how do you remove them?
-
- Power User
- Posts: 89
- Joined: 01 Feb 2014, 16:59
Re: why is this adding square brackets/how do you remove the
The brackets define a Groovy "list", and are inherently part of the returned data.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.
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(', ')}
Re: why is this adding square brackets/how do you remove the
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.
If you want something else you need to build the String yourself:
e.g.
Code: Select all
{genres.join(', ')}
Re: why is this adding square brackets/how do you remove the
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.
Re: why is this adding square brackets/how do you remove the
I'm also having issues with:
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:
But now it says ScriptException: java.lang.NullPointerException: Cannot invoke method to replaceAll() on null object.
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)}}
Okay, I think I might have it working by adding:
Code: Select all
.replaceAll("\\[|\\]", "")