diff --git a/VERSION b/VERSION index 65d36a53..262a7f89 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.18.3-develop5 +1.18.3-develop6 diff --git a/docs/metadata/dynamic.md b/docs/metadata/dynamic.md index c4e8ef07..b42ec036 100644 --- a/docs/metadata/dynamic.md +++ b/docs/metadata/dynamic.md @@ -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 | ❌ | ❌ | ❌ | ✅ | ❌ | | [`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 | ❌ | ✅ | ✅ | ❌ | ❌ | +| [`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 | ❌ | ✅ | ✅ | ❌ | ❌ | | [`country`](#country) | Create a collection for each country 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 <> ``` +### Episode Year + +Create a collection for each episode year found in the library. + + + + + + + + + + + + + + + + + + + + + + + + + + +
type Optionepisode_year
data ValueNot Used
KeysEpisode Year
Key NamesYear
Default title_formatBest <<library_type>>s of <<key_name>>
Default Template + +```yaml +default_template: + smart_filter: + limit: 50 + sort_by: critic_rating.desc + any: + episode_year: <> +``` + +
+ +#### 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 <> +``` + ### Decade Create a collection for each decade found in the library diff --git a/modules/meta.py b/modules/meta.py index 6b50ec49..d97ae273 100644 --- a/modules/meta.py +++ b/modules/meta.py @@ -13,7 +13,7 @@ ms_auto = [ ] 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, "Video": ["country", "content_rating"] + all_auto } @@ -23,7 +23,8 @@ dynamic_attributes = [ ] auto_type_translation = { "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 = { "original_language": {"plex_all": True, "filters": {"original_language": "<>"}}, @@ -486,8 +487,9 @@ class DataFile: if match: try: final = final.replace(f"<<{match.group(1)}>>", str(int(actual_value) + (int(match.group(3)) * (-1 if match.group(2) == "-" else 1)))) - except ValueError: - raise Failed(f"Template Error: {actual_value} must be a number to use {match.group(1)}") + except (ValueError, TypeError): + logger.error(f"Template Error: {actual_value} must be a number to use {match.group(1)}") + raise Failed return final else: 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} default_template = {"smart_filter": {"limit": 50, "sort_by": "critic_rating.desc", "any": {"year": "<>"}}} default_title_format = "Best <>s of <>" - 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 if library.is_show and auto_type in ["resolution", "subtitle_language", "audio_language"]: tags = library.get_tags(f"episode.{search_tag}") @@ -714,7 +716,7 @@ class MetadataFile(DataFile): default_title_format = "<> <>s" else: default_template = {"smart_filter": {"limit": 50, "sort_by": "critic_rating.desc", "any": {f"{auto_type}.is" if auto_type == "studio" else auto_type: "<>"}}} - default_title_format = "Best <>s of <>" if auto_type in ["year", "decade"] else "Top <> <>s" + default_title_format = "Best <>s of <>" if auto_type in ["year", "decade", "episode_year"] else "Top <> <>s" elif auto_type == "tmdb_collection": all_items = library.get_all() for i, item in enumerate(all_items, 1):