Movie format with collections issue

All about user-defined episode / movie / file name format expressions
Post Reply
drauku
Posts: 8
Joined: 19 Aug 2016, 07:17

Movie format with collections issue

Post by drauku »

FileBot is fantastic, and has already saved me a bunch of time. I successfully renamed my ripped TV Shows library, and have moved onto my ripped movies library. @rednoah you have come up with an amazing tool that is supported by what seems to be a great community. Thank you so much!

I have been working on a comprehensive naming scheme for a couple weeks now, and have hit a wall. I got 90% of it working, but cannot for the life of me figure out how to incorporate collections in the way that I would like, listing movies inside a collection in order of the year released.

I want the end product inside a collection to look thusly (differences in orange):
  • M:\Videos\Movies\Avatar Collection\[2009] Avatar [PG-13]\Avatar [2009] - [PG-13][161 Min][720p x264 AC3 5.1ch].mkv
And a movie that is not part of a collection to look like this:
  • M:\Videos\Movies\Avatar [2009][PG-13]\Avatar [2009] - [PG-13][161 Min][720p x264 AC3 5.1ch].mkv
I have stripped the renaming code down to the most basic form I can, and I cannot get it to spit out the inverted year+name and name+year depending on if the movie is part of a collection or not.

The below never works with a collection, and only renames the movies to the {ny} format in my directory structure:

Code: Select all

M:/Videos/Movies/{any {collection/{y} {n}/{ny}} {ny/ny}}
The below gets the folders correct, but does not have the year before the name like I want it to:

Code: Select all

M:/Videos/Movies/{any {collection/ny/ny} {ny/ny}}
I have tried a more complicated version, but keep getting groovy errors:
Image
and:
Image

My full code is here, and I'm sure contains many errors inside the collection code (it works well when I take that portion out):

Code: Select all

{any
{if (file.path.lower().matchAll(/(3d|half|full|h?sbs|f?sbs|(?i)(?<=^|[^a-z])hou(?=$|[^a-z])|(?i)(?<=^|[^a-z])fou(?=$|[^a-z])|f.ou|anaglyth)(?:.sbs|(?i)(?<=^|[^a-z])cat(?=$|[^a-z]))?/))
{'M:/Videos/Movies-3D]/'}}
{'M:/Videos/Movies/'}}
{if (collection) 
{{collection.replaceFirst(/^(?i)(The)\s(.+)/, /$2, $1/).replaceFirst(/^(?i)(Collection of the)\s(.+)/, /$2 Collection/).replaceAll(/Saga Collection/, "Saga").replaceAll(/[`´‘’ʻ""“”]/, "'").replaceAll(/[:|]/, " - ").replaceAll(/[?]/, "!").replaceAll(/[*\s]+/, " ")}/
{if (y) {' ['+y +']'}} 
{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':""} 
{' '+any{"[$certification]"}{"["+$imdb.certification+"]" }.replaceAll('N A','').replaceAll(/^ \d+$/, 'PG-$0')}/}
{{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':""} 
{if (y) {' ['+y +']'}} 
{' '+any{"[$certification]"}{"["+$imdb.certification+"]" }.replaceAll('N A','').replaceAll(/^ \d+$/, 'PG-$0')}/}} 
{(n)} 
{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""} 
{fn.contains('Extended') || fn.contains('EXTENDED') || fn.contains('extended.cut') ? ' (Extended)' : fn.contains('Special Edition') || fn.contains('SPECIAL EDITION') || fn.contains('SPECIAL.EDITION') ? ' (Special Edition)' : fn.contains('Unrated') || fn.contains('UNRATED') ? ' (Unrated)' : fn.contains('Uncensored') || fn.contains('UNCENSORED') ? ' (Uncensored)' : fn.contains('Remastered') || fn.contains('REMASTERED') ? ' (Remastered)':""} 
{if (y) {' ['+y +']'}} 
{" Part $pi"} - 
{any{"[$certification]"}{"["+$imdb.certification+"]" }.replaceAll('N A','').replaceAll(/^ \d+$/, 'PG-$0')} 
{"[$minutes Min]"}
{"[$vf $vc $ac "+af.replace('8ch', '7.1ch').replace('7ch', '6.1ch').replace('6ch', '5.1ch').replace('3ch', '2.1ch').replace('2ch','2.0ch')+"]"}
.{cf}
gives this error:
Image

Here is my working format, but without the modified collection parameters so movies inside a collection are listed by year:

Code: Select all

M:/Videos/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':""} 
{if (y) {' ['+y +']'}}
{' '+any{"[$certification]"}{"["+$imdb.certification+"]" }.replaceAll('N A','NR').replaceAll(/^ \d+$/, 'PG-$0')}/
{(n)}
{fn.contains('3D') || fn.contains('3-D') ? ' '+'3D':""}
{fn.contains('Extended') || fn.contains('EXTENDED') || fn.contains('extended.cut') ? ' (Extended)' : fn.contains('Special Edition') || fn.contains('SPECIAL EDITION') || fn.contains('SPECIAL.EDITION') ? ' (Special Edition)' : fn.contains('Unrated') || fn.contains('UNRATED') ? ' (Unrated)' : fn.contains('Uncensored') || fn.contains('UNCENSORED') ? ' (Uncensored)' : fn.contains('Remastered') || fn.contains('REMASTERED') ? ' (Remastered)':""}
{if (y) {' ['+y +']'}}
{" (Part ${pi.pad(2)})"} -
{' '+any{"[$certification]"}{"["+$imdb.certification+"]" }.replaceAll('N A','NR').replaceAll(/^ \d+$/, 'PG-$0')}
{" [$minutes Min]"}
{" [$vf $vc $ac "+af.replace('8ch', '7.1ch').replace('7ch', '6.1ch').replace('6ch', '5.1ch').replace('3ch', '2.1ch').replace('2ch','2.0ch')+"]"}
.{cf}
I read through quite a few forum posts on formats (DrevXen's, Ithiel's, and quite a few others). I've tried to figure out how to use "if/then" statements from all the code examples on the forums, but it seems I have not yet grasped how to do this in groovy. I even went to groovy-lang.org and tried to get the format from there with no success.

I know all this outs me as quite the newbie, but hopefully I can learn from this if you are able to help! Sorry for the long post, hopefully I have adequately described the issue and my goals with the proposed code.

-edited for image posting issue
User avatar
rednoah
The Source
Posts: 23936
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Movie format with collections issue

Post by rednoah »

1.
These bits should work the way you want:

Code: Select all

{any{"$collection/[$y] $n [$certification]"}{"$n [$y][$certification]"}}
Note that this expression will yield no result if certification is not defined. You may want to refactor that into it's own {...} block.


2.
Your format uses af as if the channels binding didn't exist, but it does now, so I'd use that. ;)

Code: Select all

af	2ch
channels	2.0
Possibly the same for s3d, tags, String.sortName() ...
:idea: Please read the FAQ and How to Request Help.
Post Reply