diff --git a/VERSION b/VERSION index 0acb14be..b4b657be 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.16.5-develop85 +1.16.5-develop86 diff --git a/docs/metadata/dynamic.md b/docs/metadata/dynamic.md index d617f81b..85df7042 100644 --- a/docs/metadata/dynamic.md +++ b/docs/metadata/dynamic.md @@ -130,6 +130,8 @@ Depending on the `type` of dynamic collection, `data` is used to specify the opt | [`network`](#network) | Create a collection for each network found in the library | ❌ | ❌ | ✅ | ❌ | ❌ | | [`mood`](#mood) | Create a collection for each mood found in the library | ❌ | ❌ | ❌ | ✅ | ❌ | | [`style`](#style) | Create a collection for each style found in the library | ❌ | ❌ | ❌ | ✅ | ❌ | +| [`number`](#number) | Creates a collection for each number defined | ✅ | ✅ | ✅ | ✅ | ✅ | +| [`list`](#list) | Creates a collection for each item in the list defined | ✅ | ✅ | ✅ | ✅ | ✅ | ### TMDb Collection @@ -1562,6 +1564,90 @@ dynamic_collections: template: style collection ``` +### Number + +Creates a collection for each number defined. + + + + + + + + + + + + + + + + + + + + + + + + + + +
type Optionnumber
data Values + + + + + + + + + + + + + + + + + + + + +
AttributeDescription & Values
startingValues: Number greater then 0Default: 0
endingValues: Number greater then 1Default: 1
incrementValues: Number greater then 0Default: 1
+
KeysNumber
Key NamesNumber
Default title_format<<key_name>>
Default Template**None**
+ +### List + +Creates a collection for each item in the list defined . + + + + + + + + + + + + + + + + + + + + + + + + + + +
type Optionlist
data ValuesStrings to iterate
KeysString
Key NamesString
Default title_format<<key_name>>
Default Template**None**
+ ## Exclude Exclude this list of `keys` from being created into collections. diff --git a/modules/builder.py b/modules/builder.py index 2b5369c4..81a79190 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -331,18 +331,15 @@ class CollectionBuilder: else: raise Failed("Playlist Error: libraries attribute is required") - self.sync_to_users = config.general["playlist_sync_to_users"] if "sync_to_users" in methods or "sync_to_user" in methods: s_attr = f"sync_to_user{'s' if 'sync_to_users' in methods else ''}" logger.debug("") logger.debug(f"Validating Method: {s_attr}") logger.debug(f"Value: {self.data[methods[s_attr]]}") - if self.data[methods[s_attr]]: - self.sync_to_users = self.data[methods[s_attr]] - else: - logger.warning(f"Playlist Error: sync_to_users attribute is blank defaulting to playlist_sync_to_users: {self.sync_to_users}") + self.sync_to_users = self.data[methods[s_attr]] else: logger.warning(f"Playlist Error: sync_to_users attribute not found defaulting to playlist_sync_to_users: {self.sync_to_users}") + self.sync_to_users = config.general["playlist_sync_to_users"] plex_users = self.library.users if self.sync_to_users: diff --git a/modules/meta.py b/modules/meta.py index 460f70e7..bf650d49 100644 --- a/modules/meta.py +++ b/modules/meta.py @@ -7,7 +7,7 @@ from ruamel import yaml logger = util.logger -all_auto = ["genre"] +all_auto = ["genre", "number", "list"] ms_auto = [ "actor", "year", "content_rating", "original_language", "tmdb_popular_people", "trakt_user_lists", "studio", "trakt_liked_lists", "trakt_people_list", "subtitle_language", "audio_language", "resolution", "decade" @@ -451,6 +451,36 @@ class MetadataFile(DataFile): all_keys.append(role["name"]) person_count += 1 default_template = {"plex_search": {"any": {auto_type: "<>"}}} + elif auto_type == "number": + if "data" in methods: + dynamic_data = util.parse("Config", "data", dynamic, parent=map_name, methods=methods, datatype="dict") + else: + raise Failed(f"Config Error: {map_name} data attribute not found") + number_methods = {nm.lower(): nm for nm in dynamic_data} + if "starting" in number_methods and dynamic_data[number_methods["starting"]] == "current_year": + starting = datetime.now().year + else: + starting = util.parse("Config", "starting", dynamic_data, parent=f"{map_name} data", methods=number_methods, datatype="int", default=0, minimum=0) + if "ending" in number_methods and dynamic_data[number_methods["ending"]] == "current_year": + ending = datetime.now().year + else: + ending = util.parse("Config", "ending", dynamic_data, parent=f"{map_name} data", methods=number_methods, datatype="int", default=0, minimum=1) + increment = util.parse("Config", "increment", dynamic_data, parent=f"{map_name} data", methods=number_methods, datatype="int", default=1, minimum=1) + if starting > ending: + raise Failed(f"Config Error: {map_name} data ending must be greater then starting") + current = starting + while starting <= ending: + all_keys.append(str(current)) + if str(current) not in exclude and current not in exclude: + auto_list[str(current)] = str(current) + current += increment + elif auto_type == "list": + if "data" not in methods: + raise Failed(f"Config Error: {map_name} data attribute not found") + for list_item in util.parse("Config", "data", dynamic, parent=map_name, methods=methods, datatype="strlist"): + all_keys.append(list_item) + if list_item not in exclude: + auto_list[list_item] = list_item 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: @@ -505,6 +535,8 @@ class MetadataFile(DataFile): has_var = True if not has_var: raise Failed(f"Config Error: One {map_name} template: {template_names} is required to have the template variable <>") + elif auto_type in ["number", "list"]: + raise Failed(f"Config Error: {map_name} template required for type: {auto_type}") else: self.templates[map_name] = (default_template if default_template else default_templates[auto_type], {}) template_names = [map_name]