Using {model} for dealing with collections holistically

All about user-defined episode / movie / file name format expressions
Post Reply
AbedlaPaille
Posts: 107
Joined: 12 Apr 2020, 04:02

Using {model} for dealing with collections holistically

Post by AbedlaPaille »

Amazing stuff, delighted about this. Getting euphoria rushes working on my format scheme, filebot comfirmed more thrilling than most AAA games :D

Question:

Code: Select all

{model.episode.containsAll(episodelist) ? '[complete]' : '[incomplete]'}
Possible to adapt this to collections? No success so far but i'm sure it's because i'm a noob :D

And is {model} potentially capable of preventing a collection hierarchy from being created? eg if there's only 1 item belonging to the collection in the processed batch

Haven't managed to adapt {model} to the subtitle use case i was telling you about in this thread viewtopic.php?f=8&t=6291&p=50497#p50497 though so if you have any hint for a baby programmer like myself :?:

Thanks in advance !
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [DOCS] Holistic formats with the {model} binding

Post by rednoah »

1.
{movie.collection} is a relatively new addition that will allow you to retrieve the entire list of collection entries, so based on that it should be doable.


2.
As for subtitles, you'd have to use {model} to group files by all your criteria, same movie, same extension, same language, etc and then that should give a list of duplicates (i.e. one key, multiple values) from which you can then derive index and count.
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Using {model} for dealing with collections holistically

Post by kim »

so...

Code: Select all

{ model.movie.containsAll(movie.collection) ? '[complete]' : '[incomplete]' }

Code: Select all

{ model.movie.unique().size() == 1 ? 'only 1 movie on list' : '2 or more' }
AbedlaPaille
Posts: 107
Joined: 12 Apr 2020, 04:02

Re: Using {model} for dealing with collections holistically

Post by AbedlaPaille »

Thanks guys. Kim the first one works great but does the second one work on your end?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Using {model} for dealing with collections holistically

Post by rednoah »

AbedlaPaille wrote: 12 May 2020, 04:29 Thanks guys. Kim the first one works great but does the second one work on your end?
Since {model} is involved, it's perfectly possible for this to work in one context but not another. So a screenshot of Rename is very much required, otherwise you will end up talking apples and bananas. :D
:idea: Please read the FAQ and How to Request Help.
AbedlaPaille
Posts: 107
Joined: 12 Apr 2020, 04:02

Re: Using {model} for dealing with collections holistically

Post by AbedlaPaille »

I now realize Kim's 2nd expression works, just differently than i assumed. It differenciates based on how many movies are in the processed batch rather than how many movies of the same collection are in the same batch.

e.g. collection with only one movie processed = treat as single movie, collection with more than one = treat as collection

I think i need to use his first example except instead of containsAll write something akin to contains < 2? No success so far
AbedlaPaille
Posts: 107
Joined: 12 Apr 2020, 04:02

Re: Using {model} for dealing with collections holistically

Post by AbedlaPaille »

collection with only one movie processed = treat as single movie, collection with more than one = treat as collection
Any help to make this happen?
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Using {model} for dealing with collections holistically

Post by kim »

small change

Code: Select all

{movie.collection.size() == 1 ? 'only 1 movie on list' : '2 or more' }
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Using {model} for dealing with collections holistically

Post by rednoah »

* {movie.collection} will give you the entire collection for a given movie
* {model.movie} will give you all the movies that you see in New Names


At a glance, I think what you want should be doable based on the above mentioned building blocks. You'll probably need to intersect those two sets to see what remains.


e.g.

Code: Select all

{
	// missing collection entries
	def missing = movie.collection - model.movie

	missing.size == movie.collection.size - 1
	? 'Single Entry'
	: missing.empty
	? 'Complete Collection'
	: 'Multi Entry'
}
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Using {model} for dealing with collections holistically

Post by kim »

the simple

Code: Select all

{movie.collection.size() ==  model.movie.unique().size() ? '[complete]' : '[incomplete]'}
AbedlaPaille
Posts: 107
Joined: 12 Apr 2020, 04:02

Re: Using {model} for dealing with collections holistically

Post by AbedlaPaille »

Holy molly this works ! Genius !! Thanks a lot guys this is fantastic :D
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Using {model} for dealing with collections holistically

Post by kim »

I think you are looking for something like this?

Code: Select all

{ any{model.movie.containsAll(movie.collection) && movie.collection.size() ==  model.movie.unique().size() ? collection + ' [complete]/' : collection + ' [incomplete]/' }{''}}{ny}
AbedlaPaille
Posts: 107
Joined: 12 Apr 2020, 04:02

Re: Using {model} for dealing with collections holistically

Post by AbedlaPaille »

Hi!

Code: Select all

{
	// missing collection entries
	def missing = movie.collection - model.movie

	missing.size == movie.collection.size - 1
	? 'Single Entry'
	: missing.empty
	? 'Complete Collection'
	: 'Multi Entry'
}
I'm trying to setup a --filter to do something similar. I want to catch all collections that aren't single entries, like i'm doing in my schemes with a light version of your snippet :

Code: Select all

{ def missing = movie.collection - model.movie; missing.size == movie.collection.size - 1 ? '' : collection.replaceAll(/[:|]/, " - ") }
How do i adapt this into a --filter ?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Using {model} for dealing with collections holistically

Post by rednoah »

What would the purpose of a --filter based on collections be? Exclude movie options that don't belong to any collection before matching?


:!: {model} doesn't work without rename context. The {model} is the result of matching all the files up with movies, while --filter is used to select movies for matching. {model} cannot exist yet at --filter time, because it comes into existence as a result of filtering and matching.
:idea: Please read the FAQ and How to Request Help.
AbedlaPaille
Posts: 107
Joined: 12 Apr 2020, 04:02

Re: Using {model} for dealing with collections holistically

Post by AbedlaPaille »

What would the purpose of a --filter based on collections be? Exclude movie options that don't belong to any collection before matching?
Yes i'm trying to make a hardlink folder just for my multi entry collections. In my head it goes something like that :

Code: Select all

filebot -rename -r "F:/Plex/" --db xattr --action hardlink --output "F:/Collections/" --filter "D:/CollectionsFilter.groovy" --format "D:/CollectionsFormat.groovy"
Any ideas on how i could get something similar working?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Using {model} for dealing with collections holistically

Post by rednoah »

If you want to select all movies that belong to any collection, then this will do:

Code: Select all

--filter collection
:idea: Please read the FAQ and How to Request Help.
AbedlaPaille
Posts: 107
Joined: 12 Apr 2020, 04:02

Re: Using {model} for dealing with collections holistically

Post by AbedlaPaille »

I ended up using --filter collection and a 'All' folder within for the single entry ones. Keeps things easy to browse.
Post Reply