[11] rename the template variable to value among other fixes

This commit is contained in:
meisnate12 2022-03-19 12:02:52 -04:00
parent 06336caef4
commit 557a1da829
6 changed files with 86 additions and 68 deletions

View file

@ -14,8 +14,9 @@ jobs:
- name: Send Discord Release Notification
uses: meisnate12/discord-notifications@master
with:
webhook_id: ${{ secrets.BUILD_WEBHOOK_ID }}
webhook_token: ${{ secrets.BUILD_WEBHOOK_TOKEN }}
title: Plex Meta Manager Develop Commit
webhook_id: ${{ secrets.DEVELOP_WEBHOOK_ID }}
webhook_token: ${{ secrets.DEVELOP_WEBHOOK_TOKEN }}
title: Plex Meta Manager Develop Push
commits: "true"
username: PMM Develop
avatar_url: https://raw.githubusercontent.com/meisnate12/Plex-Meta-Manager/master/.github/pmm.png

View file

@ -1 +1 @@
1.16.2-develop10
1.16.2-develop11

View file

@ -59,7 +59,7 @@ dynamic_collections:
dynamic_collections:
Countries: # mapping name does not matter, just needs to be unique
type: country
title_format: <<country>> Cinema
title_format: <<key_name>> Cinema
key_name_override:
France: French
```
@ -152,7 +152,7 @@ Create collections based on the TMDb Collections associated with items in the li
</tr>
<tr>
<th>Default <code>title_format</code></th>
<td><code>&lt;&lt;title&gt;&gt;</code></td>
<td><code>&lt;&lt;key_name&gt;&gt;</code></td>
</tr>
<tr>
<th>Default Template</th>
@ -160,7 +160,7 @@ Create collections based on the TMDb Collections associated with items in the li
```yaml
default_template:
tmdb_collection_details: <<tmdb_collection>>
tmdb_collection_details: <<value>>
```
</td>
@ -200,7 +200,7 @@ Create collections based on each actor found on [TMDb's Popular People List](htt
</tr>
<tr>
<th>Default <code>title_format</code></th>
<td><code>&lt;&lt;title&gt;&gt;</code></td>
<td><code>&lt;&lt;key_name&gt;&gt;</code></td>
</tr>
<tr>
<th>Default Template</th>
@ -208,7 +208,7 @@ Create collections based on each actor found on [TMDb's Popular People List](htt
```yaml
default_template:
tmdb_person: <<tmdb_popular_people>>
tmdb_person: <<value>>
plex_search:
all:
actor: tmdb
@ -250,7 +250,7 @@ Create collections based on the TMDb original language associated with items in
</tr>
<tr>
<th>Default <code>title_format</code></th>
<td><code>&lt;&lt;title&gt;&gt; &lt;&lt;library_type&gt;&gt;s</code></td>
<td><code>&lt;&lt;key_name&gt;&gt; &lt;&lt;library_type&gt;&gt;s</code></td>
</tr>
<tr>
<th>Default Template</th>
@ -260,7 +260,7 @@ Create collections based on the TMDb original language associated with items in
default_template:
plex_all: true
filters:
original_language: <<original_language>>
original_language: <<value>>
```
</td>
@ -298,7 +298,7 @@ Create collections based on the TMDb origin country associated with items in the
</tr>
<tr>
<th>Default <code>title_format</code></th>
<td><code>&lt;&lt;title&gt;&gt; &lt;&lt;library_type&gt;&gt;s</code></td>
<td><code>&lt;&lt;key_name&gt;&gt; &lt;&lt;library_type&gt;&gt;s</code></td>
</tr>
<tr>
<th>Default Template</th>
@ -308,7 +308,7 @@ Create collections based on the TMDb origin country associated with items in the
default_template:
plex_all: true
filters:
origin_country: <<origin_country>>
origin_country: <<value>>
```
</td>
@ -348,7 +348,7 @@ Create collections for each of the Trakt lists for the specified users. Use `me`
</tr>
<tr>
<th>Default <code>title_format</code></th>
<td><code>&lt;&lt;title&gt;&gt;</code></td>
<td><code>&lt;&lt;key_name&gt;&gt;</code></td>
</tr>
<tr>
<th>Default Template</th>
@ -356,7 +356,7 @@ Create collections for each of the Trakt lists for the specified users. Use `me`
```yaml
default_template:
trakt_list_details: <<trakt_user_lists>>
trakt_list_details: <<value>>
```
</td>
@ -399,7 +399,7 @@ Create collections for each of the Trakt lists that the authenticated user has l
</tr>
<tr>
<th>Default <code>title_format</code></th>
<td><code>&lt;&lt;title&gt;&gt;</code></td>
<td><code>&lt;&lt;key_name&gt;&gt;</code></td>
</tr>
<tr>
<th>Default Template</th>
@ -407,7 +407,7 @@ Create collections for each of the Trakt lists that the authenticated user has l
```yaml
default_template:
trakt_list_details: <<trakt_liked_lists>>
trakt_list_details: <<value>>
```
</td>
@ -447,7 +447,7 @@ Create collections for each of the people found within Trakt lists that the user
</tr>
<tr>
<th>Default <code>title_format</code></th>
<td><code>&lt;&lt;title&gt;&gt;</code></td>
<td><code>&lt;&lt;key_name&gt;&gt;</code></td>
</tr>
<tr>
<th>Default Template</th>
@ -455,7 +455,7 @@ Create collections for each of the people found within Trakt lists that the user
```yaml
default_template:
tmdb_person: <<trakt_people_list>>
tmdb_person: <<value>>
plex_search:
all:
actor: tmdb
@ -519,7 +519,7 @@ Create a collection for each actor found in the library.
</tr>
<tr>
<th>Default <code>title_format</code></th>
<td><code>&lt;&lt;title&gt;&gt;</code></td>
<td><code>&lt;&lt;key_name&gt;&gt;</code></td>
</tr>
<tr>
<th>Default Template</th>
@ -527,7 +527,7 @@ Create a collection for each actor found in the library.
```yaml
default_template:
tmdb_person: <<actor>>
tmdb_person: <<value>>
plex_search:
all:
actor: tmdb
@ -613,7 +613,7 @@ Create a collection for each director found in the library.
</tr>
<tr>
<th>Default <code>title_format</code></th>
<td><code>&lt;&lt;title&gt;&gt;</code></td>
<td><code>&lt;&lt;key_name&gt;&gt;</code></td>
</tr>
<tr>
<th>Default Template</th>
@ -621,7 +621,7 @@ Create a collection for each director found in the library.
```yaml
default_template:
tmdb_person: <<director>>
tmdb_person: <<value>>
plex_search:
all:
director: tmdb
@ -707,7 +707,7 @@ Create a collection for each writer found in the library.
</tr>
<tr>
<th>Default <code>title_format</code></th>
<td><code>&lt;&lt;title&gt;&gt;</code></td>
<td><code>&lt;&lt;key_name&gt;&gt;</code></td>
</tr>
<tr>
<th>Default Template</th>
@ -715,7 +715,7 @@ Create a collection for each writer found in the library.
```yaml
default_template:
tmdb_person: <<writer>>
tmdb_person: <<value>>
plex_search:
all:
writer: tmdb
@ -801,7 +801,7 @@ Create a collection for each producer found in the library.
</tr>
<tr>
<th>Default <code>title_format</code></th>
<td><code>&lt;&lt;title&gt;&gt;</code></td>
<td><code>&lt;&lt;key_name&gt;&gt;</code></td>
</tr>
<tr>
<th>Default Template</th>
@ -809,7 +809,7 @@ Create a collection for each producer found in the library.
```yaml
default_template:
tmdb_person: <<producer>>
tmdb_person: <<value>>
plex_search:
all:
producer: tmdb
@ -873,7 +873,7 @@ Create a collection for each genre found in the library.
</tr>
<tr>
<th>Default <code>title_format</code></th>
<td><code>Top &lt;&lt;title&gt;&gt; &lt;&lt;library_type&gt;&gt;s</code></td>
<td><code>Top &lt;&lt;key_name&gt;&gt; &lt;&lt;library_type&gt;&gt;s</code></td>
</tr>
<tr>
<th>Default Template</th>
@ -885,7 +885,7 @@ default_template:
limit: 50
sort_by: critic_rating.desc
any:
genre: <<genre>>
genre: <<value>>
```
</td>
@ -906,7 +906,7 @@ templates:
limit: 100
sort_by: critic_rating.desc
all:
genre: <<genre>>
genre: <<value>>
dynamic_collections:
Genres: # mapping name does not matter just needs to be unique
type: genre
@ -939,7 +939,7 @@ Create a collection for each content rating found in the library.
</tr>
<tr>
<th>Default <code>title_format</code></th>
<td><code>Top &lt;&lt;title&gt;&gt; &lt;&lt;library_type&gt;&gt;s</code></td>
<td><code>Top &lt;&lt;key_name&gt;&gt; &lt;&lt;library_type&gt;&gt;s</code></td>
</tr>
<tr>
<th>Default Template</th>
@ -951,7 +951,7 @@ default_template:
limit: 50
sort_by: critic_rating.desc
any:
content_rating: <<content_rating>>
content_rating: <<value>>
```
</td>
@ -970,7 +970,7 @@ templates:
limit: 100
sort_by: critic_rating.desc
all:
content_rating: <<content_rating>>
content_rating: <<value>>
dynamic_collections:
Content Ratings: # mapping name does not matter just needs to be unique
type: content_rating
@ -1000,7 +1000,7 @@ Create a collection for each year found in the library.
</tr>
<tr>
<th>Default <code>title_format</code></th>
<td><code>Best &lt;&lt;library_type&gt;&gt;s of &lt;&lt;title&gt;&gt;</code></td>
<td><code>Best &lt;&lt;library_type&gt;&gt;s of &lt;&lt;key_name&gt;&gt;</code></td>
</tr>
<tr>
<th>Default Template</th>
@ -1012,7 +1012,7 @@ default_template:
limit: 50
sort_by: critic_rating.desc
any:
year: <<year>>
year: <<value>>
```
</td>
@ -1059,7 +1059,7 @@ Create a collection for each decade found in the library
</tr>
<tr>
<th>Default <code>title_format</code></th>
<td><code>Best &lt;&lt;library_type&gt;&gt;s of &lt;&lt;title&gt;&gt;</code></td>
<td><code>Best &lt;&lt;library_type&gt;&gt;s of &lt;&lt;key_name&gt;&gt;</code></td>
</tr>
<tr>
<th>Default Template</th>
@ -1071,7 +1071,7 @@ default_template:
limit: 50
sort_by: critic_rating.desc
any:
decade: <<decade>>
decade: <<value>>
```
</td>
@ -1116,7 +1116,7 @@ Create a collection for each country found in the library
</tr>
<tr>
<th>Default <code>title_format</code></th>
<td><code>Top &lt;&lt;title&gt;&gt; &lt;&lt;library_type&gt;&gt;s</code></td>
<td><code>Top &lt;&lt;key_name&gt;&gt; &lt;&lt;library_type&gt;&gt;s</code></td>
</tr>
<tr>
<th>Default Template</th>
@ -1128,7 +1128,7 @@ default_template:
limit: 50
sort_by: critic_rating.desc
any:
country: <<country>>
country: <<value>>
```
</td>
@ -1187,7 +1187,7 @@ default_template:
limit: 50
sort_by: title.asc
any:
resolution: <<resolution>>
resolution: <<value>>
```
</td>
@ -1246,7 +1246,7 @@ default_template:
limit: 50
sort_by: critic_rating.asc
any:
subtitle_language: <<subtitle_language>>
subtitle_language: <<value>>
```
</td>
@ -1298,7 +1298,7 @@ default_template:
limit: 50
sort_by: critic_rating.asc
any:
audio_language: <<audio_language>>
audio_language: <<value>>
```
</td>
@ -1338,7 +1338,7 @@ Create a collection for each network found in the library.
</tr>
<tr>
<th>Default <code>title_format</code></th>
<td><code>Top &lt;&lt;title&gt;&gt; &lt;&lt;library_type&gt;&gt;s</code></td>
<td><code>Top &lt;&lt;key_name&gt;&gt; &lt;&lt;library_type&gt;&gt;s</code></td>
</tr>
<tr>
<th>Default Template</th>
@ -1350,7 +1350,7 @@ default_template:
limit: 50
sort_by: critic_rating.desc
any:
network: <<network>>
network: <<value>>
```
</td>
@ -1368,7 +1368,7 @@ templates:
smart_filter:
sort_by: critic_rating.desc
all:
network: <<network>>
network: <<value>>
dynamic_collections:
Networks: # mapping name does not matter just needs to be unique
type: network
@ -1399,7 +1399,7 @@ Create a collection for each mood found in the library.
</tr>
<tr>
<th>Default <code>title_format</code></th>
<td><code>Most Played &lt;&lt;title&gt;&gt; &lt;&lt;library_type&gt;&gt;s</code></td>
<td><code>Most Played &lt;&lt;value&gt;&gt; &lt;&lt;library_type&gt;&gt;s</code></td>
</tr>
<tr>
<th>Default Template</th>
@ -1411,7 +1411,7 @@ default_template:
limit: 50
sort_by: plays.desc
any:
artist_mood: <<mood>>
artist_mood: <<value>>
```
</td>
@ -1431,7 +1431,7 @@ templates:
sort_by: plays.desc
type: tracks
all:
track_mood: <<mood>>
track_mood: <<value>>
dynamic_collections:
Moods: # mapping name does not matter just needs to be unique
type: mood
@ -1462,7 +1462,7 @@ Create a collection for each style found in the library.
</tr>
<tr>
<th>Default <code>title_format</code></th>
<td><code>Most Played &lt;&lt;title&gt;&gt; &lt;&lt;library_type&gt;&gt;s</code></td>
<td><code>Most Played &lt;&lt;key_name&gt;&gt; &lt;&lt;library_type&gt;&gt;s</code></td>
</tr>
<tr>
<th>Default Template</th>
@ -1474,7 +1474,7 @@ default_template:
limit: 50
sort_by: plays.desc
any:
artist_style: <<style>>
artist_style: <<value>>
```
</td>
@ -1494,7 +1494,7 @@ templates:
sort_by: plays.desc
type: albums
all:
album_style: <<style>>
album_style: <<value>>
dynamic_collections:
Styles: # mapping name does not matter just needs to be unique
type: style
@ -1538,9 +1538,10 @@ dynamic_collections:
Name of the template to use for these dynamic collections. Each `type` has its own default template, but if you want to define and use your own template you can.
Each template is passed a template variable whose name matches the dynamic collection `type`. i.e. in the example below `<<network>>` is the template variable.
`key` and `key_name` are both passed along and can be used as template variables.
Each template is passed a few template variables you can use.
* `value`: The list of keys and addons
* `key`: The dynamic key
* `key_name`: The key after `key_name_override`, `remove_prefix`, or `remove_suffix` are run on it.
For example, the template below removes the limit on the `smart_filter` so it shows all items in each network
@ -1550,7 +1551,7 @@ templates:
smart_filter:
sort_by: critic_rating.desc
all:
network: <<network>>
network: <<value>>
dynamic_collections:
Networks: # mapping name does not matter just needs to be unique
type: network
@ -1568,7 +1569,7 @@ For example, when using `type: tmdb_collections` and you want to define a poster
templates:
optional:
- my_collection_poster
tmdb_collection_details: <<collection_id>>
tmdb_collection_details: <<value>>
collection_order: release
url_poster: <<my_collection_poster>>
dynamic_collections:

