Page 1 of 1

Having troubles with format scripting.

Posted: 24 Jun 2013, 15:00
by NeonLightning
i know i can run groovy stuff through the episode format and this

Code: Select all

F:\TV\{c{info.certification} ?: "No Known Rating"}\{n.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’ʻ]/, "'").lowerTrail().replacePart(', Edition $1')}\Season {s.pad(2)}\E{e.pad(2)} - {t.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’ʻ]/, "'").lowerTrail().replacePart(', Part $1')}
is what i have sofar. next thing i'm trying to do is add exceptions to force it to think certain shows have different certifications. like i don't have an objection to my kids watching "Never Ever Do This At Home" but its in the TV-MA folder and i don't want them going through there or "D-Day As It Happens" being in TV-Y7 and i'd rather it be in TV-PG. plus it would help me to go through the "No Known Rating" folder.

any suggestions on how i'd do so or if its possible?

i'm thinking possibly best using a csv file

Code: Select all

read Name;Certification
get {info.certification}
get {n}
check if {n} == Name
if it is replace {info.certification}
if not add to csv with Name;certification
??
not sure how i'd do so i've never used csv i tend to just work with one value at a time.
but my biggest hurdling block is understanding how to change a value that was already called i'm guessing .After
i've tried doing some if then else in the format but only somewhat got it working on my attempts.

Re: Having troubles with format scripting.

Posted: 24 Jun 2013, 15:46
by NeonLightning

Code: Select all

F:\TV\{c{info.certification} ?({c(n=="Amercian Pickers") ?: info.certification.match('TV-PG':'TV-G')}): "No Known Rating"}\{n.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’ʻ]/, "'").lowerTrail().replacePart(', Part $1')}\Season {s.pad(2)}\E{e.pad(2)} - {t.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’ʻ]/, "'").lowerTrail().replacePart(', Part $1')}
i end up with

Code: Select all

Script142$_run_closure2@475e0f30
where it should say the certification

Re: Having troubles with format scripting.

Posted: 24 Jun 2013, 16:25
by rednoah
With that much custom logic it's gonna get messy either way.

I'd use =~ regex so you can easily add more shows via a|b|c|d regex syntax. And then with my custom match function you can have multiple mappings. It's kinda like switch/case but you pass in the mappings like below:

Code: Select all

{def pg = info.certification; (n =~ 'Amercian Pickers|Dexter' ? pg.match('TV-14':'TV-G', 'TV-PG':'TV-G', '':'No Rating') : null) ?: pg}

Re: Having troubles with format scripting.

Posted: 24 Jun 2013, 16:32
by NeonLightning

Code: Select all

F:\TV\{if ({n}=='Amercian/ Pickers') {"TV-G"}else if ({info.certification}==""){"No Known Rating"}else {info.certification}}\{n.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’ʻ]/, "'").lowerTrail().replacePart(', Part $1')}\Season {s.pad(2)}\E{e.pad(2)} - {t.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’ʻ]/, "'").lowerTrail().replacePart(', Part $1')}
latest attempt
doesn't seem to do anything other than make the "No Known Rating" be blank now.. atleast this one doesn't error out?



i tried

Code: Select all

{def pg = info.certification; (n =~ 'Amercian Pickers|Dexter' ? pg.match('TV-14':'TV-G', 'TV-PG':'TV-G', '':'No Rating') : null) ?: pg}
and its doin the same thing as my last attempt as in all it seems to have done is borked the "no known Rating.

Re: Having troubles with format scripting.

Posted: 24 Jun 2013, 16:39
by rednoah
This is the test for empty string like in your code:

Code: Select all

{''.match('TV-14':'TV-G', 'TV-PG':'TV-G', '':'No Rating')}
This is the test for null value:

Code: Select all

{null.match('TV-14':'TV-G', 'TV-PG':'TV-G', null:'No Rating')}
I think certification will be null and not empty string if undefined, so use null-check instead.

Re: Having troubles with format scripting.

Posted: 24 Jun 2013, 16:54
by NeonLightning
not sure where to put that null.match but sofar as i said its not even parsing the american pickers one as anything other than what info.certification shows. i tried removing the last null and adding the : to after the ? but that just seems to make any pg as g and any 14 as g

Re: Having troubles with format scripting.

