mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-10 06:54:21 +00:00
[47] fix external template variables
This commit is contained in:
parent
5a4b908aa6
commit
87ab93076f
6 changed files with 31 additions and 31 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
1.16.5-develop46
|
||||
1.16.5-develop47
|
||||
|
|
|
@ -157,16 +157,16 @@ Special Filters each have their own set of rules for how they're used.
|
|||
|
||||
### Attribute
|
||||
|
||||
| Special Filters | Description | Movies | Shows | Seasons | Episodes | Artists | Albums | Track |
|
||||
|:--------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------:|:--------:|:--------:|:--------:|:--------:|:--------:|:--------:|
|
||||
| `history` | Uses the release date attribute (originally available) to match dates throughout history<br>`day`: Match the Day and Month to Today's Date<br>`month`: Match the Month to Today's Date<br>`1-30`: Match the Day and Month to Today's Date or `1-30` days before Today's Date | ✅ | ✅ | ❌ | ✅ | ❌ | ✅ | ❌ |
|
||||
| `episodes` | Uses the item's episodes attributes to match <br> Use the `percentage` attribute given a number between 0-100 to determine the percentage of an items episodes that must match the sub-filter. | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
|
||||
| `seasons` | Uses the item's seasons attributes to match <br> Use the `percentage` attribute given a number between 0-100 to determine the percentage of an items seasons that must match the sub-filter. | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||
| `tracks` | Uses the item's tracks attributes to match <br> Use the `percentage` attribute given a number between 0-100 to determine the percentage of an items tracks that must match the sub-filter. | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ |
|
||||
| `albums` | Uses the item's albums attributes to match <br> Use the `percentage` attribute given a number between 0-100 to determine the percentage of an items albums that must match the sub-filter. | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ |
|
||||
| `original_language`/`original_language.not`<sup>1</sup> | Uses TMDb original language [ISO 639-1 codes](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) to match<br>Example: `original_language: en, ko` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||
| `tmdb_status`/`tmdb_status.not`<sup>1</sup> | Uses TMDb Status to match<br>**Values:** `returning`, `planned`, `production`, `ended`, `canceled`, `pilot` | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||
| `tmdb_type`/`tmdb_type.not`<sup>1</sup> | Uses TMDb Type to match<br>**Values:** `documentary`, `news`, `production`, `miniseries`, `reality`, `scripted`, `talk_show`, `video` | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||
| Special Filters | Description | Movies | Shows | Seasons | Episodes | Artists | Albums | Track |
|
||||
|:-----------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------:|:--------:|:--------:|:--------:|:--------:|:--------:|:--------:|
|
||||
| `history` | Uses the release date attribute (originally available) to match dates throughout history<br>`day`: Match the Day and Month to Today's Date<br>`month`: Match the Month to Today's Date<br>`1-30`: Match the Day and Month to Today's Date or `1-30` days before Today's Date | ✅ | ✅ | ❌ | ✅ | ❌ | ✅ | ❌ |
|
||||
| `episodes` | Uses the item's episodes attributes to match <br> Use the `percentage` attribute given a number between 0-100 to determine the percentage of an items episodes that must match the sub-filter. | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
|
||||
| `seasons` | Uses the item's seasons attributes to match <br> Use the `percentage` attribute given a number between 0-100 to determine the percentage of an items seasons that must match the sub-filter. | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||
| `tracks` | Uses the item's tracks attributes to match <br> Use the `percentage` attribute given a number between 0-100 to determine the percentage of an items tracks that must match the sub-filter. | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ |
|
||||
| `albums` | Uses the item's albums attributes to match <br> Use the `percentage` attribute given a number between 0-100 to determine the percentage of an items albums that must match the sub-filter. | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ |
|
||||
| `original_language`<sup>1</sup><br>`original_language.not`<sup>1</sup> | Uses TMDb original language [ISO 639-1 codes](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) to match<br>Example: `original_language: en, ko` | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||
| `tmdb_status`<sup>1</sup><br>`tmdb_status.not`<sup>1</sup> | Uses TMDb Status to match<br>**Values:** `returning`, `planned`, `production`, `ended`, `canceled`, `pilot` | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||
| `tmdb_type`<sup>1</sup><br>`tmdb_type.not`<sup>1</sup> | Uses TMDb Type to match<br>**Values:** `documentary`, `news`, `production`, `miniseries`, `reality`, `scripted`, `talk_show`, `video` | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||
|
||||
<sup>1</sup> Also filters out missing movies/shows from being added to Radarr/Sonarr.
|
||||
|
||||
|
|
|
@ -562,7 +562,6 @@ class ConfigFile:
|
|||
self.libraries = []
|
||||
libs = check_for_attribute(self.data, "libraries", throw=True)
|
||||
|
||||
|
||||
for library_name, lib in libs.items():
|
||||
if self.requested_libraries and library_name not in self.requested_libraries:
|
||||
continue
|
||||
|
|
|
@ -47,6 +47,8 @@ def get_dict(attribute, attr_data, check_list=None, lower=False):
|
|||
logger.warning(f"Config Warning: {attribute[:-1] if attribute[-1] == 's' else attribute}: {_name} has no data")
|
||||
elif not isinstance(_data, dict):
|
||||
logger.warning(f"Config Warning: {attribute[:-1] if attribute[-1] == 's' else attribute}: {_name} must be a dictionary")
|
||||
elif attribute == "templates":
|
||||
new_dict[str(_name)] = (_data, {})
|
||||
else:
|
||||
new_dict[str(_name)] = _data
|
||||
return new_dict
|
||||
|
@ -118,7 +120,7 @@ class DataFile:
|
|||
raise Failed(f"{self.data_type} Error: template sub-attribute name is blank")
|
||||
elif variables["name"] not in self.templates:
|
||||
raise Failed(f"{self.data_type} Error: template {variables['name']} not found")
|
||||
elif not isinstance(self.templates[variables["name"]], dict):
|
||||
elif not isinstance(self.templates[variables["name"]][0], dict):
|
||||
raise Failed(f"{self.data_type} Error: template {variables['name']} is not a dictionary")
|
||||
else:
|
||||
remove_variables = []
|
||||
|
@ -138,11 +140,14 @@ class DataFile:
|
|||
variables["overlay_name"] = str(name)
|
||||
variables["library_type"] = self.library.type.lower()
|
||||
|
||||
for temp_key, temp_value in self.temp_vars.items():
|
||||
template_name = variables["name"]
|
||||
template, temp_vars = self.templates[template_name]
|
||||
|
||||
for temp_key, temp_value in temp_vars.items():
|
||||
variables[temp_key] = temp_value
|
||||
|
||||
template_name = variables["name"]
|
||||
template = self.templates[template_name]
|
||||
for temp_key, temp_value in self.temp_vars.items():
|
||||
variables[temp_key] = temp_value
|
||||
|
||||
for key, value in variables.copy().items():
|
||||
variables[f"{key}_encoded"] = requests.utils.quote(str(value))
|
||||
|
@ -252,10 +257,7 @@ class DataFile:
|
|||
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():
|
||||
if temp_key not in self.templates:
|
||||
self.templates[temp_key] = temp_value
|
||||
for tk, tv in temp_vars.items():
|
||||
if tk not in self.temp_vars:
|
||||
self.temp_vars[tk] = tv
|
||||
self.templates[temp_key] = (temp_value, temp_vars)
|
||||
|
||||
class MetadataFile(DataFile):
|
||||
def __init__(self, config, library, file_type, path, temp_vars, asset_directory):
|
||||
|
@ -496,12 +498,12 @@ class MetadataFile(DataFile):
|
|||
for template_name in template_names:
|
||||
if template_name not in self.templates:
|
||||
raise Failed(f"Config Error: {map_name} template: {template_name} not found")
|
||||
if "<<value>>" in str(self.templates[template_name]) or f"<<{auto_type}>>" in str(self.templates[template_name]):
|
||||
if "<<value>>" in str(self.templates[template_name][0]) or f"<<{auto_type}>>" in str(self.templates[template_name][0]):
|
||||
has_var = True
|
||||
if not has_var:
|
||||
raise Failed(f"Config Error: One {map_name} template: {template_names} is required to have the template variable <<value>>")
|
||||
else:
|
||||
self.templates[map_name] = default_template if default_template else default_templates[auto_type]
|
||||
self.templates[map_name] = (default_template if default_template else default_templates[auto_type], {})
|
||||
template_names = [map_name]
|
||||
remove_prefix = []
|
||||
if "remove_prefix" in self.temp_vars:
|
||||
|
@ -1101,7 +1103,7 @@ class PlaylistFile(DataFile):
|
|||
super().__init__(config, file_type, path, temp_vars, asset_directory)
|
||||
self.data_type = "Playlist"
|
||||
logger.info("")
|
||||
logger.info(f"Loading Playlist File {file_type}: {path}")
|
||||
logger.info(f"Loading Playlist {file_type}: {path}")
|
||||
data = self.load_file(self.type, self.path)
|
||||
self.playlists = get_dict("playlists", data, self.config.playlist_names)
|
||||
self.templates = get_dict("templates", data)
|
||||
|
@ -1116,7 +1118,7 @@ class OverlayFile(DataFile):
|
|||
self.library = library
|
||||
self.data_type = "Overlay"
|
||||
logger.info("")
|
||||
logger.info(f"Loading Overlay File {file_type}: {path}")
|
||||
logger.info(f"Loading Overlay {file_type}: {path}")
|
||||
data = self.load_file(self.type, self.path)
|
||||
self.overlays = get_dict("overlays", data, self.library.overlays)
|
||||
self.templates = get_dict("templates", data)
|
||||
|
|
|
@ -128,7 +128,6 @@ class Overlays:
|
|||
time.sleep(1)
|
||||
has_original = backup_image_path
|
||||
|
||||
|
||||
poster_compare = None
|
||||
if poster is None and has_original is None:
|
||||
logger.error(f"{item_title[:60]:<60} | Overlay Error: No poster found")
|
||||
|
|
|
@ -448,9 +448,9 @@ def run_collection(config, library, metadata, requested_collections):
|
|||
and data_template["name"] \
|
||||
and metadata.templates \
|
||||
and data_template["name"] in metadata.templates \
|
||||
and metadata.templates[data_template["name"]] \
|
||||
and "test" in metadata.templates[data_template["name"]] \
|
||||
and metadata.templates[data_template["name"]]["test"] is True:
|
||||
and metadata.templates[data_template["name"]][0] \
|
||||
and "test" in metadata.templates[data_template["name"]][0] \
|
||||
and metadata.templates[data_template["name"]][0]["test"] is True:
|
||||
no_template_test = False
|
||||
if no_template_test:
|
||||
continue
|
||||
|
@ -622,9 +622,9 @@ def run_playlists(config):
|
|||
and data_template["name"] \
|
||||
and playlist_file.templates \
|
||||
and data_template["name"] in playlist_file.templates \
|
||||
and playlist_file.templates[data_template["name"]] \
|
||||
and "test" in playlist_file.templates[data_template["name"]] \
|
||||
and playlist_file.templates[data_template["name"]]["test"] is True:
|
||||
and playlist_file.templates[data_template["name"]][0] \
|
||||
and "test" in playlist_file.templates[data_template["name"]][0] \
|
||||
and playlist_file.templates[data_template["name"]][0]["test"] is True:
|
||||
no_template_test = False
|
||||
if no_template_test:
|
||||
continue
|
||||
|
|
Loading…
Reference in a new issue