Help Cleaning Up Scheme

All about user-defined episode / movie format expressions
Post Reply
cyberdoggy
Posts: 28
Joined: 03 Sep 2016, 21:27

Help Cleaning Up Scheme

Post by cyberdoggy »

I gathered bits and pieces of various schemes throughout these threads and I came up with a pretty darn close to what I am using scheme. What I ask is if anybody has some spare time if they could clean this up and check for errors since I only understand a little of the code. Thanks.

An example of the output I am looking to have that basically works right now. I just want to know if the code has unnecessary stuff in it or errors:
H:/Movies/Conjuring Collection, The\Conjuring 2, The (2016) [R] [BluRay] /The.Conjuring.2.2016.1080p.10bit.BluRay.HEVC.HEVC.x265.AAC.7.1CH- PSA

Code: Select all

H:/Movies/{collection.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/).replaceFirst(/^(?i)(Collection of the)\s(.+)/, /$2 Collection/).replaceAll(/Saga Collection/, "Saga").replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ")}\{norm = {it.upperInitial().lowerTrail().replaceTrailingBrackets().replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ").replaceAll(/\b[IiVvXx]+\b/, { it.upper() }).replaceAll(/\b[0-9](?i:th|nd|rd)\b/, { it.lower() }).replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/)}; norm(n)}{if (norm(n) != norm(primaryTitle)) ' ('+norm(primaryTitle)+')'}{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""} ({y}) {[''+any{certification}{imdb.certification}.replaceAll(/^\d+$/, 'PG-$0')]} {[''+source+'']} /{norm={it.upperInitial().lowerTrail().replaceTrailingBrackets().replaceAll(/\u0022/, '\'').replaceAll(/[:|]/, '.').replaceAll(/\?/, '!').replaceAll(/[*\s\.,]+/, '.').replaceAll(/\b[IiVvXx]+\b/, { it.upper() }).replaceAll(/[0-9](th|nd|rd)/, { it.lower() })};isLatin = {java.text.Normalizer.normalize(it, java.text.Normalizer.Form.NFD).replaceAll(/\p{InCombiningDiacriticalMarks}+/, '') ==~ /^\p{InBasicLatin}+$/}; isLatin(info.OriginalName) ? norm(info.OriginalName) : norm(primaryTitle) }{if(isLatin(info.OriginalName) && info.OriginalName != primaryTitle && !(info.SpokenLanguages[0] ==~ /(sv|da|no)/)) '.'+ norm(primaryTitle) }{fn.contains('3D') || fn.contains('3-D') ? '.3D':''}{'.'+fn.replace(/(?i)\.DC\./, '.directors.cut.').replaceAll(/director\'?s|theatrical|ultimate/,'$0.Cut').matchAll(/UNCENSORED|UNRATED|REMASTERED|EXTENDED|UNCUT|DIRECTORS.CUT|THEATRICAL.CUT|ULTIMATE.CUT|FINAL.CUT|SPECIAL.EDITION\'?DIRECTORS.CUT|THEATRICAL.CUT|ULTIMATE.CUT|FINAL.CUT|SPECIAL.EDITION/).sort().join('.')}{'.'+fn.matchAll(/PROPER|REPACK/)*.upper().sort().join('.')}.{y}{'.'+vf}.{video.bitdepth.join('-') -null}{'bit'}{'.'+source}{'.'+vc.replace('Microsoft', 'VC-1').replace ('AVC','H.264') .replace ('x264','H.264').replace ('HEVC','HEVC.x265') .replace ('x265','HEVC.x265')}{'.'+ac.replace('MPEG Audio', 'MP3')}{audio.FormatProfile =~ /MA Core/ ? '-HD.MA' : ''}{audio.FormatProfile =~ /ES/ ? '-ES' : ''}{audio.FormatProfile =~ /Pro/ ? '-Pro' : ''}{'.'+af.replace ('8ch', '7.1CH').replace('7ch', '6.1CH').replace('6ch', '5.1CH').replace('3ch', '2.1CH').replace('2ch','2.0CH').replace('1ch','1.0CH')}{def g = c{group}; def m = c{fn.match(/(?:(?<=[-])[a-z0-9]+$)|(?:^[a-z0-9]+(?=[-]))/)}; if(g==null && m!=null) return '-'+m.replace(/^tpz$/, 'TOPAZ'); if(g!=null && m!=null && m.lower()!=g.lower()) return '-'+m.replace(/^tpz$/, 'TOPAZ'); if(g!=null) return '-'+g;}- {any{"$group"}{fn.match(/_.+?$/)}{'NA'}}
Last edited by cyberdoggy on 25 Sep 2016, 15:19, edited 1 time in total.
kim
Power User
Posts: 1046
Joined: 15 May 2014, 16:17

Re: Help Cleaning Up Scheme

Post by kim »

start by asking yourself or telling people, how do I want the result to look like...

then you can build a better script
User avatar
rednoah
The Source
Posts: 19128
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help Cleaning Up Scheme

Post by rednoah »

I'd start with simple components that you can make sense of individually.

1.
cyberdoggy wrote: Conjuring Collection, The

Code: Select all

{collection.sortName('$2, $1')}
2.
cyberdoggy wrote: Conjuring 2, The (2016) [R] [BluRay]

Code: Select all

{n.sortName('$2, $1')} ({y}) [{rating}] [{source}]
3.
cyberdoggy wrote: The.Conjuring.2.2016.1080p.10bit.BluRay.x265.AAC.7.1CH-PSA

Code: Select all

{allOf{n}{y}{vf}{bitdepth+'bit'}{source}{vc}{ac}{channels}{'-'+group}.join('.').space('.')}
:idea: Please read the FAQ and How to Request Help.
cyberdoggy
Posts: 28
Joined: 03 Sep 2016, 21:27

Re: Help Cleaning Up Scheme

Post by cyberdoggy »

Thanks rednoah I will play with it!
Post Reply