[6] add episode_year dynamic collection option

pull/1282/head
meisnate12 2 years ago
parent ec4a9bc0c1
commit dc5e52b146

@ -1 +1 @@
1.18.3-develop5 1.18.3-develop6

@ -123,6 +123,7 @@ Depending on the `type` of dynamic collection, `data` is used to specify the opt
| [`album_genre`](#album-genre) | Create a collection for each album genre found in the library | ❌ | ❌ | ❌ | ✅ | ❌ | | [`album_genre`](#album-genre) | Create a collection for each album genre found in the library | ❌ | ❌ | ❌ | ✅ | ❌ |
| [`content_rating`](#content-rating) | Create a collection for each content rating found in the library | ❌ | ✅ | ✅ | ❌ | ✅ | | [`content_rating`](#content-rating) | Create a collection for each content rating found in the library | ❌ | ✅ | ✅ | ❌ | ✅ |
| [`year`](#year) | Create a collection for each year found in the library | ❌ | ✅ | ✅ | ❌ | ❌ | | [`year`](#year) | Create a collection for each year found in the library | ❌ | ✅ | ✅ | ❌ | ❌ |
| [`episode_year`](#episode-year) | Create a collection for each episode year found in the library | ❌ | ✅ | ✅ | ❌ | ❌ |
| [`decade`](#decade) | Create a collection for each decade found in the library | ❌ | ✅ | ✅ | ❌ | ❌ | | [`decade`](#decade) | Create a collection for each decade found in the library | ❌ | ✅ | ✅ | ❌ | ❌ |
| [`country`](#country) | Create a collection for each country found in the library | ❌ | ✅ | ❌ | ✅ | ✅ | | [`country`](#country) | Create a collection for each country found in the library | ❌ | ✅ | ❌ | ✅ | ✅ |
| [`resolution`](#resolution) | Create a collection for each resolution found in the library | ❌ | ✅ | ✅ | ❌ | ❌ | | [`resolution`](#resolution) | Create a collection for each resolution found in the library | ❌ | ✅ | ✅ | ❌ | ❌ |
@ -1109,6 +1110,65 @@ dynamic_collections:
title_format: Best of <<key_name>> title_format: Best of <<key_name>>
``` ```
### Episode Year
Create a collection for each episode year found in the library.
<table class="dualTable colwidths-auto align-default table">
<tr>
<th><code>type</code> Option</th>
<td><code>episode_year</code></td>
</tr>
<tr>
<th><code>data</code> Value</th>
<td>Not Used</td>
</tr>
<tr>
<th>Keys</th>
<td>Episode Year</td>
</tr>
<tr>
<th>Key Names</th>
<td>Year</td>
</tr>
<tr>
<th>Default <code>title_format</code></th>
<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>
<td>
```yaml
default_template:
smart_filter:
limit: 50
sort_by: critic_rating.desc
any:
episode_year: <<value>>
```
</td>
</tr>
</table>
#### Example
* Create dynamic collections based on each year found in the library (TV and Movies)
* Use the `include` attribute to only show collections for years "2020", "2021" and "2022"
* Name the collection "Best of [Year]"
```yaml
dynamic_collections:
Years: # mapping name does not matter just needs to be unique
type: episode_year
include:
- 2020
- 2021
- 2022
title_format: Best of <<key_name>>
```
### Decade ### Decade
Create a collection for each decade found in the library Create a collection for each decade found in the library

@ -13,7 +13,7 @@ ms_auto = [
] ]
auto = { auto = {
"Movie": ["tmdb_collection", "edition", "country", "director", "producer", "writer"] + all_auto + ms_auto, "Movie": ["tmdb_collection", "edition", "country", "director", "producer", "writer"] + all_auto + ms_auto,
"Show": ["network", "origin_country"] + all_auto + ms_auto, "Show": ["network", "origin_country", "episode_year"] + all_auto + ms_auto,
"Artist": ["mood", "style", "country", "album_genre", "album_mood", "album_style", "track_mood"] + all_auto, "Artist": ["mood", "style", "country", "album_genre", "album_mood", "album_style", "track_mood"] + all_auto,
"Video": ["country", "content_rating"] + all_auto "Video": ["country", "content_rating"] + all_auto
} }
@ -23,7 +23,8 @@ dynamic_attributes = [
] ]
auto_type_translation = { auto_type_translation = {
"content_rating": "contentRating", "subtitle_language": "subtitleLanguage", "audio_language": "audioLanguage", "content_rating": "contentRating", "subtitle_language": "subtitleLanguage", "audio_language": "audioLanguage",
"album_genre": "album.genre", "album_style": "album.style", "album_mood": "album.mood", "track_mood": "track.mood", "edition": "editionTitle" "album_genre": "album.genre", "album_style": "album.style", "album_mood": "album.mood", "track_mood": "track.mood",
"edition": "editionTitle", "episode_year": "episode.year"
} }
default_templates = { default_templates = {
"original_language": {"plex_all": True, "filters": {"original_language": "<<value>>"}}, "original_language": {"plex_all": True, "filters": {"original_language": "<<value>>"}},
@ -486,8 +487,9 @@ class DataFile:
if match: if match:
try: try:
final = final.replace(f"<<{match.group(1)}>>", str(int(actual_value) + (int(match.group(3)) * (-1 if match.group(2) == "-" else 1)))) final = final.replace(f"<<{match.group(1)}>>", str(int(actual_value) + (int(match.group(3)) * (-1 if match.group(2) == "-" else 1))))
except ValueError: except (ValueError, TypeError):
raise Failed(f"Template Error: {actual_value} must be a number to use {match.group(1)}") logger.error(f"Template Error: {actual_value} must be a number to use {match.group(1)}")
raise Failed
return final return final
else: else:
return og_txt return og_txt
@ -681,7 +683,7 @@ class MetadataFile(DataFile):
auto_list = {str(k): f"{k}s" for k in addons if str(k) not in exclude and f"{k}s" not in exclude} auto_list = {str(k): f"{k}s" for k in addons if str(k) not in exclude and f"{k}s" not in exclude}
default_template = {"smart_filter": {"limit": 50, "sort_by": "critic_rating.desc", "any": {"year": "<<value>>"}}} default_template = {"smart_filter": {"limit": 50, "sort_by": "critic_rating.desc", "any": {"year": "<<value>>"}}}
default_title_format = "Best <<library_type>>s of <<key_name>>" default_title_format = "Best <<library_type>>s of <<key_name>>"
elif auto_type in ["genre", "mood", "style", "album_genre", "album_mood", "album_style", "track_mood", "country", "studio", "edition", "network", "year", "decade", "content_rating", "subtitle_language", "audio_language", "resolution"]: elif auto_type in ["genre", "mood", "style", "album_genre", "album_mood", "album_style", "track_mood", "country", "studio", "edition", "network", "year", "episode_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 search_tag = auto_type_translation[auto_type] if auto_type in auto_type_translation else auto_type
if library.is_show and auto_type in ["resolution", "subtitle_language", "audio_language"]: if library.is_show and auto_type in ["resolution", "subtitle_language", "audio_language"]:
tags = library.get_tags(f"episode.{search_tag}") tags = library.get_tags(f"episode.{search_tag}")
@ -714,7 +716,7 @@ class MetadataFile(DataFile):
default_title_format = "<<key_name>> <<library_type>>s" default_title_format = "<<key_name>> <<library_type>>s"
else: else:
default_template = {"smart_filter": {"limit": 50, "sort_by": "critic_rating.desc", "any": {f"{auto_type}.is" if auto_type == "studio" else auto_type: "<<value>>"}}} default_template = {"smart_filter": {"limit": 50, "sort_by": "critic_rating.desc", "any": {f"{auto_type}.is" if auto_type == "studio" else auto_type: "<<value>>"}}}
default_title_format = "Best <<library_type>>s of <<key_name>>" if auto_type in ["year", "decade"] else "Top <<key_name>> <<library_type>>s" default_title_format = "Best <<library_type>>s of <<key_name>>" if auto_type in ["year", "decade", "episode_year"] else "Top <<key_name>> <<library_type>>s"
elif auto_type == "tmdb_collection": elif auto_type == "tmdb_collection":
all_items = library.get_all() all_items = library.get_all()
for i, item in enumerate(all_items, 1): for i, item in enumerate(all_items, 1):

Loading…
Cancel
Save