allow all schedules

pull/528/head
meisnate12 3 years ago
parent b17fd41552
commit 6fa97a21e3

@ -79,13 +79,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 = ["show_filtered", "show_missing", "save_missing", "missing_only_released", "only_filter_missing", "delete_below_minimum"]
scheduled_boolean = ["visible_library", "visible_home", "visible_shared"]
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", "visible_library", "visible_home", "visible_shared"] + boolean_details + string_details
"collection_minimum", "label"] + boolean_details + scheduled_boolean + 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"]
@ -368,7 +369,7 @@ class CollectionBuilder:
else:
logger.debug(f"Value: {self.data[methods['schedule']]}")
try:
util.schedule_check(self.data[methods['schedule']], self.current_time, self.config.run_hour)
util.schedule_check("schedule", self.data[methods['schedule']], self.current_time, self.config.run_hour)
except NotScheduled as e:
suffix = ""
if self.details["delete_not_scheduled"]:
@ -795,7 +796,7 @@ 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"]:
elif method_name in scheduled_boolean:
if isinstance(method_data, bool):
self.details[method_name] = method_data
elif isinstance(method_data, (int, float)):
@ -805,18 +806,11 @@ class CollectionBuilder:
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)
try:
util.schedule_check(method_name, self.details[method_name], self.current_time, self.config.run_hour)
self.details[method_name] = True
except NotScheduled:
self.details[method_name] = False
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)

@ -642,7 +642,7 @@ class ConfigFile:
else:
logger.debug(f"Value: {lib['schedule']}")
try:
util.schedule_check(lib["schedule"], current_time, self.run_hour)
util.schedule_check("schedule", lib["schedule"], current_time, self.run_hour)
except NotScheduled:
params["skip_library"] = True

@ -358,7 +358,7 @@ def check_day(_m, _d):
else:
return _m, _d
def schedule_check(data, current_time, run_hour):
def schedule_check(attribute, data, current_time, run_hour):
skip_collection = True
schedule_list = get_list(data)
next_month = current_time.replace(day=28) + timedelta(days=4)
@ -373,7 +373,7 @@ def schedule_check(data, current_time, run_hour):
elif run_time.startswith(("hour", "week", "month", "year", "range")):
match = re.search("\\(([^)]+)\\)", run_time)
if not match:
logger.error(f"Schedule Error: failed to parse schedule: {schedule}")
logger.error(f"Schedule Error: failed to parse {attribute}: {schedule}")
continue
param = match.group(1)
if run_time.startswith("hour"):
@ -385,10 +385,10 @@ def schedule_check(data, current_time, run_hour):
else:
raise ValueError
except ValueError:
logger.error(f"Schedule Error: hourly schedule attribute {schedule} invalid must be an integer between 0 and 23")
logger.error(f"Schedule Error: hourly {attribute} attribute {schedule} invalid must be an integer between 0 and 23")
elif run_time.startswith("week"):
if param.lower() not in days_alias:
logger.error(f"Schedule Error: weekly schedule attribute {schedule} invalid must be a day of the week i.e. weekly(Monday)")
logger.error(f"Schedule Error: weekly {attribute} attribute {schedule} invalid must be a day of the week i.e. weekly(Monday)")
continue
weekday = days_alias[param.lower()]
schedule_str += f"\nScheduled weekly on {pretty_days[weekday]}"
@ -404,7 +404,7 @@ def schedule_check(data, current_time, run_hour):
else:
raise ValueError
except ValueError:
logger.error(f"Schedule Error: monthly schedule attribute {schedule} invalid must be an integer between 1 and 31")
logger.error(f"Schedule Error: monthly {attribute} attribute {schedule} invalid must be an integer between 1 and 31")
elif run_time.startswith("year"):
try:
if "/" in param:
@ -419,11 +419,11 @@ def schedule_check(data, current_time, run_hour):
raise ValueError
except ValueError:
logger.error(
f"Schedule Error: yearly schedule attribute {schedule} invalid must be in the MM/DD format i.e. yearly(11/22)")
f"Schedule Error: yearly {attribute} attribute {schedule} invalid must be in the MM/DD format i.e. yearly(11/22)")
elif run_time.startswith("range"):
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])$", param)
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)")
logger.error(f"Schedule Error: range {attribute} attribute {schedule} invalid must be in the MM/DD-MM/DD format i.e. range(12/01-12/25)")
continue
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)))
@ -435,7 +435,7 @@ def schedule_check(data, current_time, run_hour):
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")
logger.error(f"Schedule Error: {attribute} attribute {schedule} invalid")
if len(schedule_str) == 0:
skip_collection = False
if skip_collection:

Loading…
Cancel
Save