[DOCS] Holistic formats with the {model} binding

All about user-defined episode / movie format expressions
User avatar
The Source
Posts: 18823
Joined: 16 Nov 2011, 08:59
Location: Taipei

[DOCS] Holistic formats with the {model} binding

Post by rednoah »

{model} gives you access to all matches and bindings for each match for the current batch. Any binding that is available for a single match (e.g. n) can also be accessed for all matches (e.g. model.n).

If you have 3 matches / files, and use {episode} to format them, then you get a different name for each file because {episode} is different for each match. {model.episode} gives you all episode values for all matches for each match.

:idea: {model} is particularly useful when the destination path for a match doesn't just depend on the match itself, but on other matches processed in the same context as well.


Season 1-9 group folders:

Code: Select all

{n} [Season {model.s.bounds().join('-')}]/{plex.name}

Mark series folder complete if all known episodes of a given show are being processed in the current batch:

Code: Select all

{n} {model.episode.containsAll(episodelist) ? '[complete]' : '[incomplete]'}/{plex.name}

Bindings such as {vc} yield different values for different files. If we want {vc} tags in the folder name, but ensure that all files regardless of {vc} end up in the same folder, then we can use {model} to include all the different {vc} values in the folder path:

Code: Select all

{n} {model.vc.sort().unique()}/{plex.name}

Before the {ci} collection index binding was introduced, one could have used {model} to count all the {collection} values of the current match group and conjure up that particular value:

Code: Select all

{model.findAll{ it.collection == collection }.sort{ it.d }.findIndexOf{ it.id == id } + 1}
:idea: Please read the FAQ and How to Request Help.