[35] small fixes

This commit is contained in:
meisnate12 2022-07-16 15:28:16 -04:00
parent ebc60fb0f7
commit 5f742615e6
5 changed files with 40 additions and 4 deletions

View file

@ -1 +1 @@
1.17.1-develop34
1.17.1-develop35

View file

@ -101,10 +101,11 @@ collections:
## Special Template Attributes
There are three attributes unique to `templates`; `default`, `optional`, and `move_prefix`.
There are some attributes unique to `templates`; `default`, `optional`, `conditionals`, and `move_prefix`.
* `default` can set default values for template variables to be used if they're not specified in the call.
* `optional` can specify variables that if not specified on the template call will cause any attribute using one of those variables to be ignored in the template. You can make any template variable optional per collection by setting it to `null`.
* `conditionals` can specify variables based on conditions set by the user. See more [here](#conditionals)
* `move_prefix` can be given a list or comma-separated string of prefixes to move to the end of the collection/playlist name for sorting.
i.e. If you have `move_prefix: The` and a collection is called `The Avengers` then `<<collection_name>>` is replaced with `Avengers, The` instead of `The Avengers` for that collection.
@ -115,6 +116,41 @@ Every template call is given these template variables.
* `<<library_type>>` which is the library type
* All Template Variables can append `_encoded` to the variable name to use a URL encode version of the variable. ex. `<<collection_name_encoded>>`
### Conditionals
Each conditional is identified by its mapping name and has one required attribute; `conditions` and one optional attribute; `default`.
`default` is the default value for the variable when no condition is met. If default is not specified the variable becomes an optional variable.
`conditions` is a list of sets of conditions where if all conditions are met then the variable will be the `value` specified in that condition.
Each set of conditions must have the `value` attribute which is the value of the variable if the condition is met.
All other attribute pairs in the set of conditions will check a variable of the attribute key and see if the variable is the attribute value or in the list of attribute values.
Here's an example from the [PMM default ratings file](https://github.com/meisnate12/Plex-Meta-Manager-Configs/blob/master/PMM/overlays/ratings.yml).
```yaml
templates:
Rating:
conditionals:
rating1_horizontal_offset:
default: 30 # If no condition sets below are meet
conditions:
- side: [top, bottom]
rating2: none
rating3: none
value: 0 # If side is 'top' or 'bottom' and rating2 is 'none' and rating3 is 'none'
- side: [top, bottom]
rating2: none
value: -165 # If side is 'top' or 'bottom' and rating2 is 'none' and no previous conditions are meet
- side: [top, bottom]
rating3: none
value: -165 # If side is 'top' or 'bottom' rating3 is 'none' and no previous conditions are meet
- side: [top, bottom]
value: -335 # If side is 'top' or 'bottom' and no previous conditions are meet
```
## Advance Example
Here's an example IMDb Genre template and two different ways to call it.

View file

@ -505,7 +505,6 @@ class CollectionBuilder:
results = self.config.TMDb.search_people(tmdb_person)
if results:
valid_names.append(tmdb_person)
valid_names.append(results[0].name)
if results[0].biography:
self.summaries["tmdb_person"] = results[0].biography
if results[0].profile_url:

View file

@ -141,6 +141,7 @@ class DataFile:
name_var = f"{self.data_type.lower()}_name"
variables[name_var] = str(name)
variables["mapping_name"] = mapping_name
variables["library_type"] = self.library.type.lower() if self.library else "items"
variables["library_name"] = self.library.name if self.library else "playlist"

View file

@ -470,7 +470,7 @@ class Trakt:
userlist = util.parse(err_type, "userlist", trakt_dict, methods=dict_methods, parent=method_name, options=["recommended", "watched", "collected", "watchlist"])
user = util.parse(err_type, "user", trakt_dict, methods=dict_methods, parent=method_name, default="me")
sort_by = None
if userlist in ["recommended", "watchlist"] and "sort" in dict_methods:
if userlist in ["recommended", "watchlist"] and "sort_by" in dict_methods:
sort_by = util.parse(err_type, "sort_by", trakt_dict, methods=dict_methods, parent=method_name, default="rank", options=["rank", "added", "released", "title"])
self._userlist("collection" if userlist == "collected" else userlist, user, is_movie, sort_by=sort_by)
valid_dicts.append({"userlist": userlist, "user": user, "sort_by": sort_by})