[17] changed to external_templates + docs

This commit is contained in:
meisnate12 2022-04-10 00:33:59 -04:00
parent 68ceeb6999
commit 589b7fde5d
8 changed files with 219 additions and 87 deletions

View file

@ -1 +1 @@
1.16.3-develop16
1.16.3-develop17

View file

@ -140,13 +140,12 @@ html_theme_options = {
("_menu", "Config", [
("Configuration File", "config/configuration"),
("_divider", ),
("_menu", "Libraries/Playlists", [
("Libraries", "config/libraries"),
("Playlists", "config/playlist"),
("Operations", "config/operations"),
]),
("Settings Attributes", "config/settings"),
("_menu", "Services Attributes", [
("Libraries", "config/libraries"),
("Playlists", "config/playlist"),
("Path Types", "config/paths"),
("Operations", "config/operations"),
("Settings", "config/settings"),
("_menu", "Services", [
("Webhooks Attributes", "config/webhooks"),
("Plex Attributes", "config/plex"),
("TMDb Attributes", "config/tmdb"),

View file

@ -1,12 +1,12 @@
# Library Attributes & Metadata Paths
# Library & Playlist Files Attributes
## Overview
## Library Attributes
Within the [Configuration File](configuration), the `libraries:` attribute specifies the Plex libraries that the user wants Plex Meta Manager to act on.
Attributes are used to instruct Plex Meta Manager what actions to take, such as "load the following libraries" or "execute the following Collection Definition files". These attributes can be specified individually per library, or can be inherited from the global value if it has been set. If an attribute is specified at both the library and global level, then the library level attribute will take priority.
## Example
### Example
This example is an advanced version of the library mappings which highlights some attributes being set at the global level, and some being set at the library level:
@ -71,7 +71,7 @@ radarr:
```
</details>
## Attributes
### Attributes
The available attributes for each library are as follows:
@ -88,7 +88,7 @@ The available attributes for each library are as follows:
| [`sonarr`](sonarr) | Any `sonarr` attribute that overrides a global value | global | &#10060; |
| [`tautulli`](tautulli) | Any `tautulli` attribute that overrides a global value | global | &#10060; |
## Library Name
#### Library Name
Each library that the user wants Plex Meta Manager to interact with must be documented with a library attribute. A library attribute is represented by the mapping name (i.e. `Movies` or `TV Shows`), this must have a unique name that correlates with a library of the same name within the Plex Media Server. In the situation that two servers are being connected to which both have libraries of the same name, the `library_name` attribute can be utilized to specify the real Library Name, whilst the library attribute's mapping name can be made into a placeholder. This is showcased below:
<details>
@ -114,11 +114,9 @@ plex:
* In this example, `"Movies01"`, `"TV Shows"`, and `"Anime"` will all use the global plex server (http://192.168.1.12:32400) which is defined using the global `plex` mapping. `"Movies02"` will use the plex server http://192.168.1.35:32400 which is defined under its `plex` mapping over the global mapping.
</details>
## Metadata Path
### Metadata Path
### Overview
The `metadata_path` attribute is used to define the metadata (aka YAML) files that will be executed against the parent library.
The `metadata_path` attribute is used to define [Metadata Files](../metadata/metadata) by specifying the path type and path of the files that will be executed against the parent library. See [Path Types](paths) for how to define them.
By default, when `metadata_path` is missing the script will look within the root PMM directory for a metadata file called `<MAPPING_NAME>.yml`. In this example, Plex Meta Manager will look for a file named `TV Shows.yml`.
```yaml
@ -126,32 +124,6 @@ libraries:
TV Shows:
```
### Path Types
In this example, four metadata file path types are defined for the `"TV Shows"` library:
```yaml
TV Shows:
metadata_path:
- file: config/TVShows.yml
- folder: config/TV Shows/
- git: meisnate12/ShowCharts
- url: https://somewhere.com/PopularTV.yml
```
The four path types are outlined as follows:
* `- file:` refers to a metadata file which is located within the system that PMM is being run from.
* `- folder:` refers to a directory containing metadata files which is located within the system that PMM is being run from.
* `- git:` refers to a metadata file which is hosted on the [Configs Repo](https://github.com/meisnate12/Plex-Meta-Manager-Configs).
* `- repo:` refers to a metadata file which is hosted on a custom repository specified aby the user with the [`custom-repo` Setting Attribute](settings.md#custom-repo).
* `- url:` refers to a metadata file which is hosted publicly on the internet.
Within the above example, PMM will:
* First, look within the root of the PMM directory (also known as `config/`) for a metadata file named `TVShows.yml`. If this file does not exist, PMM will skip the entry and move to the next one in the list.
* Then, look within the root of the PMM directory (also known as `config/`) for a directory called `TV Shows`, and then load any metadata files within that directory.
* Then, look at the [meisnate12 folder](https://github.com/meisnate12/Plex-Meta-Manager-Configs/tree/master/meisnate12) within the GitHub Configs Repo for a file called `MovieCharts.yml` which it finds [here](https://github.com/meisnate12/Plex-Meta-Manager-Configs/blob/master/meisnate12/MovieCharts.yml).
* Finally, load the metadata file located at `https://somewhere.com/PopularTV.yml`
## Missing Path
The `missing_path` attribute is used to define where to save the "missing items" YAML file. This file is used to store information about media which is missing from the Plex library compared to what is expected from the Metadata file.
@ -172,4 +144,16 @@ Alternatively, "missing items" YAML files can be placed in their own directory,
libraries:
Movies:
missing_path: /config/missing/Movies.yml
```
## Playlist Files Attribute
As playlists are not tied to one specific library and can combine media from multiple libraries, they require their own special [Playlist Files](../metadata/metadata) to work.
You can define Playlist Files by using `playlist_files` mapper by specifying the path type and path of the files that will be executed. See [Path Types](paths) for how to define them.
```yaml
playlist_files:
- file: config/playlists.yml
- git: meisnate12/Playlists
```

130
docs/config/paths.md Normal file
View file

@ -0,0 +1,130 @@
# Path Types
YAML Files are defined by their path type and path location for the [`metadata_path`](libraries.md#metadata-path), [`playlist_files`](libraries.md#metadata-path), and [`external_templates`](libraries.md#metadata-path) attributes.
They can either be on the local system, online at an url, directly from the [Plex Meta Manager Configs](https://github.com/meisnate12/Plex-Meta-Manager-Configs) repository, or from another [`Custom Repository`](settings.md#custom-repo).
The path types are outlined as follows:
* `- file:` refers to a metadata file which is located within the system that PMM is being run from.
* `- folder:` refers to a directory containing metadata files which is located within the system that PMM is being run from.
* `- url:` refers to a metadata file which is hosted publicly on the internet.
* `- git:` refers to a metadata file which is hosted on the [Configs Repo](https://github.com/meisnate12/Plex-Meta-Manager-Configs).
* `- repo:` refers to a metadata file which is hosted on a custom repository specified aby the user with the [`custom_repo` Setting Attribute](settings.md#custom-repo).
## Template Variables
[Template Variables](../metadata/templates.md#template-variables) can be added to every template in any defined YAML file by adding the `template_variables` attribute to the dictionary defining the file.
### Example
```yaml
libraries:
TV Shows:
metadata_path:
- git: PMM/genre
template_variables:
schedule_separator: never
collection_mode: hide
```
In this example there will be two template variables added to every template in the git file PMM/genre.
`schedule_separator` is set to `never` to not show a separator in this section and `collection_mode` is set to `hide`.
What these variables will do depends on how they're defined in the Metadata File.
## Metadata Path
The [`metadata_path`](libraries.md#metadata-path) attribute is defined under the [`libraries`](libraries) attribute in your [Configuration File](configuration).
### Example
<details>
<summary>Click to Expand</summary>
<br />
In this example, multiple metadata file path types are defined for the `"TV Shows"` library:
```yaml
libraries:
TV Shows:
metadata_path:
- file: config/TVShows.yml
- folder: config/TV Shows/
- git: meisnate12/ShowCharts
- repo: charts
- url: https://somewhere.com/PopularTV.yml
```
Within the above example, PMM will:
* First, look within the root of the PMM directory (also known as `config/`) for a metadata file named `TVShows.yml`. If this file does not exist, PMM will skip the entry and move to the next one in the list.
* Then, look within the root of the PMM directory (also known as `config/`) for a directory called `TV Shows`, and then load any metadata files within that directory.
* Then, look at the [meisnate12 folder](https://github.com/meisnate12/Plex-Meta-Manager-Configs/tree/master/meisnate12) within the GitHub Configs Repo for a file called `MovieCharts.yml` which it finds [here](https://github.com/meisnate12/Plex-Meta-Manager-Configs/blob/master/meisnate12/MovieCharts.yml).
* Then, look at the within the Custom Defined Repo for a file called `charts.yml`.
* Finally, load the metadata file located at `https://somewhere.com/PopularTV.yml`
</details>
## Playlist Files
The [`playlist_files`](libraries.md#playlist-files-attribute) at the top level in your [Configuration File](configuration).
### Example
<details>
<summary>Click to Expand</summary>
<br />
In this example, multiple `playlist_files` attribute path types are defined:
```yaml
playlist_files:
- file: config/playlists.yml
- folder: config/Playlists/
- git: meisnate12/Playlists
- repo: playlists
- url: https://somewhere.com/Playlists.yml
```
Within the above example, PMM will:
* First, look within the root of the PMM directory (also known as `config/`) for a playlist file named `Playlists.yml`. If this file does not exist, PMM will skip the entry and move to the next one in the list.
* Then, look within the root of the PMM directory (also known as `config/`) for a directory called `Playlists`, and then load any playlist files within that directory.
* Then, look at the [meisnate12 folder](https://github.com/meisnate12/Plex-Meta-Manager-Configs/tree/master/meisnate12) within the GitHub Configs Repo for a file called `MovieCharts.yml` which it finds [here](https://github.com/meisnate12/Plex-Meta-Manager-Configs/blob/master/meisnate12/Playlists.yml).
* Then, look at the within the Custom Defined Repo for a file called `playlists.yml`.
* Finally, load the playlist file located at `https://somewhere.com/Playlists.yml`
</details>
## External Templates
The [`external_templates`](../metadata/templates.md#external-templates) attribute is defined at the top level in your [Metadata File](../metadata/metadata).
### Example
<details>
<summary>Click to Expand</summary>
<br />
In this example, multiple external template file path types are defined:
```yaml
external_templates:
- file: config/templates.yml
- folder: config/templates/
- url: https://somewhere.com/templates.yml
- git: PMM/templates
- repo: templates
```
Within the above example, PMM will:
* First, look within the root of the PMM directory (also known as `config/`) for a metadata file named `templates.yml`. If this file does not exist, PMM will skip the entry and move to the next one in the list.
* Then, look within the root of the PMM directory (also known as `config/`) for a directory called `templates`, and then load any metadata files within that directory.
* Then, load the metadata file located at `https://somewhere.com/templates.yml`.
* Then, look at the [PMM folder](https://github.com/meisnate12/Plex-Meta-Manager-Configs/tree/master/PMM) within the GitHub Configs Repo for a file called `templates.yml` which it finds [here](https://github.com/meisnate12/Plex-Meta-Manager-Configs/blob/master/PMM/templates.yml).
* Finally, look at the within the Custom Defined Repo for a file called `templates.yml`.
</details>

View file

@ -6,22 +6,23 @@ All the following attributes update various details of the collection/playlist's
Only `tmdb_person` works with Playlists.
| Attribute | Description & Values |
|:-------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `tmdb_person` | **Description:** Changes summary and poster to a TMDb Person's biography and profile as well as allow the people specified to be used in [Plex Searches](../builders/plex.md#plex-search).<br>**Values:** TMDb Person ID (List or Comma-separated string) |
| `sort_title` | **Description:** Changes the sort title.<br>You can "promote" certain collections to the top of a library by creating a sort title starting with a `+` or "demote" certain collections to the bottom of a library by creating a sort title starting with a `~`.<br>**Values:** Text to change Sort Title |
| `content_rating` | **Description:** Changes the content rating.<br>**Values:** Text to change Content Rating |
| `label` | **Description:** Appends new labels.<br>**Values:** Comma-separated string of labels to append |
| `label.remove` | **Description:** Removes existing labels from the collection.<br>**Values:** Comma-separated string of labels to remove |
| `label.sync` | **Description:** Matches the labels of the collection to the labels provided (Leave blank to remove all labels)<br>**Values:** Comma-separated string of labels to sync |
| `collection_mode` | **Description:** Changes the Collection Mode<br>**Values:**<table class="clearTable"><tr><td>`default`</td><td>Library default</td></tr><tr><td>`hide`</td><td>Hide Collection</td></tr><tr><td>`hide_items`</td><td>Hide Items in this Collection</td></tr><tr><td>`show_items`</td><td>Show this Collection and its Items</td></tr></table> |
| `collection_order` | **Description:** Changes the Collection Order<br>When using `custom` you can only have a single builder in the collection.<br>**Values:**<table class="clearTable"><tr><td>`release`</td><td>Order Collection by Release Dates</td></tr><tr><td>`alpha`</td><td>Order Collection Alphabetically</td></tr><tr><td>`custom`</td><td>Order Collection Via the Builder Order</td></tr><tr><td>[Any `plex_search` Sort Option](../builders/plex.md#sort-options)</td><td>Order Collection by any `plex_search` Sort Option</td></tr></table> |
| `collection_level` | **Description:** Make season, episode, album or track collections from `plex_all`, `plex_search`, `trakt_list`, or `imdb_list` Builders and Filters<br>**Values:**<table class="clearTable"><tr><td>`season`</td><td>Collection contains seasons</td></tr><tr><td>`episode`</td><td>Collection contains episodes</td></tr><tr><td>`album`</td><td>Collection contains albums</td></tr><tr><td>`track`</td><td>Collection contains tracks</td></tr></table> |
| `visible_library` | **Description:** Changes collection visible on Library (Only works with Plex Pass)<br>**Values:**<table class="clearTable"><tr><td>`true`</td><td>Visible</td></tr><tr><td>`false`</td><td>Not Visible</td></tr><tr><td>[Any `schedule` Option](schedule)</td><td>Visible When Scheduled</td></tr></table> |
| `visible_home` | **Description:** Changes collection visible on Home (Only works with Plex Pass)<br>**Values:**<table class="clearTable"><tr><td>`true`</td><td>Visible</td></tr><tr><td>`false`</td><td>Not Visible</td></tr><tr><td>[Any `schedule` Option](schedule)</td><td>Visible When Scheduled</td></tr></table> |
| `visible_shared` | **Description:** Changes collection visible on Shared Users' Home (Only works with Plex Pass)<br>**Values:**<table class="clearTable"><tr><td>`true`</td><td>Visible</td></tr><tr><td>`false`</td><td>Not Visible</td></tr><tr><td>[Any `schedule` Option](schedule)</td><td>Visible When Scheduled</td></tr></table> |
| `url_theme` | **Description:** Changes the Collection Theme to the URL provided.<br>**Values:** URL to mp3 file |
| `file_theme` | **Description:** Changes the Collection Theme to the file location provided.<br>**Values:** Path to mp3 file |
| Attribute | Description & Values |
|:-----------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `tmdb_person` | **Description:** Changes summary and poster to a TMDb Person's biography and profile as well as allow the people specified to be used in [Plex Searches](../builders/plex.md#plex-search).<br>**Values:** TMDb Person ID (List or Comma-separated string) |
| `sort_title` | **Description:** Changes the sort title.<br>You can "promote" certain collections to the top of a library by creating a sort title starting with a `+` or "demote" certain collections to the bottom of a library by creating a sort title starting with a `~`.<br>**Values:** Text to change Sort Title |
| `content_rating` | **Description:** Changes the content rating.<br>**Values:** Text to change Content Rating |
| `label` | **Description:** Appends new labels.<br>**Values:** Comma-separated string of labels to append |
| `label.remove` | **Description:** Removes existing labels from the collection.<br>**Values:** Comma-separated string of labels to remove |
| `label.sync` | **Description:** Matches the labels of the collection to the labels provided (Leave blank to remove all labels)<br>**Values:** Comma-separated string of labels to sync |
| `collection_mode` | **Description:** Changes the Collection Mode<br>**Normal Collections Only**<br>**Values:**<table class="clearTable"><tr><td>`default`</td><td>Library default</td></tr><tr><td>`hide`</td><td>Hide Collection</td></tr><tr><td>`hide_items`</td><td>Hide Items in this Collection</td></tr><tr><td>`show_items`</td><td>Show this Collection and its Items</td></tr></table> |
| `collection_order` | **Description:** Changes the Collection Order<br>**Normal Collections Only**<br>When using `custom` you can only have a single builder in the collection.<br>**Values:**<table class="clearTable"><tr><td>`release`</td><td>Order Collection by Release Dates</td></tr><tr><td>`alpha`</td><td>Order Collection Alphabetically</td></tr><tr><td>`custom`</td><td>Order Collection Via the Builder Order</td></tr><tr><td>[Any `plex_search` Sort Option](../builders/plex.md#sort-options)</td><td>Order Collection by any `plex_search` Sort Option</td></tr></table> |
| `collection_filtering` | **Description:** Changes the Collection Filtering<br>**Smart Collections Only**<br>**Values:**<table class="clearTable"><tr><td>`admin`</td><td>Always the server admin user</td></tr><tr><td>`user`</td><td>User currently viewing the content</td></tr></table> |
| `collection_level` | **Description:** Make season, episode, album or track collections from `plex_all`, `plex_search`, `trakt_list`, or `imdb_list` Builders and Filters<br>**Values:**<table class="clearTable"><tr><td>`season`</td><td>Collection contains seasons</td></tr><tr><td>`episode`</td><td>Collection contains episodes</td></tr><tr><td>`album`</td><td>Collection contains albums</td></tr><tr><td>`track`</td><td>Collection contains tracks</td></tr></table> |
| `visible_library` | **Description:** Changes collection visible on Library (Only works with Plex Pass)<br>**Values:**<table class="clearTable"><tr><td>`true`</td><td>Visible</td></tr><tr><td>`false`</td><td>Not Visible</td></tr><tr><td>[Any `schedule` Option](schedule)</td><td>Visible When Scheduled</td></tr></table> |
| `visible_home` | **Description:** Changes collection visible on Home (Only works with Plex Pass)<br>**Values:**<table class="clearTable"><tr><td>`true`</td><td>Visible</td></tr><tr><td>`false`</td><td>Not Visible</td></tr><tr><td>[Any `schedule` Option](schedule)</td><td>Visible When Scheduled</td></tr></table> |
| `visible_shared` | **Description:** Changes collection visible on Shared Users' Home (Only works with Plex Pass)<br>**Values:**<table class="clearTable"><tr><td>`true`</td><td>Visible</td></tr><tr><td>`false`</td><td>Not Visible</td></tr><tr><td>[Any `schedule` Option](schedule)</td><td>Visible When Scheduled</td></tr></table> |
| `url_theme` | **Description:** Changes the Collection Theme to the URL provided.<br>**Values:** URL to mp3 file |
| `file_theme` | **Description:** Changes the Collection Theme to the file location provided.<br>**Values:** Path to mp3 file |
* Here's an example of how the collections can look on the Home Page.

View file

@ -10,12 +10,13 @@ Collections, templates, metadata, and dynamic collections are defined within one
These are the attributes which can be used within the Metadata File:
| Attribute | Description |
|:-----------------------------------------------------|:-------------------------------------------------------------------------------------------------------------|
| `metadata` | contains definitions of metadata changes to make to library items [movie titles, episode descriptions, etc.] |
| [`templates`](templates) | contains definitions of templates that can be leveraged by multiple collections |
| [`collections`](#collections-and-playlists-mappings) | contains definitions of collections you wish to add to one or more libraries |
| [`dynamic_collections`](dynamic) | contains definitions of dynamic collections you wish to create in one or more libraries |
| Attribute | Description |
|:--------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `metadata` | contains definitions of metadata changes to [movie](metadata/movie), [show](metadata/show), or [music](metadata/music) library's items [movie titles, episode descriptions, etc.] |
| [`templates`](templates) | contains definitions of templates that can be leveraged by multiple collections |
| [`external_templates`](templates.md#external-templates) | contains [path types](../config/paths) that point to external templates that can be leveraged by multiple collections |
| [`collections`](#collections-and-playlists-mappings) | contains definitions of collections you wish to add to one or more libraries |
| [`dynamic_collections`](dynamic) | contains definitions of dynamic collections you wish to create in one or more libraries |
* One of `metadata`, `collections` or `dynamic_collections` must be present for the Metadata File to execute.
* Example Metadata Files can be found in the [Plex Meta Manager Configs Repository](https://github.com/meisnate12/Plex-Meta-Manager-Configs)
@ -26,10 +27,11 @@ Playlists are defined in one or more Playlist files that are mapped in the [Play
There are two attributes which can be utilized within the Playlist File:
| Attribute | Description |
|:-----------------------------------------------|:------------------------------------------------------------------------------|
| [`templates`](templates) | contains definitions of templates that can be leveraged by multiple playlists |
| [`playlists`](#additional-playlist-attributes) | contains definitions of playlists you wish to add to the server |
| Attribute | Description |
|:--------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------|
| [`templates`](templates) | contains definitions of templates that can be leveraged by multiple playlists |
| [`external_templates`](templates.md#external-templates) | contains [path types](../config/paths) that point to external templates that can be leveraged by multiple playlists |
| [`playlists`](#additional-playlist-attributes) | contains definitions of playlists you wish to add to the server |
* `playlists` is required in order to run the Playlist File.
* You can find example Playlist Files in the [Plex Meta Manager Configs Repository](https://github.com/meisnate12/Plex-Meta-Manager-Configs)

View file

@ -1,6 +1,6 @@
# Templates
Collections often share a lot of common [or generalizable] configuration details. Templates allow you to define these details so they can be used across multiple collections.
Collections often share a lot of common [or generalizable] configuration details. Templates allow you to define these details so they can be used across multiple collections.
For example, an actor collection might look like this:
@ -9,7 +9,7 @@ collections:
Bruce Lee:
actor: tmdb
tmdb_person: 19429
sort_title: +_Bruce Lee
sort_title: !_Bruce Lee
sync_mode: sync
collection_order: release
```
@ -21,20 +21,24 @@ collections:
Bruce Lee:
actor: tmdb
tmdb_person: 19429
sort_title: +_Bruce Lee
sort_title: !_Bruce Lee
sync_mode: sync
collection_order: release
Chris Pratt:
actor: tmdb
tmdb_person: 73457
sort_title: +_Chris Pratt
sort_title: !_Chris Pratt
sync_mode: sync
collection_order: release
```
You could keep going in this way, but there's a lot of repetition there. Both of these collections have the same `sync_mode`, `collection_order`, and `actor` settings; the other two details, `tmdb_person` and `sort_title`, depend on a value defined in the collection.
You could keep going in this way, but there's a lot of repetition there. Both of these collections have the same `sync_mode`, `collection_order`, and `actor` settings; the other two details, `tmdb_person` and `sort_title`, depend on a value defined in the collection.
Those repetitive aspects can be moved into template and leveraged by multiple collections.
Those repetitive aspects can be moved into a template and leveraged by multiple collections.
## Template Variables
Template Variables are used to define the data that going to be changing in the template.
For example, a template for those two collections might look like this:
@ -43,7 +47,7 @@ templates:
Actor:
actor: tmdb
tmdb_person: <<person>>
sort_title: +_<<collection_name>>
sort_title: !_<<collection_name>>
sync_mode: sync
collection_order: release
```
@ -68,11 +72,11 @@ collections:
template: {name: Actor, person: 19429}
```
Note that we provide the template name `Actor` and the value to insert in the place of `<<person>>`. The `<<collection_name>>` is a template variable that is always available and doesn't have to be called out like `<<person>>`.
Note that we provide the template name `Actor` and the value to insert in the place of `<<person>>`. The `<<collection_name>>` is a template variable that is always available and doesn't have to be called out like `<<person>>`.
Inside a template, you can use all the Builders, Details, and [Filters](filters) attributes that you can give collections/playlists [except `template`; templates cannot be nested].
The names of template variables that you define are arbitrary. In the example above, `<<person>>` could have been `<<tvdb_person_id>>` or `<<bing>>` or anything else. The only thing that matters is that in the template definition you surround them with `<< >>` and in the collection definition you spell it correctly.
The names of template variables that you define are arbitrary. In the example above, `<<person>>` could have been `<<tvdb_person_id>>` or `<<bing>>` or anything else. The only thing that matters is that in the template definition you surround them with `<< >>` and in the collection definition you spell it correctly.
To use a template with a collection definition you use the `template` attribute. The only required attribute under `template` is `name` which must correspond exactly to the template mapping name. Any other attributes under `template` are considered template variables whose names correspond exactly with the template variable name surrounded by `<<` and `>>` in the templates. These template variables will replace any part of any value that contains the template variable name surrounded by `<<` and `>>` in the template with the specified template variable's value.
@ -83,7 +87,7 @@ templates:
Actor:
actor: tmdb
tmdb_person: <<person>>
sort_title: +_<<collection_name>>
sort_title: !_<<collection_name>>
sync_mode: sync
collection_order: release
collections:
@ -95,6 +99,8 @@ collections:
person: 73457
```
## Special Template Attributes
There are three attributes unique to `templates`; `default`, `optional`, and `move_prefix`.
* `default` can set default values for template variables to be used if they're not specified in the call.
@ -106,6 +112,8 @@ Every template call is given either `<<collection_name>>` or `<<playlist_name>>`
All Template Variables can append `_encoded` to the variable name to use a URL encode version of the variable. ex. `<<collection_name_encoded>>`
## Advance Example
Here's an example IMDb Genre template and two different ways to call it.
```yaml
@ -121,7 +129,7 @@ templates:
limit: <<limit>>
- url: https://www.imdb.com/search/title/?title_type=<<title>>&release_date=1990-01-01,&user_rating=5.0,10.0&num_votes=100000,&genres=<<genre>>&sort=user_rating,desc
limit: <<limit>>
sort_title: ++_<<collection_name>>
sort_title: !_<<collection_name>>
url_poster: https://theposterdb.com/api/assets/<<poster_id>>
sync_mode: sync
collection_order: alpha
@ -142,3 +150,13 @@ collections:
```
Check out the example files in the [Plex Meta Manager Configs Repository](https://github.com/meisnate12/Plex-Meta-Manager-Configs/tree/master/meisnate12) for more uses and examples.
## External Templates
To load external templates located in another file you can use the `external_templates` attribute by specifying the path type and path of the files that will be executed. See [Path Types](../config/paths) for how to define them.
```yaml
external_templates:
- file: config/templates.yml
- git: PMM/templates
```

View file

@ -235,9 +235,9 @@ class DataFile:
continue
return new_attributes
def load_templates(self):
if "load_templates" in self.templates and self.templates["load_templates"]:
for file_type, template_file, temp_vars in util.load_yaml_files(self.templates["load_templates"]):
def external_templates(self, data):
if "external_templates" in data and data["external_templates"]:
for file_type, template_file, temp_vars in util.load_yaml_files(data["external_templates"]):
temp_data = self.load_file(file_type, template_file)
if temp_data and isinstance(temp_data, dict) and "templates" in temp_data and temp_data["templates"] and isinstance(temp_data["templates"], dict):
for temp_key, temp_value in temp_data["templates"].items():
@ -246,7 +246,6 @@ class DataFile:
for tk, tv in temp_vars.items():
if tk not in self.temp_vars:
self.temp_vars[tk] = tv
self.templates.pop("load_templates")
class MetadataFile(DataFile):
def __init__(self, config, library, file_type, path, temp_vars):
@ -264,8 +263,7 @@ class MetadataFile(DataFile):
data = self.load_file(self.type, self.path)
self.metadata = get_dict("metadata", data, library.metadata_files)
self.templates = get_dict("templates", data)
self.load_templates()
self.external_templates(data)
self.collections = get_dict("collections", data, library.collections)
self.dynamic_collections = get_dict("dynamic_collections", data)
col_names = library.collections + [c for c in self.collections]
@ -1074,7 +1072,7 @@ class PlaylistFile(DataFile):
data = self.load_file(self.type, self.path)
self.playlists = get_dict("playlists", data, self.config.playlist_names)
self.templates = get_dict("templates", data)
self.load_templates()
self.external_templates(data)
if not self.playlists:
raise Failed("YAML Error: playlists attribute is required")
logger.info(f"Playlist File Loaded Successfully")