[17] add `tmdb_birthday`

pull/1391/head
meisnate12 2 years ago
parent 507ad51469
commit 85d12b406e

@ -1 +1 @@
1.19.0-develop16
1.19.0-develop17

@ -129,7 +129,9 @@ templates:
optional:
- tmdb_person
- tmdb_person_offset
- tmdb_birthday
tmdb_person: <<tmdb_person>>
tmdb_birthday: <<tmdb_birthday>>
tmdb_person_offset: <<tmdb_person_offset_<<key>>>>
url_poster: <<url_poster_<<key>>>>
conditionals:

@ -52,6 +52,7 @@ This file contains a [Separator](../separators) so all [Shared Separator Variabl
| `exclude` | **Description:** Exclude these Actors from creating a Dynamic Collection.<br>**Values:** List of Actor Names |
| `name_format` | **Description:** Changes the title format of the Dynamic Collections.<br>**Default:** `<<key_name>>`<br>**Values:** Any string with `<<key_name>>` in it. |
| `summary_format` | **Description:** Changes the summary format of the Dynamic Collections.<br>**Default:** `<<library_translationU>>s with <<key_name>>.`<br>**Values:** Any string with `<<key_name>>` 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.<br>**Values:** Any Number 0 or greater<br>**Default:** 0 |
| `tmdb_person_offset_<<key>>`<sup>1</sup> | **Description:** Changes the summary tmdb_person_offset for the specific key.<br>**Default:** `0`<br>**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 `<<key>>` with when calling.

@ -49,6 +49,7 @@ This file contains a [Separator](../separators) so all [Shared Separator Variabl
| `exclude` | **Description:** Exclude these Directors from creating a Dynamic Collection.<br>**Values:** List of Director Names |
| `name_format` | **Description:** Changes the title format of the Dynamic Collections.<br>**Default:** `<<key_name>> (Director)`<br>**Values:** Any string with `<<key_name>>` in it. |
| `summary_format` | **Description:** Changes the summary format of the Dynamic Collections.<br>**Default:** `<<library_translationU>>s directed by <<key_name>>.`<br>**Values:** Any string with `<<key_name>>` 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.<br>**Values:** Any Number 0 or greater<br>**Default:** 0 |
| `tmdb_person_offset_<<key>>`<sup>1</sup> | **Description:** Changes the summary tmdb_person_offset for the specific key.<br>**Default:** `0`<br>**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 `<<key>>` with when calling.

@ -49,6 +49,7 @@ This file contains a [Separator](../separators) so all [Shared Separator Variabl
| `exclude` | **Description:** Exclude these Producers from creating a Dynamic Collection.<br>**Values:** List of Producer Names |
| `name_format` | **Description:** Changes the title format of the Dynamic Collections.<br>**Default:** `<<key_name>> (Producer)`<br>**Values:** Any string with `<<key_name>>` in it. |
| `summary_format` | **Description:** Changes the summary format of the Dynamic Collections.<br>**Default:** `<<library_translationU>>s produced by <<key_name>>.`<br>**Values:** Any string with `<<key_name>>` 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.<br>**Values:** Any Number 0 or greater<br>**Default:** 0 |
| `tmdb_person_offset_<<key>>`<sup>1</sup> | **Description:** Changes the summary tmdb_person_offset for the specific key.<br>**Default:** `0`<br>**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 `<<key>>` with when calling.

@ -49,6 +49,7 @@ This file contains a [Separator](../separators) so all [Shared Separator Variabl
| `exclude` | **Description:** Exclude these Writers from creating a Dynamic Collection.<br>**Values:** List of Writer Names |
| `name_format` | **Description:** Changes the title format of the Dynamic Collections.<br>**Default:** `<<key_name>> (Writer)`<br>**Values:** Any string with `<<key_name>>` in it. |
| `summary_format` | **Description:** Changes the summary format of the Dynamic Collections.<br>**Default:** `<<library_translationU>>s written by <<key_name>>.`<br>**Values:** Any string with `<<key_name>>` 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.<br>**Values:** Any Number 0 or greater<br>**Default:** 0 |
| `tmdb_person_offset_<<key>>`<sup>1</sup> | **Description:** Changes the summary tmdb_person_offset for the specific key.<br>**Default:** `0`<br>**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 `<<key>>` with when calling.

@ -8,6 +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).<br>**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`.<br>**Values:** Any Number greater then 0<br>**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.<br>**Values:** Any Number 0 or greater<br>**Default:** 0 |
| `sort_title` | **Description:** Changes the sort title.<br>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 `~`.<br>**Values:** Text to change Sort Title |
| `content_rating` | **Description:** Changes the content rating.<br>**Values:** Text to change Content Rating |
| `label` | **Description:** Appends new labels.<br>**Values:** Comma-separated string of labels to append |

@ -45,7 +45,7 @@ ignored_details = [
"delete_not_scheduled", "tmdb_person", "build_collection", "collection_order", "builder_level", "overlay", "pmm_poster",
"validate_builders", "libraries", "sync_to_users", "exclude_users", "collection_name", "playlist_name", "name", "limit",
"blank_collection", "allowed_library_types", "run_definition", "delete_playlist", "ignore_blank_results", "only_run_on_create",
"delete_collections_named", "tmdb_person_offset", "append_label", "key_name", "translation_key", "translation_prefix"
"delete_collections_named", "tmdb_person_offset", "append_label", "key_name", "translation_key", "translation_prefix", "tmdb_birthday"
]
details = [
"ignore_ids", "ignore_imdb_ids", "server_preroll", "changes_webhooks", "collection_filtering", "collection_mode", "url_theme",
@ -757,6 +757,22 @@ class CollectionBuilder:
logger.debug(f"Value: {data[methods['tmdb_person_offset']]}")
self.tmdb_person_offset = util.parse(self.Type, "tmdb_person_offset", self.data, datatype="int", methods=methods, default=0, minimum=0)
self.tmdb_birthday = None
if "tmdb_birthday" in methods:
logger.debug("")
logger.debug("Validating Method: tmdb_birthday")
logger.debug(f"Value: {data[methods['tmdb_birthday']]}")
if not self.data[methods["tmdb_birthday"]]:
raise Failed(f"{self.Type} Error: tmdb_birthday attribute is blank")
parsed_birthday = util.parse(self.Type, "tmdb_birthday", self.data, datatype="dict", methods=methods)
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)
}
first_person = None
self.tmdb_person_birthday = None
if "tmdb_person" in methods:
logger.debug("")
logger.debug("Validating Method: tmdb_person")
@ -767,12 +783,16 @@ class CollectionBuilder:
valid_names = []
for tmdb_person in util.get_list(self.data[methods["tmdb_person"]]):
try:
if not first_person:
first_person = tmdb_person
person = self.config.TMDb.get_person(util.regex_first_int(tmdb_person, "TMDb Person ID"))
valid_names.append(person.name)
if person.biography:
self.summaries["tmdb_person"] = person.biography
if person.profile_url:
self.posters["tmdb_person"] = person.profile_url
if person.birthday and not self.tmdb_person_birthday:
self.tmdb_person_birthday = person.birthday
except Failed as e:
if str(e).startswith("TMDb Error"):
logger.error(e)
@ -786,6 +806,8 @@ class CollectionBuilder:
self.summaries["tmdb_person"] = results[result_index].biography
if results[result_index].profile_url:
self.posters["tmdb_person"] = results[result_index].profile_url
if results[result_index].birthday and not self.tmdb_person_birthday:
self.tmdb_person_birthday = results[result_index].birthday
except Failed as ee:
logger.error(ee)
if len(valid_names) > 0:
@ -793,6 +815,44 @@ class CollectionBuilder:
else:
raise Failed(f"{self.Type} Error: No valid TMDb Person IDs in {self.data[methods['tmdb_person']]}")
if self.tmdb_birthday:
if "tmdb_person" not in methods:
raise NotScheduled("Skipped because tmdb_person is required when using tmdb_birthday")
if not self.tmdb_person_birthday:
raise NotScheduled(f"Skipped because No Birthday was found for {first_person}")
now = datetime(self.current_time.year, self.current_time.month, self.current_time.day)
try:
delta = datetime(now.year, self.tmdb_person_birthday.month, self.tmdb_person_birthday.day)
except ValueError:
delta = datetime(now.year, self.tmdb_person_birthday.month, 28)
before_delta = delta
after_delta = delta
if delta < now:
try:
before_delta = datetime(now.year + 1, self.tmdb_person_birthday.month, self.tmdb_person_birthday.day)
except ValueError:
before_delta = datetime(now.year + 1, self.tmdb_person_birthday.month, 28)
elif delta > now:
try:
after_delta = datetime(now.year - 1, self.tmdb_person_birthday.month, self.tmdb_person_birthday.day)
except ValueError:
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"]:
suffix = ""
if self.details["delete_not_scheduled"]:
try:
self.obj = self.library.get_playlist(self.name) if self.playlist else self.library.get_collection(self.name, force_search=True)
logger.info(self.delete())
self.deleted = True
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}")
self.smart_url = None
self.smart_type_key = None
if "smart_url" in methods and not self.playlist and not self.overlay:

Loading…
Cancel
Save