[17] switch <<title>> to <<key_name>>

pull/790/head
meisnate12 3 years ago
parent 6cb1d33805
commit 022cf7668a

@ -1 +1 @@
1.16.0-develop16
1.16.0-develop17

@ -26,13 +26,17 @@ By default, the collections generated will be named for the thing being used to
There are many attributes that can change the titles, including `title_format`, `remove_suffix`, `remove_prefix`, `pre_format_override`, and `post_format_override` all detailed below.
## Dynamic Keys & Titles
## Dynamic Keys & Key Names
A `dynamic key` or `key` for short is used to refer to a specific value/result from the dynamic collection criteria that will be used to create the collection.
A `title` in this case is the name that replaces `<<title>>` in `title_format` to create the collection titles for each key.
A `key_name` is the name that replaces `<<key_name>>` in `title_format` to create the collection titles for each key.
An example of some keys that would be generated from a `genre` dynamic collection are; "Animation", "Horror" and "Comedy"
An example of some keys and their names that would be generated from a `tmdb_collections` dynamic collection are
* `key`: "10"
* `key_name`: Star Wars Collection
* `key`: "1241"
* `key_name`: Harry Potter Collection
### Example Key Usage
@ -776,7 +780,7 @@ dynamic_collections:
type: genre
exclude:
- Talk Show
title_format: Top <<title>> <<library_type>>s
title_format: Top <<key_name>> <<library_type>>s
template: genre collection
```
@ -836,7 +840,7 @@ dynamic_collections:
- 2020
- 2021
- 2022
title_format: Best of <<title>>
title_format: Best of <<key_name>>
```
### Decade
@ -891,7 +895,7 @@ default_template:
dynamic_collections:
Decades: # mapping name does not matter just needs to be unique
type: decade
title_format: Top <<title>> <<library_type>>s
title_format: Top <<key_name>> <<library_type>>s
post_format_override:
2020: Top 2020 Movies (so far)
```
@ -948,7 +952,7 @@ default_template:
dynamic_collections:
Countries: # mapping name does not matter just needs to be unique
type: country
title_format: Top <<country>> Cinema
title_format: Top <<key_name>> Cinema
pre_format_override:
France: French
Germany: German
@ -1012,7 +1016,7 @@ templates:
dynamic_collections:
Networks: # mapping name does not matter just needs to be unique
type: network
title_format: <<title>>
title_format: <<key_name>>
template: network collection
```
@ -1075,7 +1079,7 @@ templates:
dynamic_collections:
Moods: # mapping name does not matter just needs to be unique
type: mood
title_format: Top <<title>> Tracks
title_format: Top <<key_name>> Tracks
template: mood collection
```
@ -1138,7 +1142,7 @@ templates:
dynamic_collections:
Styles: # mapping name does not matter just needs to be unique
type: style
title_format: Top <<title>> Albums
title_format: Top <<key_name>> Albums
template: style collection
```
@ -1191,7 +1195,7 @@ templates:
dynamic_collections:
Networks: # mapping name does not matter just needs to be unique
type: network
title_format: <<title>>
title_format: <<key_name>>
template: network collection
```
@ -1236,7 +1240,7 @@ dynamic_collections:
This is the format for the collection titles.
there are two special tags you can include in the `title_format`
* `<<title>>` is required and is what will be replaced by the dynamic title
* `<<key_name>>` is required and is what will be replaced by the dynamic key name.
* `<<library_type>>` will be replaced with either Movie, Show, or Artist depending on your library type.
Here's an example using `title_format`.
@ -1245,7 +1249,7 @@ Here's an example using `title_format`.
dynamic_collections:
Genres: # mapping name does not matter just needs to be unique
type: genre
title_format: Top 50 <<title>> <<library_type>>s
title_format: Top 50 <<key_name>> <<library_type>>s
```
## Pre Format Override
@ -1259,7 +1263,7 @@ This example uses the `pre_format_override` attribute to change the formatting o
dynamic_collections:
Countries: # mapping name does not matter, just needs to be unique
type: country
title_format: <<country>> Cinema
title_format: <<key_name>> Cinema
pre_format_override:
France: French
```

@ -271,7 +271,7 @@ class MetadataFile(DataFile):
if k in v:
logger.warning(f"Config Warning: {k} cannot be an addon for itself")
exclude.extend([vv for vv in v if vv != k])
default_title_format = "<<title>>"
default_title_format = "<<key_name>>"
default_template = None
auto_list = {}
dynamic_data = None
@ -283,10 +283,10 @@ class MetadataFile(DataFile):
auto_list = {i.title: i.title for i in library.get_tags(auto_type) if 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 <<title>> <<library_type>>s"
default_title_format = "Most Played <<key_name>> <<library_type>>s"
else:
default_template = {"smart_filter": {"limit": 50, "sort_by": "critic_rating.desc", "any": {auto_type: f"<<{auto_type}>>"}}}
default_title_format = "Best <<library_type>>s of <<title>>" if auto_type in ["year", "decade"] else "Top <<title>> <<library_type>>s"
default_title_format = "Best <<library_type>>s of <<key_name>>" if auto_type in ["year", "decade"] else "Top <<key_name>> <<library_type>>s"
elif auto_type == "tmdb_collection":
if not all_items:
all_items = library.get_all()
@ -307,7 +307,7 @@ class MetadataFile(DataFile):
if tmdb_item and tmdb_item.original_language and tmdb_item.original_language.iso_639_1 not in exclude and tmdb_item.original_language.english_name not in exclude:
auto_list[tmdb_item.original_language.iso_639_1] = tmdb_item.original_language.english_name
logger.exorcise()
default_title_format = "<<title>> <<library_type>>s"
default_title_format = "<<key_name>> <<library_type>>s"
elif auto_type in ["actor", "director", "writer", "producer"]:
people = {}
if "data" in methods:
@ -369,8 +369,8 @@ class MetadataFile(DataFile):
title_format = default_title_format
if "title_format" in methods:
title_format = util.parse("Config", "title_format", dynamic, parent=map_name, methods=methods, default=default_title_format)
if "<<title>>" not in title_format:
logger.error(f"Config Error: <<title>> not in title_format: {title_format} using default: {default_title_format}")
if "<<key_name>>" not in title_format and "<<title>>" not in title_format:
logger.error(f"Config Error: <<key_name>> not in title_format: {title_format} using default: {default_title_format}")
title_format = default_title_format
post_format_override = util.parse("Config", "post_format_override", dynamic, parent=map_name, methods=methods, datatype="dict") if "post_format_override" in methods else {}
pre_format_override = util.parse("Config", "pre_format_override", dynamic, parent=map_name, methods=methods, datatype="dict") if "pre_format_override" in methods else {}
@ -434,7 +434,7 @@ class MetadataFile(DataFile):
for suffix in remove_suffix:
if value.endswith(suffix):
value = value[:-len(suffix)].strip()
collection_title = title_format.replace("<<title>>", value)
collection_title = title_format.replace("<<title>>", value).replace("<<key_name>>", value)
if collection_title in col_names:
logger.warning(f"Config Warning: Skipping duplicate collection: {collection_title}")
else:

Loading…
Cancel
Save