[10] expand ignore_blank_results

pull/1171/head
meisnate12 2 years ago
parent 7a70ab8f4c
commit 2b90478ea7

@ -1 +1 @@
1.18.0-develop9 1.18.0-develop10

@ -47,8 +47,8 @@ dynamic_collections:
type: number type: number
sync: true sync: true
data: data:
starting: current_year-5 starting: current_year-6
ending: current_year ending: current_year-1
title_format: Oscars Winners <<key_name>> title_format: Oscars Winners <<key_name>>
template: template:
- use_year_collections - use_year_collections

@ -34,11 +34,11 @@ Note that the `templates_variables:` section only needs to be used if you do wan
All [Shared Collection Variables](../collection_variables) are available as well as the additional Variables below which can be used to customize the file. All [Shared Collection Variables](../collection_variables) are available as well as the additional Variables below which can be used to customize the file.
| Variable | Description & Values | | Variable | Description & Values |
|:---------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |:---------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `use_year_collections` | **Description:** Turn the individual year collections off.<br>**Values:** `false` to turn of the collections | | `use_year_collections` | **Description:** Turn the individual year collections off.<br>**Values:** `false` to turn of the collections |
| `collection_order` | **Description:** Changes the Collection Order for all collections in a Defaults file.<br>**Default:** `custom`<br>**Values:**<table class="clearTable"><tr><td>`release`</td><td>Order Collection by Release Dates</td></tr><tr><td>`alpha`</td><td>Order Collection Alphabetically</td></tr><tr><td>`custom`</td><td>Order Collection Via the Builder Order</td></tr><tr><td>[Any `plex_search` Sort Option](../../metadata/builders/plex.md#sort-options)</td><td>Order Collection by any `plex_search` Sort Option</td></tr></table> | | `collection_order` | **Description:** Changes the Collection Order for all collections in a Defaults file.<br>**Default:** `custom`<br>**Values:**<table class="clearTable"><tr><td>`release`</td><td>Order Collection by Release Dates</td></tr><tr><td>`alpha`</td><td>Order Collection Alphabetically</td></tr><tr><td>`custom`</td><td>Order Collection Via the Builder Order</td></tr><tr><td>[Any `plex_search` Sort Option](../../metadata/builders/plex.md#sort-options)</td><td>Order Collection by any `plex_search` Sort Option</td></tr></table> |
| `collection_order_<<key>>`<sup>1</sup> | **Description:** Changes the Collection Order of the specified key's collection.<br>**Default:** `collection_order`<br>**Values:**<table class="clearTable"><tr><td>`release`</td><td>Order Collection by Release Dates</td></tr><tr><td>`alpha`</td><td>Order Collection Alphabetically</td></tr><tr><td>`custom`</td><td>Order Collection Via the Builder Order</td></tr><tr><td>[Any `plex_search` Sort Option](../../metadata/builders/plex.md#sort-options)</td><td>Order Collection by any `plex_search` Sort Option</td></tr></table> | | `collection_order_<<key>>`<sup>1</sup> | **Description:** Changes the Collection Order of the specified key's collection.<br>**Default:** `collection_order`<br>**Values:**<table class="clearTable"><tr><td>`release`</td><td>Order Collection by Release Dates</td></tr><tr><td>`alpha`</td><td>Order Collection Alphabetically</td></tr><tr><td>`custom`</td><td>Order Collection Via the Builder Order</td></tr><tr><td>[Any `plex_search` Sort Option](../../metadata/builders/plex.md#sort-options)</td><td>Order Collection by any `plex_search` Sort Option</td></tr></table> |
| `data` | **Description:** Replaces the `data` dynamic collection value.<br><table class="clearTable"><tr><th>Attribute</th><th>Description & Values</th></tr><tr><td><code>starting</code></td><td>Controls the starting year for collections<hr><strong>Default:</strong> current_year-5<hr><strong>Values:</strong> Number greater than 0</td></tr><tr><td><code>ending</code></td><td>Controls the ending year for collections<hr><strong>Default:</strong> current_year<hr><strong>Values:</strong> Number greater than 1</td></tr><tr><td><code>increment</code></td><td>Controls the increment (i.e. every 5th year)<hr><strong>Default:</strong> 1<hr><strong>Values:</strong> Number greater than 0</td><td></td></tr></table><ul><li><strong><code>starting</code> and <code>ending</code> can also have the value <code>current_year</code></strong></li><li><strong>You can also use a value relative to the <code>current_year</code> by doing <code>current_year-5</code></strong></li></ul> | | `data` | **Description:** Replaces the `data` dynamic collection value.<br><table class="clearTable"><tr><th>Attribute</th><th>Description & Values</th></tr><tr><td><code>starting</code></td><td>Controls the starting year for collections<hr><strong>Default:</strong> current_year-6<hr><strong>Values:</strong> Number greater than 0</td></tr><tr><td><code>ending</code></td><td>Controls the ending year for collections<hr><strong>Default:</strong> current_year-1<hr><strong>Values:</strong> Number greater than 1</td></tr><tr><td><code>increment</code></td><td>Controls the increment (i.e. every 5th year)<hr><strong>Default:</strong> 1<hr><strong>Values:</strong> Number greater than 0</td><td></td></tr></table><ul><li><strong><code>starting</code> and <code>ending</code> can also have the value <code>current_year</code></strong></li><li><strong>You can also use a value relative to the <code>current_year</code> by doing <code>current_year-5</code></strong></li></ul> |
| `exclude` | **Description:** Exclude these Years from creating a Dynamic Collection.<br>**Values:** List of Years | | `exclude` | **Description:** Exclude these Years from creating a Dynamic Collection.<br>**Values:** List of Years |
1. Each default collection has a `key` that when calling to effect a specific collection you must replace `<<key>>` with when calling. 1. Each default collection has a `key` that when calling to effect a specific collection you must replace `<<key>>` with when calling.
@ -56,7 +56,7 @@ libraries:
radarr_add_missing: true radarr_add_missing: true
data: data:
starting: current_year-10 starting: current_year-10
ending: current_year ending: current_year-1
``` ```

@ -1,7 +1,7 @@
import os, re, time import os, re, time
from datetime import datetime from datetime import datetime
from modules import anidb, anilist, flixpatrol, icheckmovies, imdb, letterboxd, mal, plex, radarr, reciperr, sonarr, tautulli, tmdb, trakt, tvdb, mdblist, util from modules import anidb, anilist, flixpatrol, icheckmovies, imdb, letterboxd, mal, plex, radarr, reciperr, sonarr, tautulli, tmdb, trakt, tvdb, mdblist, util
from modules.util import Failed, NonExisting, NotScheduled, NotScheduledRange, Deleted from modules.util import Failed, FilterFailed, NonExisting, NotScheduled, NotScheduledRange, Deleted
from modules.overlay import Overlay from modules.overlay import Overlay
from plexapi.audio import Artist, Album, Track from plexapi.audio import Artist, Album, Track
from plexapi.exceptions import BadRequest, NotFound from plexapi.exceptions import BadRequest, NotFound
@ -415,6 +415,13 @@ class CollectionBuilder:
else: else:
server_check = pl_library.PlexServer.machineIdentifier server_check = pl_library.PlexServer.machineIdentifier
self.ignore_blank_results = False
if "ignore_blank_results" in methods and not self.playlist:
logger.debug("")
logger.debug("Validating Method: ignore_blank_results")
logger.debug(f"Value: {data[methods['ignore_blank_results']]}")
self.ignore_blank_results = util.parse(self.Type, "ignore_blank_results", self.data, datatype="bool", methods=methods, default=True)
self.smart_filter_details = "" self.smart_filter_details = ""
self.smart_label = {"sort_by": "random", "all": {"label": [self.name]}} self.smart_label = {"sort_by": "random", "all": {"label": [self.name]}}
self.smart_label_collection = False self.smart_label_collection = False
@ -437,7 +444,14 @@ class CollectionBuilder:
else: else:
logger.warning(f"{self.Type} Error: smart_label attribute: {self.data[methods['smart_label']]} is invalid defaulting to random") logger.warning(f"{self.Type} Error: smart_label attribute: {self.data[methods['smart_label']]} is invalid defaulting to random")
if self.smart_label_collection and self.library.smart_label_check(self.name): if self.smart_label_collection and self.library.smart_label_check(self.name):
try:
_, self.smart_filter_details, _ = self.build_filter("smart_label", self.smart_label, default_sort="random") _, self.smart_filter_details, _ = self.build_filter("smart_label", self.smart_label, default_sort="random")
except FilterFailed as e:
if self.ignore_blank_results:
raise
else:
raise Failed(str(e))
if "delete_not_scheduled" in methods and not self.overlay: if "delete_not_scheduled" in methods and not self.overlay:
logger.debug("") logger.debug("")
@ -497,13 +511,6 @@ class CollectionBuilder:
logger.debug(f"Value: {data[methods['build_collection']]}") logger.debug(f"Value: {data[methods['build_collection']]}")
self.build_collection = util.parse(self.Type, "build_collection", self.data, datatype="bool", methods=methods, default=True) self.build_collection = util.parse(self.Type, "build_collection", self.data, datatype="bool", methods=methods, default=True)
self.ignore_blank_results = False
if "ignore_blank_results" in methods and not self.playlist:
logger.debug("")
logger.debug("Validating Method: ignore_blank_results")
logger.debug(f"Value: {data[methods['ignore_blank_results']]}")
self.ignore_blank_results = util.parse(self.Type, "ignore_blank_results", self.data, datatype="bool", methods=methods, default=True)
self.blank_collection = False self.blank_collection = False
if "blank_collection" in methods and not self.playlist and not self.overlay: if "blank_collection" in methods and not self.playlist and not self.overlay:
logger.debug("") logger.debug("")
@ -574,7 +581,13 @@ class CollectionBuilder:
raise Failed(f"{self.Type} Error: smart_url is incorrectly formatted") raise Failed(f"{self.Type} Error: smart_url is incorrectly formatted")
if "smart_filter" in methods and not self.playlist and not self.overlay: if "smart_filter" in methods and not self.playlist and not self.overlay:
try:
self.smart_type_key, self.smart_filter_details, self.smart_url = self.build_filter("smart_filter", self.data[methods["smart_filter"]], display=True, default_sort="random") self.smart_type_key, self.smart_filter_details, self.smart_url = self.build_filter("smart_filter", self.data[methods["smart_filter"]], display=True, default_sort="random")
except FilterFailed as e:
if self.ignore_blank_results:
raise
else:
raise Failed(str(e))
if self.collectionless: if self.collectionless:
for x in ["smart_label", "smart_filter", "smart_url"]: for x in ["smart_label", "smart_filter", "smart_url"]:
@ -1302,7 +1315,13 @@ class CollectionBuilder:
for dict_data in util.parse(self.Type, method_name, method_data, datatype="listdict"): for dict_data in util.parse(self.Type, method_name, method_data, datatype="listdict"):
dict_methods = {dm.lower(): dm for dm in dict_data} dict_methods = {dm.lower(): dm for dm in dict_data}
if method_name == "plex_search": if method_name == "plex_search":
try:
self.builders.append((method_name, self.build_filter("plex_search", dict_data))) self.builders.append((method_name, self.build_filter("plex_search", dict_data)))
except FilterFailed as e:
if self.ignore_blank_results:
raise
else:
raise Failed(str(e))
elif method_name == "plex_collectionless": elif method_name == "plex_collectionless":
prefix_list = util.parse(self.Type, "exclude_prefix", dict_data, datatype="list", methods=dict_methods) if "exclude_prefix" in dict_methods else [] prefix_list = util.parse(self.Type, "exclude_prefix", dict_data, datatype="list", methods=dict_methods) if "exclude_prefix" in dict_methods else []
exact_list = util.parse(self.Type, "exclude", dict_data, datatype="list", methods=dict_methods) if "exclude" in dict_methods else [] exact_list = util.parse(self.Type, "exclude", dict_data, datatype="list", methods=dict_methods) if "exclude" in dict_methods else []
@ -1311,7 +1330,13 @@ class CollectionBuilder:
exact_list.append(self.name) exact_list.append(self.name)
self.builders.append((method_name, {"exclude_prefix": prefix_list, "exclude": exact_list})) self.builders.append((method_name, {"exclude_prefix": prefix_list, "exclude": exact_list}))
else: else:
try:
self.builders.append(("plex_search", self.build_filter("plex_search", {"any": {method_name: method_data}}))) self.builders.append(("plex_search", self.build_filter("plex_search", {"any": {method_name: method_data}})))
except FilterFailed as e:
if self.ignore_blank_results:
raise
else:
raise Failed(str(e))
def _reciperr(self, method_name, method_data): def _reciperr(self, method_name, method_data):
if method_name == "reciperr_list": if method_name == "reciperr_list":
@ -1972,7 +1997,7 @@ class CollectionBuilder:
final_filter = built_filter[:-1] if base_all else f"push=1&{built_filter}pop=1" final_filter = built_filter[:-1] if base_all else f"push=1&{built_filter}pop=1"
filter_url = f"?type={type_key}&{f'limit={limit}&' if limit else ''}sort={'%2C'.join([sorts[s] for s in sort])}&{final_filter}" filter_url = f"?type={type_key}&{f'limit={limit}&' if limit else ''}sort={'%2C'.join([sorts[s] for s in sort])}&{final_filter}"
else: else:
raise Failed(f"{self.Type} Error: No Plex Filter Created") raise FilterFailed(f"{self.Type} Error: No Plex Filter Created")
if display: if display:
logger.debug(f"Smart URL: {filter_url}") logger.debug(f"Smart URL: {filter_url}")
@ -2053,7 +2078,7 @@ class CollectionBuilder:
error += f"\nOptions: {names}" error += f"\nOptions: {names}"
if validate: if validate:
raise Failed(error) raise Failed(error)
else: elif not self.ignore_blank_results:
logger.error(error) logger.error(error)
return valid_list return valid_list
elif attribute in date_attributes and modifier in [".before", ".after"]: elif attribute in date_attributes and modifier in [".before", ".after"]:
@ -2695,7 +2720,13 @@ class CollectionBuilder:
plex_search["any"] = {f"{self.builder_level}_collection": self.name} plex_search["any"] = {f"{self.builder_level}_collection": self.name}
else: else:
plex_search["any"] = {"collection": self.name} plex_search["any"] = {"collection": self.name}
try:
search_data = self.build_filter("plex_search", plex_search) search_data = self.build_filter("plex_search", plex_search)
except FilterFailed as e:
if self.ignore_blank_results:
raise
else:
raise Failed(str(e))
items = self.library.get_filter_items(search_data[2]) items = self.library.get_filter_items(search_data[2])
previous = None previous = None
for i, item in enumerate(items, 0): for i, item in enumerate(items, 0):

@ -24,6 +24,9 @@ class LimitReached(Exception):
class Failed(Exception): class Failed(Exception):
pass pass
class FilterFailed(Failed):
pass
class Deleted(Exception): class Deleted(Exception):
pass pass

Loading…
Cancel
Save