From f16710e3c70b3d9e0ded4d4227e75199c4cf9ab1 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Tue, 18 Apr 2023 13:50:39 -0400 Subject: [PATCH] [18] adds this month to birthdays --- VERSION | 2 +- defaults/templates.yml | 1 + docs/defaults/both/actor.md | 2 +- docs/defaults/movie/director.md | 2 +- docs/defaults/movie/producer.md | 2 +- docs/defaults/movie/writer.md | 2 +- docs/metadata/details/metadata.md | 2 +- modules/builder.py | 16 ++++++++++++---- 8 files changed, 19 insertions(+), 10 deletions(-) diff --git a/VERSION b/VERSION index d5728b4e..87ab12d4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.19.0-develop17 +1.19.0-develop18 diff --git a/defaults/templates.yml b/defaults/templates.yml index 73b7d8c6..f375638c 100644 --- a/defaults/templates.yml +++ b/defaults/templates.yml @@ -133,6 +133,7 @@ templates: tmdb_person: <> tmdb_birthday: <> tmdb_person_offset: <>>> + delete_not_scheduled: true url_poster: <>>> conditionals: extra: diff --git a/docs/defaults/both/actor.md b/docs/defaults/both/actor.md index 935f96dd..255e591d 100644 --- a/docs/defaults/both/actor.md +++ b/docs/defaults/both/actor.md @@ -52,7 +52,7 @@ This file contains a [Separator](../separators) so all [Shared Separator Variabl | `exclude` | **Description:** Exclude these Actors from creating a Dynamic Collection.
**Values:** List of Actor Names | | `name_format` | **Description:** Changes the title format of the Dynamic Collections.
**Default:** `<>`
**Values:** Any string with `<>` in it. | | `summary_format` | **Description:** Changes the summary format of the Dynamic Collections.
**Default:** `<>s with <>.`
**Values:** Any string with `<>` in it. | -| `tmdb_birthday` | **Description:** Has 2 possible attributes `before` and `after` which represents the number of days before/after the `tmdb_person`'s birthday which allows the definition to run.
**Values:** Any Number 0 or greater
**Default:** 0 | +| `tmdb_birthday` | **Description:** Controls if the Definition is run based on `tmdb_person`'s Birthday. Has 3 possible attributes `this_month`, `before` and `after`.
**Values:**
`this_month`Run's if Birthday is in current Month`true`/`false`
`before`Run if X Number of Days before the BirthdayNumber 0 or greater
`after`Run if X Number of Days after the BirthdayNumber 0 or greater
| | `tmdb_person_offset_<>`1 | **Description:** Changes the summary tmdb_person_offset for the specific key.
**Default:** `0`
**Values:** Dictionary of Actor Name as the keys and the tmdb_person_offset as the value. | 1. Each default collection has a `key` that when calling to effect a specific collection you must replace `<>` with when calling. diff --git a/docs/defaults/movie/director.md b/docs/defaults/movie/director.md index ced1c3f9..b4e779cb 100644 --- a/docs/defaults/movie/director.md +++ b/docs/defaults/movie/director.md @@ -49,7 +49,7 @@ This file contains a [Separator](../separators) so all [Shared Separator Variabl | `exclude` | **Description:** Exclude these Directors from creating a Dynamic Collection.
**Values:** List of Director Names | | `name_format` | **Description:** Changes the title format of the Dynamic Collections.
**Default:** `<> (Director)`
**Values:** Any string with `<>` in it. | | `summary_format` | **Description:** Changes the summary format of the Dynamic Collections.
**Default:** `<>s directed by <>.`
**Values:** Any string with `<>` in it. | -| `tmdb_birthday` | **Description:** Has 2 possible attributes `before` and `after` which represents the number of days before/after the `tmdb_person`'s birthday which allows the definition to run.
**Values:** Any Number 0 or greater
**Default:** 0 | +| `tmdb_birthday` | **Description:** Controls if the Definition is run based on `tmdb_person`'s Birthday. Has 3 possible attributes `this_month`, `before` and `after`.
**Values:**
`this_month`Run's if Birthday is in current Month`true`/`false`
`before`Run if X Number of Days before the BirthdayNumber 0 or greater
`after`Run if X Number of Days after the BirthdayNumber 0 or greater
| | `tmdb_person_offset_<>`1 | **Description:** Changes the summary tmdb_person_offset for the specific key.
**Default:** `0`
**Values:** Dictionary of Actor Name as the keys and the tmdb_person_offset as the value. | 1. Each default collection has a `key` that when calling to effect a specific collection you must replace `<>` with when calling. diff --git a/docs/defaults/movie/producer.md b/docs/defaults/movie/producer.md index e44ed0c2..549405fd 100644 --- a/docs/defaults/movie/producer.md +++ b/docs/defaults/movie/producer.md @@ -49,7 +49,7 @@ This file contains a [Separator](../separators) so all [Shared Separator Variabl | `exclude` | **Description:** Exclude these Producers from creating a Dynamic Collection.
**Values:** List of Producer Names | | `name_format` | **Description:** Changes the title format of the Dynamic Collections.
**Default:** `<> (Producer)`
**Values:** Any string with `<>` in it. | | `summary_format` | **Description:** Changes the summary format of the Dynamic Collections.
**Default:** `<>s produced by <>.`
**Values:** Any string with `<>` in it. | -| `tmdb_birthday` | **Description:** Has 2 possible attributes `before` and `after` which represents the number of days before/after the `tmdb_person`'s birthday which allows the definition to run.
**Values:** Any Number 0 or greater
**Default:** 0 | +| `tmdb_birthday` | **Description:** Controls if the Definition is run based on `tmdb_person`'s Birthday. Has 3 possible attributes `this_month`, `before` and `after`.
**Values:**
`this_month`Run's if Birthday is in current Month`true`/`false`
`before`Run if X Number of Days before the BirthdayNumber 0 or greater
`after`Run if X Number of Days after the BirthdayNumber 0 or greater
| | `tmdb_person_offset_<>`1 | **Description:** Changes the summary tmdb_person_offset for the specific key.
**Default:** `0`
**Values:** Dictionary of Actor Name as the keys and the tmdb_person_offset as the value. | 1. Each default collection has a `key` that when calling to effect a specific collection you must replace `<>` with when calling. diff --git a/docs/defaults/movie/writer.md b/docs/defaults/movie/writer.md index 5b3eff5c..7bc9cc08 100644 --- a/docs/defaults/movie/writer.md +++ b/docs/defaults/movie/writer.md @@ -49,7 +49,7 @@ This file contains a [Separator](../separators) so all [Shared Separator Variabl | `exclude` | **Description:** Exclude these Writers from creating a Dynamic Collection.
**Values:** List of Writer Names | | `name_format` | **Description:** Changes the title format of the Dynamic Collections.
**Default:** `<> (Writer)`
**Values:** Any string with `<>` in it. | | `summary_format` | **Description:** Changes the summary format of the Dynamic Collections.
**Default:** `<>s written by <>.`
**Values:** Any string with `<>` in it. | -| `tmdb_birthday` | **Description:** Has 2 possible attributes `before` and `after` which represents the number of days before/after the `tmdb_person`'s birthday which allows the definition to run.
**Values:** Any Number 0 or greater
**Default:** 0 | +| `tmdb_birthday` | **Description:** Controls if the Definition is run based on `tmdb_person`'s Birthday. Has 3 possible attributes `this_month`, `before` and `after`.
**Values:**
`this_month`Run's if Birthday is in current Month`true`/`false`
`before`Run if X Number of Days before the BirthdayNumber 0 or greater
`after`Run if X Number of Days after the BirthdayNumber 0 or greater
| | `tmdb_person_offset_<>`1 | **Description:** Changes the summary tmdb_person_offset for the specific key.
**Default:** `0`
**Values:** Dictionary of Actor Name as the keys and the tmdb_person_offset as the value. | 1. Each default collection has a `key` that when calling to effect a specific collection you must replace `<>` with when calling. diff --git a/docs/metadata/details/metadata.md b/docs/metadata/details/metadata.md index fb5e16ce..b687622a 100644 --- a/docs/metadata/details/metadata.md +++ b/docs/metadata/details/metadata.md @@ -8,7 +8,7 @@ All the following attributes update various details of the definition's Metadata |:-----------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `tmdb_person` | **Description:** Changes summary and poster to a TMDb Person's biography and profile to the first specified person as well as allow the people specified to be used in [Plex Searches](../builders/plex.md#plex-search).
**Values:** TMDb Person ID or Actor Name (Will pull the first ID from the TMDb search results) (List or Comma-separated string) | | `tmdb_person_offset` | **Description:** Offsets which search results are used by `tmdb_person`.
**Values:** Any Number greater then 0
**Default:** 0 | -| `tmdb_birthday` | **Description:** Has 2 possible attributes `before` and `after` which represents the number of days before/after the `tmdb_person`'s birthday which allows the definition to run.
**Values:** Any Number 0 or greater
**Default:** 0 | +| `tmdb_birthday` | **Description:** Controls if the Definition is run based on `tmdb_person`'s Birthday. Has 3 possible attributes `this_month`, `before` and `after`.
**Values:**
`this_month`Run's if Birthday is in current Month`true`/`false`
`before`Run if X Number of Days before the BirthdayNumber 0 or greater
`after`Run if X Number of Days after the BirthdayNumber 0 or greater
| | `sort_title` | **Description:** Changes the sort title.
You can "promote" certain collections to the top of a library by creating a sort title starting with a `+` or "demote" certain collections to the bottom of a library by creating a sort title starting with a `~`.
**Values:** Text to change Sort Title | | `content_rating` | **Description:** Changes the content rating.
**Values:** Text to change Content Rating | | `label` | **Description:** Appends new labels.
**Values:** Comma-separated string of labels to append | diff --git a/modules/builder.py b/modules/builder.py index 30ccc61b..2282a052 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -289,6 +289,7 @@ class CollectionBuilder: if key_name_key and key_name_key in translations["key_names"]: trans_key = translations["key_names"][key_name_key] logger.debug(f"Value: {trans_key}") + self.key_name = trans_key en_name = None en_summary = None @@ -768,7 +769,8 @@ class CollectionBuilder: parsed_methods = {m.lower(): m for m in parsed_birthday} self.tmdb_birthday = { "before": util.parse(self.Type, "before", parsed_birthday, datatype="int", methods=parsed_methods, minimum=0, default=0), - "after": util.parse(self.Type, "after", parsed_birthday, datatype="int", methods=parsed_methods, minimum=0, default=0) + "after": util.parse(self.Type, "after", parsed_birthday, datatype="int", methods=parsed_methods, minimum=0, default=0), + "this_month": util.parse(self.Type, "this_month", parsed_birthday, datatype="bool", methods=parsed_methods, default=False) } first_person = None @@ -841,7 +843,13 @@ class CollectionBuilder: after_delta = datetime(now.year - 1, self.tmdb_person_birthday.month, 28) days_after = (now - after_delta).days days_before = (before_delta - now).days - if days_before > self.tmdb_birthday["before"] and days_after > self.tmdb_birthday["after"]: + msg = "" + if self.tmdb_birthday["this_month"]: + if now.month != self.tmdb_person_birthday.month: + msg = f"Skipped because Birthday Month: {self.tmdb_person_birthday.month} is not {now.month}" + elif days_before > self.tmdb_birthday["before"] and days_after > self.tmdb_birthday["after"]: + msg = f"Skipped because days until {self.tmdb_person_birthday.month}/{self.tmdb_person_birthday.day}: {days_before} > {self.tmdb_birthday['before']} and days after {self.tmdb_person_birthday.month}/{self.tmdb_person_birthday.day}: {days_after} > {self.tmdb_birthday['after']}" + if msg: suffix = "" if self.details["delete_not_scheduled"]: try: @@ -851,7 +859,7 @@ class CollectionBuilder: suffix = f" and was deleted" except Failed: suffix = f" and could not be found to delete" - raise NotScheduled(f"Skipped because days until {self.tmdb_person_birthday.month}/{self.tmdb_person_birthday.day}: {days_before} > {self.tmdb_birthday['before']} and days after {self.tmdb_person_birthday.month}/{self.tmdb_person_birthday.day}: {days_after} > {self.tmdb_birthday['after']}{suffix}") + raise NotScheduled(f"{msg}{suffix}") self.smart_url = None self.smart_type_key = None @@ -1130,7 +1138,7 @@ class CollectionBuilder: def _summary(self, method_name, method_data): if method_name == "summary": - self.summaries[method_name] = method_data + self.summaries[method_name] = str(method_data).replace("<>", self.key_name) if self.key_name else method_data elif method_name == "tmdb_summary": self.summaries[method_name] = self.config.TMDb.get_movie_show_or_collection(util.regex_first_int(method_data, "TMDb ID"), self.library.is_movie).overview elif method_name == "tmdb_description":