mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2025-02-16 13:58:25 +00:00
[10] library level template variables
This commit is contained in:
parent
2f79f2f7ae
commit
3a655c6d5a
5 changed files with 49 additions and 28 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
1.17.0-develop9
|
||||
1.17.0-develop10
|
||||
|
|
|
@ -78,19 +78,20 @@ radarr:
|
|||
|
||||
The available attributes for each library are as follows:
|
||||
|
||||
| Attribute | Values | Default | Required |
|
||||
|:-------------------------------------------|:------------------------------------------------------------------------------------------------------|:-------------------------------------:|:-------------------------------:|
|
||||
| [`library_name`](#library-name) | Library name (required only when trying to use multiple libraries with the same name) | Base Attribute Name | ❌ |
|
||||
| [`metadata_path`](#metadata-path) | Location of Metadata YAML files | `/config/<<MAPPING_NAME>>.yml` | ❌ |
|
||||
| [`overlay_path`](#overlay-path) | Location of Overlay YAML files | None | ❌ |
|
||||
| [`report_path`](#report-path) | Location to create the YAML file listing added, removed, filtered, and missing items for this library | `/config/<<MAPPING_NAME>>_report.yml` | ❌ |
|
||||
| [`schedule`](../metadata/details/schedule) | Use any [schedule option](../metadata/details/schedule) to control when this library is run. | daily | ❌ |
|
||||
| [`operations`](operations) | Library Operations to run | N/A | ❌ |
|
||||
| [`settings`](settings) | Any `setting` attribute that overrides a global value | global | ❌ |
|
||||
| [`plex`](plex) | Any `plex` attribute that overrides a global value | global | ✅ Either here or globally |
|
||||
| [`radarr`](radarr) | Any `radarr` attribute that overrides a global value | global | ❌ |
|
||||
| [`sonarr`](sonarr) | Any `sonarr` attribute that overrides a global value | global | ❌ |
|
||||
| [`tautulli`](tautulli) | Any `tautulli` attribute that overrides a global value | global | ❌ |
|
||||
| Attribute | Values | Default | Required |
|
||||
|:--------------------------------------------|:------------------------------------------------------------------------------------------------------|:-------------------------------------:|:-------------------------------:|
|
||||
| [`library_name`](#library-name) | Library name (required only when trying to use multiple libraries with the same name) | Base Attribute Name | ❌ |
|
||||
| [`metadata_path`](#metadata-path) | Location of Metadata YAML files | `/config/<<MAPPING_NAME>>.yml` | ❌ |
|
||||
| [`overlay_path`](#overlay-path) | Location of Overlay YAML files | None | ❌ |
|
||||
| [`report_path`](#report-path) | Location to create the YAML file listing added, removed, filtered, and missing items for this library | `/config/<<MAPPING_NAME>>_report.yml` | ❌ |
|
||||
| [`template_variables`](#template-variables) | Library template variables to be applied to every Metadata and Overlay file run. | N/A | ❌ |
|
||||
| [`schedule`](../metadata/details/schedule) | Use any [schedule option](../metadata/details/schedule) to control when this library is run. | daily | ❌ |
|
||||
| [`operations`](operations) | Library Operations to run | N/A | ❌ |
|
||||
| [`settings`](settings) | Any `setting` attribute that overrides a global value | global | ❌ |
|
||||
| [`plex`](plex) | Any `plex` attribute that overrides a global value | global | ✅ Either here or globally |
|
||||
| [`radarr`](radarr) | Any `radarr` attribute that overrides a global value | global | ❌ |
|
||||
| [`sonarr`](sonarr) | Any `sonarr` attribute that overrides a global value | global | ❌ |
|
||||
| [`tautulli`](tautulli) | Any `tautulli` attribute that overrides a global value | global | ❌ |
|
||||
|
||||
### Library Name
|
||||
|
||||
|
@ -189,6 +190,17 @@ libraries:
|
|||
report_path: /config/reports/Movies.yml
|
||||
```
|
||||
|
||||
### Template Variables
|
||||
|
||||
Library template variables to be applied to every Metadata and Overlay file run.
|
||||
|
||||
```yaml
|
||||
libraries:
|
||||
Movies:
|
||||
template_variable:
|
||||
collection_mode: true
|
||||
```
|
||||
|
||||
## 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.
|
||||
|
|
|
@ -730,16 +730,20 @@ class ConfigFile:
|
|||
if self.Trakt is None and params["mass_trakt_rating_update"]:
|
||||
error_check("mass_trakt_rating_update", "Trakt")
|
||||
|
||||
lib_vars = {}
|
||||
if "template_variables" in lib and lib["template_variables"] and isinstance(lib["template_variables"], dict):
|
||||
lib_vars = lib["template_variables"]
|
||||
|
||||
try:
|
||||
if lib and "metadata_path" in lib:
|
||||
if not lib["metadata_path"]:
|
||||
raise Failed("Config Error: metadata_path attribute is blank")
|
||||
files = util.load_files(lib["metadata_path"], "metadata_path", schedule=(current_time, self.run_hour, self.ignore_schedules))
|
||||
files = util.load_files(lib["metadata_path"], "metadata_path", schedule=(current_time, self.run_hour, self.ignore_schedules), lib_vars=lib_vars)
|
||||
if not files:
|
||||
raise Failed("Config Error: No Paths Found for metadata_path")
|
||||
params["metadata_path"] = files
|
||||
elif os.path.exists(os.path.join(default_dir, f"{library_name}.yml")):
|
||||
params["metadata_path"] = [("File", os.path.join(default_dir, f"{library_name}.yml"), {}, None)]
|
||||
params["metadata_path"] = [("File", os.path.join(default_dir, f"{library_name}.yml"), lib_vars, None)]
|
||||
else:
|
||||
params["metadata_path"] = []
|
||||
params["default_dir"] = default_dir
|
||||
|
@ -761,7 +765,7 @@ class ConfigFile:
|
|||
try:
|
||||
if not lib["overlay_path"]:
|
||||
raise Failed("Config Error: overlay_path attribute is blank")
|
||||
files = util.load_files(lib["overlay_path"], "overlay_path")
|
||||
files = util.load_files(lib["overlay_path"], "overlay_path", lib_vars=lib_vars)
|
||||
if not files:
|
||||
raise Failed("Config Error: No Paths Found for overlay_path")
|
||||
for file in util.get_list(lib["overlay_path"], split=False):
|
||||
|
|
|
@ -119,16 +119,16 @@ class Operations:
|
|||
batch_display += f"\n{self.library.edit_tags('label', item, add_tags=add_labels, remove_tags=remove_labels, do_print=False)}"
|
||||
except Failed:
|
||||
pass
|
||||
|
||||
path = os.path.dirname(str(item.locations[0])) if self.library.is_movie else str(item.locations[0])
|
||||
if self.library.Radarr and self.library.radarr_add_all_existing and tmdb_id:
|
||||
path = path.replace(self.library.Radarr.plex_path, self.library.Radarr.radarr_path)
|
||||
path = path[:-1] if path.endswith(('/', '\\')) else path
|
||||
radarr_adds.append((tmdb_id, path))
|
||||
if self.library.Sonarr and self.library.sonarr_add_all_existing and tvdb_id:
|
||||
path = path.replace(self.library.Sonarr.plex_path, self.library.Sonarr.sonarr_path)
|
||||
path = path[:-1] if path.endswith(("/", "\\")) else path
|
||||
sonarr_adds.append((tvdb_id, path))
|
||||
if item.locations:
|
||||
path = os.path.dirname(str(item.locations[0])) if self.library.is_movie else str(item.locations[0])
|
||||
if self.library.Radarr and self.library.radarr_add_all_existing and tmdb_id:
|
||||
path = path.replace(self.library.Radarr.plex_path, self.library.Radarr.radarr_path)
|
||||
path = path[:-1] if path.endswith(('/', '\\')) else path
|
||||
radarr_adds.append((tmdb_id, path))
|
||||
if self.library.Sonarr and self.library.sonarr_add_all_existing and tvdb_id:
|
||||
path = path.replace(self.library.Sonarr.plex_path, self.library.Sonarr.sonarr_path)
|
||||
path = path[:-1] if path.endswith(("/", "\\")) else path
|
||||
sonarr_adds.append((tvdb_id, path))
|
||||
|
||||
tmdb_item = None
|
||||
if any([o == "tmdb" for o in self.library.meta_operations]):
|
||||
|
|
|
@ -380,13 +380,18 @@ def time_window(tw):
|
|||
else:
|
||||
return tw
|
||||
|
||||
def load_files(files_to_load, method, schedule=None):
|
||||
def load_files(files_to_load, method, schedule=None, lib_vars=None):
|
||||
files = []
|
||||
if not lib_vars:
|
||||
lib_vars = {}
|
||||
for file in get_list(files_to_load, split=False):
|
||||
if isinstance(file, dict):
|
||||
temp_vars = {}
|
||||
if "template_variables" in file and file["template_variables"] and isinstance(file["template_variables"], dict):
|
||||
temp_vars = file["template_variables"]
|
||||
for k, v in lib_vars.items():
|
||||
if k not in temp_vars:
|
||||
temp_vars[k] = v
|
||||
asset_directory = []
|
||||
if "asset_directory" in file and file["asset_directory"]:
|
||||
for asset_path in get_list(file["asset_directory"], split=False):
|
||||
|
|
Loading…
Add table
Reference in a new issue