View file

@ -132,7 +132,7 @@ class IMDb:
parental_dict = {}
expired = None
if self.config.Cache and not ignore_cache:
parental_dict, expired = self.config.Cache.query_imdb_parental(imdb_id, self.config.expiration)
parental_dict, expired = self.config.Cache.query_imdb_parental(imdb_id, self.config.Cache.expiration)
if parental_dict and expired is False:
return parental_dict
response = self.config.get_html(f"https://www.imdb.com/title/{imdb_id}/parentalguide")
@ -143,7 +143,7 @@ class IMDb:
else:
raise Failed(f"IMDb Error: No Item Found for IMDb ID: {imdb_id}")
if self.config.Cache and not ignore_cache:
self.config.Cache.update_imdb_parental(expired, imdb_id, parental_dict, self.config.expiration)
self.config.Cache.update_imdb_parental(expired, imdb_id, parental_dict, self.config.Cache.expiration)
return parental_dict
def _ids_from_chart(self, chart):

View file

@ -269,26 +269,31 @@ class MetadataFile(DataFile):
include = util.parse("Config", "include", dynamic, parent=map_name, methods=methods, datatype="list") if "include" in methods else []
if og_exclude and include:
raise Failed(f"Config Error: {map_name} cannot have both include and exclude attributes")
addons = util.parse("Config", "addons", dynamic, parent=map_name, methods=methods, datatype="dictlist") if "addons" in methods else {}
addons = util.parse("Config", "addons", dynamic, parent=map_name, methods=methods, datatype="dictliststr") if "addons" in methods else {}
exclude = [str(e) for e in og_exclude]
for k, v in addons.items():
if k in v:
logger.warning(f"Config Warning: {k} cannot be an addon for itself")
exclude.extend([str(vv) for vv in v if str(vv) != str(k)])
exclude.extend([y for y in v if y != k])
default_title_format = "<<key_name>>"
default_template = None
auto_list = {}
all_keys = []
dynamic_data = None
def _check_dict(check_dict):
for ck, cv in check_dict.items():
all_keys.append(ck)
if ck not in exclude and cv not in exclude:
auto_list[ck] = cv
if auto_type in ["genre", "mood", "style", "country", "network", "year", "decade", "content_rating", "subtitle_language", "audio_language", "resolution"]:
search_tag = auto_type_translation[auto_type] if auto_type in auto_type_translation else auto_type
tags = library.get_tags(search_tag)
if auto_type in ["decade", "subtitle_language", "audio_language"]:
auto_list = {str(i.key): i.title for i in library.get_tags(search_tag) if str(i.title) not in exclude and str(i.key) not in exclude}
all_keys = [str(i.key) for i in tags]
auto_list = {str(i.key): i.title for i in tags if str(i.title) not in exclude and str(i.key) not in exclude}
else:
auto_list = {str(i.title): i.title for i in library.get_tags(search_tag) if str(i.title) not in exclude}
all_keys = [str(i.title) for i in tags]
auto_list = {str(i.title): i.title for i in tags if str(i.title) not in exclude}
if library.is_music:
default_template = {"smart_filter": {"limit": 50, "sort_by": "plays.desc", "any": {f"artist_{auto_type}": f"<<{auto_type}>>"}}}
default_title_format = "Most Played <<key_name>> <<library_type>>s"
@ -305,8 +310,10 @@ class MetadataFile(DataFile):
logger.ghost(f"Processing: {i}/{len(all_items)} {item.title}")
tmdb_id, tvdb_id, imdb_id = library.get_ids(item)
tmdb_item = config.TMDb.get_item(item, tmdb_id, tvdb_id, imdb_id, is_movie=True)
if tmdb_item and tmdb_item.collection_id and tmdb_item.collection_id not in exclude and tmdb_item.collection_name not in exclude:
auto_list[str(tmdb_item.collection_id)] = tmdb_item.collection_name
if tmdb_item and tmdb_item.collection_id:
all_keys.append(str(tmdb_item.collection_id))
if tmdb_item.collection_id not in exclude and tmdb_item.collection_name not in exclude:
auto_list[str(tmdb_item.collection_id)] = tmdb_item.collection_name
logger.exorcise()
elif auto_type == "original_language":
if not all_items:
@ -315,8 +322,10 @@ class MetadataFile(DataFile):
logger.ghost(f"Processing: {i}/{len(all_items)} {item.title}")
tmdb_id, tvdb_id, imdb_id = library.get_ids(item)
tmdb_item = config.TMDb.get_item(item, tmdb_id, tvdb_id, imdb_id, is_movie=library.type == "Movie")
if tmdb_item and tmdb_item.language_iso and tmdb_item.language_iso not in exclude and tmdb_item.language_name not in exclude:
auto_list[tmdb_item.language_iso] = tmdb_item.language_name
if tmdb_item and tmdb_item.language_iso:
all_keys.append(tmdb_item.language_iso)
if tmdb_item.language_iso not in exclude and tmdb_item.language_name not in exclude:
auto_list[tmdb_item.language_iso] = tmdb_item.language_name
logger.exorcise()
default_title_format = "<<key_name>> <<library_type>>s"
elif auto_type == "origin_country":
@ -328,6 +337,7 @@ class MetadataFile(DataFile):
tmdb_item = config.TMDb.get_item(item, tmdb_id, tvdb_id, imdb_id, is_movie=library.type == "Movie")
if tmdb_item and tmdb_item.countries:
for country in tmdb_item.countries:
all_keys.append(country.iso_3166_1)
if country.iso_3166_1 not in exclude and country.name not in exclude:
auto_list[country.iso_3166_1] = country.name
logger.exorcise()
@ -457,9 +467,13 @@ class MetadataFile(DataFile):
for suffix in remove_suffix:
if key_name.endswith(suffix):
key_name = key_name[:-len(suffix)].strip()
key_value = [key]
if key in addons:
key_value.extend([a for a in addons[key] if a in all_keys])
template_call = {
"name": template_name,
auto_type: [key] + addons[key] if key in addons else [key],
"value": key_value,
auto_type: key_value,
"key_name": key_name, "key": key
}
for k, v in template_variables.items():

View file

@ -450,12 +450,14 @@ def parse(error, attribute, data, datatype=None, methods=None, parent=None, defa
else:
raise Failed(f"{error} Error: {display} {dict_data} is not a dictionary")
return final_list
elif datatype in ["dict", "dictlist", "dictdict", "strdict"]:
elif datatype in ["dict", "dictlist", "dictdict", "strdict", "dictliststr"]:
if isinstance(value, dict):
if datatype == "dict":
return value
elif datatype == "dictlist":
return {k: v if isinstance(v, list) else [v] for k, v in value.items()}
elif datatype == "dictliststr":
return {str(k): [str(y) for y in v] if isinstance(v, list) else [str(v)] for k, v in value.items()}
elif datatype == "strdict":
return {str(k): str(v) for k, v in value.items()}
else: