add ranges to visible_library, visible_home, and visible_shared

This commit is contained in:
meisnate12 2021-12-18 23:11:23 -05:00
parent aa95c63794
commit b17fd41552
3 changed files with 38 additions and 19 deletions

View file

@ -78,17 +78,14 @@ summary_details = [
]
poster_details = ["url_poster", "tmdb_poster", "tmdb_profile", "tvdb_poster", "file_poster"]
background_details = ["url_background", "tmdb_background", "tvdb_background", "file_background"]
boolean_details = [
"visible_library", "visible_home", "visible_shared", "show_filtered", "show_missing", "save_missing",
"missing_only_released", "only_filter_missing", "delete_below_minimum"
]
boolean_details = ["show_filtered", "show_missing", "save_missing", "missing_only_released", "only_filter_missing", "delete_below_minimum"]
string_details = ["sort_title", "content_rating", "name_mapping"]
ignored_details = [
"smart_filter", "smart_label", "smart_url", "run_again", "schedule", "sync_mode", "template", "test", "delete_not_scheduled",
"tmdb_person", "build_collection", "collection_order", "collection_level", "validate_builders", "collection_name", "sort_by", "libraries"
]
details = ["ignore_ids", "ignore_imdb_ids", "server_preroll", "collection_changes_webhooks", "collection_mode",
"collection_minimum", "label"] + boolean_details + string_details
"collection_minimum", "label", "visible_library", "visible_home", "visible_shared"] + boolean_details + string_details
collectionless_details = ["collection_order", "plex_collectionless", "label", "label_sync_mode", "test"] + \
poster_details + background_details + summary_details + string_details
item_bool_details = ["item_tmdb_season_titles", "item_assets", "revert_overlay", "item_lock_background", "item_lock_poster", "item_lock_title", "item_refresh"]
@ -690,7 +687,7 @@ class CollectionBuilder:
elif datatype == "bool":
if isinstance(value, bool):
return value
elif isinstance(value, int):
elif isinstance(value, (int, float)):
return value > 0
elif str(value).lower() in ["t", "true"]:
return True
@ -798,6 +795,28 @@ class CollectionBuilder:
self.details[method_final] = util.get_list(method_data) if method_data else []
elif method_name == "collection_changes_webhooks":
self.details[method_name] = self._parse(method_name, method_data, datatype="list")
elif method_name in ["visible_library", "visible_home", "visible_shared"]:
if isinstance(method_data, bool):
self.details[method_name] = method_data
elif isinstance(method_data, (int, float)):
self.details[method_name] = method_data > 0
elif str(method_data).lower() in ["t", "true"]:
self.details[method_name] = True
elif str(method_data).lower() in ["f", "false"]:
self.details[method_name] = False
else:
match = re.match("^(1[0-2]|0?[1-9])/(3[01]|[12][0-9]|0?[1-9])-(1[0-2]|0?[1-9])/(3[01]|[12][0-9]|0?[1-9])$", method_data)
if not match:
logger.error(f"{self.Type} Error: {method_name} must be either true, false or in the MM/DD-MM/DD format i.e. 12/01-12/25")
else:
month_start, day_start = util.check_day(int(match.group(1)), int(match.group(2)))
month_end, day_end = util.check_day(int(match.group(3)), int(match.group(4)))
month_check, day_check = util.check_day(self.current_time.month, self.current_time.day)
check = datetime.strptime(f"{month_check}/{day_check}", "%m/%d")
start = datetime.strptime(f"{month_start}/{day_start}", "%m/%d")
end = datetime.strptime(f"{month_end}/{day_end}", "%m/%d")
logger.info(f"\n{method_name} between {util.pretty_months[month_start]} {util.make_ordinal(day_start)} and {util.pretty_months[month_end]} {util.make_ordinal(day_end)}")
self.details[method_name] = start <= check <= end if start < end else (check <= end or check >= start)
elif method_name in boolean_details:
default = self.details[method_name] if method_name in self.details else None
self.details[method_name] = self._parse(method_name, method_data, datatype="bool", default=default)

View file

@ -66,7 +66,7 @@ class Sonarr:
_paths.append(tvdb_id)
else:
_ids.append(tvdb_id)
logger.debug(f"Radarr Adds: {_ids if _ids else ''}")
logger.debug(f"Sonarr Adds: {_ids if _ids else ''}")
for tvdb_id in _paths:
logger.debug(tvdb_id)
folder = options["folder"] if "folder" in options else self.root_folder_path

View file

@ -347,6 +347,17 @@ def is_string_filter(values, modifier, data):
if jailbreak: break
return (jailbreak and modifier in [".not", ".isnot"]) or (not jailbreak and modifier in ["", ".is", ".begins", ".ends", ".regex"])
def check_day(_m, _d):
if _m in [1, 3, 5, 7, 8, 10, 12] and _d > 31:
return _m, 31
elif _m in [4, 6, 9, 11] and _d > 30:
return _m, 30
elif _m == 2 and _d > 28:
return _m, 28
else:
return _m, _d
def schedule_check(data, current_time, run_hour):
skip_collection = True
schedule_list = get_list(data)
@ -414,17 +425,6 @@ def schedule_check(data, current_time, run_hour):
if not match:
logger.error(f"Schedule Error: range schedule attribute {schedule} invalid must be in the MM/DD-MM/DD format i.e. range(12/01-12/25)")
continue
def check_day(_m, _d):
if _m in [1, 3, 5, 7, 8, 10, 12] and _d > 31:
return _m, 31
elif _m in [4, 6, 9, 11] and _d > 30:
return _m, 30
elif _m == 2 and _d > 28:
return _m, 28
else:
return _m, _d
month_start, day_start = check_day(int(match.group(1)), int(match.group(2)))
month_end, day_end = check_day(int(match.group(3)), int(match.group(4)))
month_check, day_check = check_day(current_time.month, current_time.day)
@ -432,7 +432,7 @@ def schedule_check(data, current_time, run_hour):
start = datetime.strptime(f"{month_start}/{day_start}", "%m/%d")
end = datetime.strptime(f"{month_end}/{day_end}", "%m/%d")
schedule_str += f"\nScheduled between {pretty_months[month_start]} {make_ordinal(day_start)} and {pretty_months[month_end]} {make_ordinal(day_end)}"
if start <= check <= end if start < end else check <= end or check >= start:
if start <= check <= end if start < end else (check <= end or check >= start):
skip_collection = False
else:
logger.error(f"Schedule Error: schedule attribute {schedule} invalid")