[90] schedule multiple alls

This commit is contained in:
meisnate12 2022-05-12 10:09:08 -04:00
parent 9013d8143a
commit 0eaba3dd2c
4 changed files with 36 additions and 21 deletions

View file

@ -1 +1 @@
1.16.5-develop89
1.16.5-develop90

View file

@ -30,6 +30,7 @@ settings:
asset_folders: true
asset_depth: 0
create_asset_folders: false
prioritize_assets: false
dimensional_asset_rename: false
download_url_assets: false
show_missing_season_assets: false
@ -48,14 +49,16 @@ settings:
show_options: false
show_missing: true
show_missing_assets: true
save_missing: true
save_report: false
tvdb_language: eng
ignore_ids:
ignore_imdb_ids:
item_refresh_delay: 0
playlist_sync_to_user: all
playlist_report: false
verify_ssl: true
custom_repo:
check_nightly: false
webhooks: # Can be individually specified per library as well
error:
version:

View file

@ -52,7 +52,9 @@ collections:
TMDb Top Rated:
tmdb_top_rated: 30
sync_mode: sync
schedule: monthly(1), monthly(15)
schedule:
- monthly(1)
- monthly(15)
```
Below is an example of a scheduled pinning collection:
@ -66,18 +68,18 @@ collections:
The scheduling options are:
| Name | Description | Format | Example |
|:--------|:-----------------------------------------------------------------------------------------------------|:----------------------|:---------------------|
| Hourly | Update only when the script is run in that hour | hourly(Hour of Day) | `hourly(17)` |
| Daily | Update once a day | daily | `daily` |
| Weekly | Update once a week on the specified day | weekly(Day of Week) | `weekly(sunday)` |
| Monthly | Update once a month on the specified day | monthly(Day of Month) | `monthly(1)` |
| Yearly | Update once a year on the specified day | yearly(MM/DD) | `yearly(01/30)` |
| Range | Updates whenever the date is within the range | range(MM/DD-MM/DD) | `range(12/01-12/31)` |
| Never | Never updates | never | `never` |
| All | Requires that all scheduling option be meet in order to run<br>ex. `all, weekly(sunday), hourly(17)` | all | `all` |
| Name | Description | Format | Example |
|:--------|:-------------------------------------------------------------------------------------------------|:----------------------|:----------------------------------|
| Hourly | Update only when the script is run in that hour | hourly(Hour of Day) | `hourly(17)` |
| Daily | Update once a day | daily | `daily` |
| Weekly | Update once a week on the specified day | weekly(Day of Week) | `weekly(sunday)` |
| Monthly | Update once a month on the specified day | monthly(Day of Month) | `monthly(1)` |
| Yearly | Update once a year on the specified day | yearly(MM/DD) | `yearly(01/30)` |
| Range | Updates whenever the date is within the range | range(MM/DD-MM/DD) | `range(12/01-12/31)` |
| Never | Never updates | never | `never` |
| All | Requires that all comma separated scheduling options inside its brackets be meet in order to run | all[Options] | `all[weekly(sunday), hourly(17)]` |
* `daily` is the default when `schedule` isn't specified.
* You can run the script multiple times per day but using the `--time` command line argument detailed on the [Run Commands & Environmental Variables Page](../../home/environmental.md#time-to-run).
* You can have multiple scheduling options just make them a list or comma-separated values.
* You can use the `delete_not_scheduled` setting to delete Collections that are skipped due to not being scheduled.
* You can have multiple scheduling options as a list.
* You can use the `delete_not_scheduled` setting to delete Collections that are skipped due to not being scheduled.

View file

@ -513,21 +513,31 @@ def check_day(_m, _d):
else:
return _m, _d
def schedule_check(attribute, data, current_time, run_hour):
def schedule_check(attribute, data, current_time, run_hour, is_all=False):
range_collection = False
all_check = 0
schedules_run = 0
is_all = False
next_month = current_time.replace(day=28) + timedelta(days=4)
last_day = next_month - timedelta(days=next_month.day)
schedule_str = ""
if isinstance(data, str) and (("all" in data and not data.endswith("]")) or data.count("all") > 1):
raise Failed("Schedule Error: each all schedule must be on its own line")
elif isinstance(data, str) and "all" in data:
data = [data]
for schedule in get_list(data):
run_time = str(schedule).lower()
display = f"{attribute} attribute {schedule} invalid"
schedules_run += 1
if run_time == "all":
is_all = True
all_check += 1
if run_time.startswith("all"):
match = re.search("\\[([^\\]]+)\\]", run_time)
if not match:
logger.error(f"Schedule Error: failed to parse {attribute}: {schedule}")
continue
try:
schedule_check(attribute, match.group(1), current_time, run_hour, is_all=True)
all_check += 1
except NotScheduled:
continue
elif run_time.startswith(("day", "daily")):
all_check += 1
elif run_time == "never":
@ -598,7 +608,7 @@ def schedule_check(attribute, data, current_time, run_hour):
all_check += 1
else:
logger.error(f"Schedule Error: {display}")
if all_check == 0 or (is_all and schedules_run != all_check):
if (all_check == 0 and not is_all) or (is_all and schedules_run != all_check):
if range_collection:
raise NotScheduledRange(schedule_str)
else: