From 653d949f0e916f4ac36ce8c79154e3b79003f8b6 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Fri, 11 Mar 2022 10:33:22 -0500 Subject: [PATCH] [20] #763 add content_rating to dynamic collecitons --- VERSION | 2 +- docs/metadata/dynamic.md | 62 ++++++++++++++++++++++++++++++++++++++++ modules/meta.py | 17 +++++------ 3 files changed, 72 insertions(+), 9 deletions(-) diff --git a/VERSION b/VERSION index 357eb4f1..b053bdc3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.16.0-develop19 +1.16.0-develop20 diff --git a/docs/metadata/dynamic.md b/docs/metadata/dynamic.md index 2bc6f1bf..012103f4 100644 --- a/docs/metadata/dynamic.md +++ b/docs/metadata/dynamic.md @@ -119,6 +119,7 @@ Depending on the `type` of dynamic collection, `data` is used to specify the opt | [`writer`](#writer) | Create a collection for each writer found in the library | ✅ | ✅ | ❌ | ❌ | ❌ | | [`producer`](#producer) | Create a collection for each producer found in the library | ✅ | ✅ | ❌ | ❌ | ❌ | | [`genre`](#genre) | Create a collection for each 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 | ❌ | ✅ | ✅ | ❌ | ❌ | | [`decade`](#decade) | Create a collection for each decade found in the library | ❌ | ✅ | ❌ | ❌ | ❌ | | [`country`](#country) | Create a collection for each country found in the library | ❌ | ✅ | ❌ | ✅ | ✅ | @@ -913,6 +914,67 @@ dynamic_collections: template: genre collection ``` +### Content Rating + +Create a collection for each content rating found in the library. + + + + + + + + + + + + + + + + + + + + + + + + + + +
type Optioncontent_rating
data ValueNot Used
KeysContent Rating
Key NamesContent Rating
Default title_formatTop <<title>> <<library_type>>s
Default Template + +```yaml +default_template: + smart_filter: + limit: 50 + sort_by: critic_rating.desc + any: + content_rating: <> +``` + +
+ +#### Example: + +* Create dynamic collections based on each content rating found in the library (TV and Movies) +* Amend the template to increase the limit from 50 to 100 + +```yaml +templates: + content rating collection: + smart_filter: + limit: 100 + sort_by: critic_rating.desc + all: + content_rating: <> +dynamic_collections: + Content Ratings: # mapping name does not matter just needs to be unique + type: content_rating + template: content rating collection +``` + ### Year Create a collection for each year found in the library. diff --git a/modules/meta.py b/modules/meta.py index 6fb95083..b93b984d 100644 --- a/modules/meta.py +++ b/modules/meta.py @@ -11,18 +11,17 @@ logger = util.logger github_base = "https://raw.githubusercontent.com/meisnate12/Plex-Meta-Manager-Configs/master/" all_auto = ["genre"] -ms_auto = ["actor", "year", "original_language", "tmdb_popular_people", "trakt_user_lists", "trakt_liked_lists", "trakt_people_list"] +ms_auto = [ + "actor", "year", "content_rating", "original_language", "tmdb_popular_people", + "trakt_user_lists", "trakt_liked_lists", "trakt_people_list" +] auto = { "Movie": ["tmdb_collection", "decade", "country", "director", "producer", "writer"] + all_auto + ms_auto, "Show": ["network", "origin_country"] + all_auto + ms_auto, "Artist": ["mood", "style", "country"] + all_auto, - "Video": ["country"] + all_auto + "Video": ["country", "content_rating"] + all_auto } default_templates = { - "actor": {"tmdb_person": f"<>", "plex_search": {"all": {"actor": "tmdb"}}}, - "director": {"tmdb_person": f"<>", "plex_search": {"all": {"director": "tmdb"}}}, - "producer": {"tmdb_person": f"<>", "plex_search": {"all": {"producer": "tmdb"}}}, - "writer": {"tmdb_person": f"<>", "plex_search": {"all": {"writer": "tmdb"}}}, "original_language": {"plex_all": True, "filters": {"original_language": "<>"}}, "origin_country": {"plex_all": True, "filters": {"origin_country": "<>"}}, "tmdb_collection": {"tmdb_collection_details": "<>"}, @@ -280,8 +279,9 @@ class MetadataFile(DataFile): for ck, cv in check_dict.items(): 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"]: - auto_list = {i.title: i.title for i in library.get_tags(auto_type) if i.title not in exclude} + if auto_type in ["genre", "mood", "style", "country", "network", "year", "decade", "content_rating"]: + search_tag = "contentRating" if auto_type == "content_rating" else auto_type + auto_list = {i.title: i.title for i in library.get_tags(search_tag) 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 <> <>s" @@ -365,6 +365,7 @@ class MetadataFile(DataFile): person_count += 1 except TMDbNotFound: logger.error(f"TMDb Error: Actor {role['name']} Not Found") + default_template = {"tmdb_person": f"<<{auto_type}>>", "plex_search": {"all": {auto_type: "tmdb"}}}, elif auto_type == "trakt_user_lists": dynamic_data = util.parse("Config", "data", dynamic, parent=map_name, methods=methods, datatype="list") for option in dynamic_data: