From 589b7fde5d91dda2158aeae29805bd2904478ebb Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Sun, 10 Apr 2022 00:33:59 -0400 Subject: [PATCH] [17] changed to external_templates + docs --- VERSION | 2 +- docs/conf.py | 13 ++- docs/config/libraries.md | 54 +++++-------- docs/config/paths.md | 130 ++++++++++++++++++++++++++++++ docs/metadata/details/metadata.md | 33 ++++---- docs/metadata/metadata.md | 22 ++--- docs/metadata/templates.md | 40 ++++++--- modules/meta.py | 12 ++- 8 files changed, 219 insertions(+), 87 deletions(-) create mode 100644 docs/config/paths.md diff --git a/VERSION b/VERSION index e25c3141..ff2e1cc7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.16.3-develop16 +1.16.3-develop17 diff --git a/docs/conf.py b/docs/conf.py index 4fd3b960..b5a774af 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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"), diff --git a/docs/config/libraries.md b/docs/config/libraries.md index cbc1cee5..6e6c5b7d 100644 --- a/docs/config/libraries.md +++ b/docs/config/libraries.md @@ -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: ``` -## 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 | ❌ | | [`tautulli`](tautulli) | Any `tautulli` attribute that overrides a global value | global | ❌ | -## 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:
@@ -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.
-## 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 `.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 ``` \ No newline at end of file diff --git a/docs/config/paths.md b/docs/config/paths.md new file mode 100644 index 00000000..27048d64 --- /dev/null +++ b/docs/config/paths.md @@ -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 + +
+ Click to Expand +
+ +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` + +
+ +## Playlist Files + +The [`playlist_files`](libraries.md#playlist-files-attribute) at the top level in your [Configuration File](configuration). + +### Example + +
+ Click to Expand +
+ +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` + +
+ +## External Templates + +The [`external_templates`](../metadata/templates.md#external-templates) attribute is defined at the top level in your [Metadata File](../metadata/metadata). + +### Example + +
+ Click to Expand +
+ +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`. + +
diff --git a/docs/metadata/details/metadata.md b/docs/metadata/details/metadata.md index 2a022978..92a407c2 100644 --- a/docs/metadata/details/metadata.md +++ b/docs/metadata/details/metadata.md @@ -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).
**Values:** TMDb Person ID (List or Comma-separated string) | -| `sort_title` | **Description:** Changes the sort title.
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 `~`.
**Values:** Text to change Sort Title | -| `content_rating` | **Description:** Changes the content rating.
**Values:** Text to change Content Rating | -| `label` | **Description:** Appends new labels.
**Values:** Comma-separated string of labels to append | -| `label.remove` | **Description:** Removes existing labels from the collection.
**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)
**Values:** Comma-separated string of labels to sync | -| `collection_mode` | **Description:** Changes the Collection Mode
**Values:**
`default`Library default
`hide`Hide Collection
`hide_items`Hide Items in this Collection
`show_items`Show this Collection and its Items
| -| `collection_order` | **Description:** Changes the Collection Order
When using `custom` you can only have a single builder in the collection.
**Values:**
`release`Order Collection by Release Dates
`alpha`Order Collection Alphabetically
`custom`Order Collection Via the Builder Order
[Any `plex_search` Sort Option](../builders/plex.md#sort-options)Order Collection by any `plex_search` Sort Option
| -| `collection_level` | **Description:** Make season, episode, album or track collections from `plex_all`, `plex_search`, `trakt_list`, or `imdb_list` Builders and Filters
**Values:**
`season`Collection contains seasons
`episode`Collection contains episodes
`album`Collection contains albums
`track`Collection contains tracks
| -| `visible_library` | **Description:** Changes collection visible on Library (Only works with Plex Pass)
**Values:**
`true`Visible
`false`Not Visible
[Any `schedule` Option](schedule)Visible When Scheduled
| -| `visible_home` | **Description:** Changes collection visible on Home (Only works with Plex Pass)
**Values:**
`true`Visible
`false`Not Visible
[Any `schedule` Option](schedule)Visible When Scheduled
| -| `visible_shared` | **Description:** Changes collection visible on Shared Users' Home (Only works with Plex Pass)
**Values:**
`true`Visible
`false`Not Visible
[Any `schedule` Option](schedule)Visible When Scheduled
| -| `url_theme` | **Description:** Changes the Collection Theme to the URL provided.
**Values:** URL to mp3 file | -| `file_theme` | **Description:** Changes the Collection Theme to the file location provided.
**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).
**Values:** TMDb Person ID (List or Comma-separated string) | +| `sort_title` | **Description:** Changes the sort title.
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 `~`.
**Values:** Text to change Sort Title | +| `content_rating` | **Description:** Changes the content rating.
**Values:** Text to change Content Rating | +| `label` | **Description:** Appends new labels.
**Values:** Comma-separated string of labels to append | +| `label.remove` | **Description:** Removes existing labels from the collection.
**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)
**Values:** Comma-separated string of labels to sync | +| `collection_mode` | **Description:** Changes the Collection Mode
**Normal Collections Only**
**Values:**
`default`Library default
`hide`Hide Collection
`hide_items`Hide Items in this Collection
`show_items`Show this Collection and its Items
| +| `collection_order` | **Description:** Changes the Collection Order
**Normal Collections Only**
When using `custom` you can only have a single builder in the collection.
**Values:**
`release`Order Collection by Release Dates
`alpha`Order Collection Alphabetically
`custom`Order Collection Via the Builder Order
[Any `plex_search` Sort Option](../builders/plex.md#sort-options)Order Collection by any `plex_search` Sort Option
| +| `collection_filtering` | **Description:** Changes the Collection Filtering
**Smart Collections Only**
**Values:**
`admin`Always the server admin user
`user`User currently viewing the content
| +| `collection_level` | **Description:** Make season, episode, album or track collections from `plex_all`, `plex_search`, `trakt_list`, or `imdb_list` Builders and Filters
**Values:**
`season`Collection contains seasons
`episode`Collection contains episodes
`album`Collection contains albums
`track`Collection contains tracks
| +| `visible_library` | **Description:** Changes collection visible on Library (Only works with Plex Pass)
**Values:**
`true`Visible
`false`Not Visible
[Any `schedule` Option](schedule)Visible When Scheduled
| +| `visible_home` | **Description:** Changes collection visible on Home (Only works with Plex Pass)
**Values:**
`true`Visible
`false`Not Visible
[Any `schedule` Option](schedule)Visible When Scheduled
| +| `visible_shared` | **Description:** Changes collection visible on Shared Users' Home (Only works with Plex Pass)
**Values:**
`true`Visible
`false`Not Visible
[Any `schedule` Option](schedule)Visible When Scheduled
| +| `url_theme` | **Description:** Changes the Collection Theme to the URL provided.
**Values:** URL to mp3 file | +| `file_theme` | **Description:** Changes the Collection Theme to the file location provided.
**Values:** Path to mp3 file | * Here's an example of how the collections can look on the Home Page. diff --git a/docs/metadata/metadata.md b/docs/metadata/metadata.md index de99711d..52d21814 100644 --- a/docs/metadata/metadata.md +++ b/docs/metadata/metadata.md @@ -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) diff --git a/docs/metadata/templates.md b/docs/metadata/templates.md index 54ccf53d..a2ff8d5b 100644 --- a/docs/metadata/templates.md +++ b/docs/metadata/templates.md @@ -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: <> - sort_title: +_<> + sort_title: !_<> 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 `<>`. The `<>` is a template variable that is always available and doesn't have to be called out like `<>`. +Note that we provide the template name `Actor` and the value to insert in the place of `<>`. The `<>` is a template variable that is always available and doesn't have to be called out like `<>`. 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, `<>` could have been `<>` or `<>` 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, `<>` could have been `<>` or `<>` 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: <> - sort_title: +_<> + sort_title: !_<> 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 `<>` or `<>` All Template Variables can append `_encoded` to the variable name to use a URL encode version of the variable. ex. `<>` +## Advance Example + Here's an example IMDb Genre template and two different ways to call it. ```yaml @@ -121,7 +129,7 @@ templates: limit: <> - url: https://www.imdb.com/search/title/?title_type=<>&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 +``` diff --git a/modules/meta.py b/modules/meta.py index a7c06c05..db661899 100644 --- a/modules/meta.py +++ b/modules/meta.py @@ -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")