Posted: 24 Jun 2013, 17:06
by rednoah
I just showed you my test cases. You can work with specific values and see what happens. Just test things step by step like this.

This works with the default sample data:

Code: Select all

{n} {certification} => {def pg = info.certification; (n =~ 'Firefly' ? pg.match('TV-14':'TV-G', 'TV-PG':'TV-G', null:'No Rating') : null) ?: pg}
It's gonna evaluate to Firefly TV-14 => TV-G.



Now lets see what happens if certification is null:

Code: Select all

{n} {certification} => {def pg = null; (n =~ 'Firefly' ? pg.match('TV-14':'TV-G', 'TV-PG':'TV-G', null:'No Rating') : null) ?: pg}
Output: Firefly TV-14 => No Rating


Not exactly sure what logic you want but you can easily modify the first sample for any kinda of replacement logic.

Re: Having troubles with format scripting.

Posted: 24 Jun 2013, 17:35
by NeonLightning
issue i see is inability to have two shows with same certification be parsed as two others.. eg both "D-Day As It Happens" and "Avatar The Last Airbender" are normally TV-7 but i want Avatar to goto TV-G and D-Day to goto TV-PG.

also from what i can tell
{(n =~ 'Firefly' ? info.certification.match('TV-14':'TV-G'): null) ?: info.certification}
does pretty much the same thing as your suggestion.... i'm guessing i'm totally off base since only languages i know anything about is qbasic and a little bash...

btw sorry to be such a pain. reading your help on other posts has been rather helpful to me sofar

Re: Having troubles with format scripting.

Posted: 24 Jun 2013, 17:58
by NeonLightning
GOT IT!
using csv. sadly don't know how to use the append command or i'd have it write any new ones to the csv.

Code: Select all

{def a; new File('F:/TV/names.csv').splitEachLine(';'){ if (n == it[0]) a = it[1]}; a ?: {c{info.certification} ?: "No Known Rating"}}

Re: Having troubles with format scripting.

Posted: 24 Jun 2013, 19:29
by NeonLightning
grr..... closed it and reopened it now i'm getting script run errors again...

Re: Having troubles with format scripting.

Posted: 25 Jun 2013, 01:38
by rednoah
So you really just wanna hardcode the PG rating for certain shows? That logic is pretty much the same as forcing a series name.

Code: Select all

{def a; new File('D:/pg.csv').splitEachLine(';'){ if (n == it[0]) a = it[1]}; a ?: info.certification ?: "No Known Rating"}
Where pg.csv would look like this:

Code: Select all

Firefly;TV-PG

Re: Having troubles with format scripting.

Posted: 25 Jun 2013, 02:43
by rednoah
With r1649 I added some convenience functions for these kinda use-cases:

Code: Select all

{csv('D:/pg.csv').get(n) ?: info.certification ?: 'No Rating'}
Didn't make it into the v3.61 release though.

Re: Having troubles with format scripting.

Posted: 25 Jun 2013, 03:04
by NeonLightning
really glad you did so but i'm not quite following how its used.

Re: Having troubles with format scripting.

Posted: 25 Jun 2013, 04:06
by NeonLightning
oh ok n is getting pulled as a label basically and the first part pulls whatever n is labelling and the rest is just else ifs

Re: Having troubles with format scripting.

Posted: 26 Jun 2013, 05:44
by NeonLightning
rednoah wrote:With r1649 I added some convenience functions for these kinda use-cases:

Code: Select all

{csv('D:/pg.csv').get(n) ?: info.certification ?: 'No Rating'}
Didn't make it into the v3.61 release though.
just tried it and it seems to pull them but its not naming them unless they have a rating. its not handling no rating properly just giving me a blank(aka sending them to F:\TV\ instead of F:\No Known Rating\

Re: Having troubles with format scripting.

Posted: 26 Jun 2013, 06:22
by NeonLightning

Code: Select all

F:\TV\{csv('F:/TV/names.csv').get(n) ?: c{info.certification} ?: "No Known Rating"}\{n.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’ʻ]/, "'").lowerTrail().replacePart(', Part $1')}\Season {s.pad(2)}\E{e.pad(2)} - {t.replaceAll(/[!?.]+$/).replaceAll(/[`´‘’ʻ]/, "'").lowerTrail().replacePart(', Part $1')} 
this seems to work