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

View file

@ -52,7 +52,9 @@ collections:
TMDb Top Rated: TMDb Top Rated:
tmdb_top_rated: 30 tmdb_top_rated: 30
sync_mode: sync sync_mode: sync
schedule: monthly(1), monthly(15) schedule:
- monthly(1)
- monthly(15)
``` ```
Below is an example of a scheduled pinning collection: Below is an example of a scheduled pinning collection:
@ -66,18 +68,18 @@ collections:
The scheduling options are: The scheduling options are:
| Name | Description | Format | Example | | Name | Description | Format | Example |
|:--------|:-----------------------------------------------------------------------------------------------------|:----------------------|:---------------------| |:--------|:-------------------------------------------------------------------------------------------------|:----------------------|:----------------------------------|
| Hourly | Update only when the script is run in that hour | hourly(Hour of Day) | `hourly(17)` | | Hourly | Update only when the script is run in that hour | hourly(Hour of Day) | `hourly(17)` |
| Daily | Update once a day | daily | `daily` | | Daily | Update once a day | daily | `daily` |
| Weekly | Update once a week on the specified day | weekly(Day of Week) | `weekly(sunday)` | | 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)` | | 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)` | | 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)` | | Range | Updates whenever the date is within the range | range(MM/DD-MM/DD) | `range(12/01-12/31)` |
| Never | Never updates | never | `never` | | 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` | | 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. * `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 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 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. * 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: else:
return _m, _d 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 range_collection = False
all_check = 0 all_check = 0
schedules_run = 0 schedules_run = 0
is_all = False
next_month = current_time.replace(day=28) + timedelta(days=4) next_month = current_time.replace(day=28) + timedelta(days=4)
last_day = next_month - timedelta(days=next_month.day) last_day = next_month - timedelta(days=next_month.day)
schedule_str = "" 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): for schedule in get_list(data):
run_time = str(schedule).lower() run_time = str(schedule).lower()
display = f"{attribute} attribute {schedule} invalid" display = f"{attribute} attribute {schedule} invalid"
schedules_run += 1 schedules_run += 1
if run_time == "all": if run_time.startswith("all"):
is_all = True match = re.search("\\[([^\\]]+)\\]", run_time)
all_check += 1 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")): elif run_time.startswith(("day", "daily")):
all_check += 1 all_check += 1
elif run_time == "never": elif run_time == "never":
@ -598,7 +608,7 @@ def schedule_check(attribute, data, current_time, run_hour):
all_check += 1 all_check += 1
else: else:
logger.error(f"Schedule Error: {display}") 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: if range_collection:
raise NotScheduledRange(schedule_str) raise NotScheduledRange(schedule_str)
else: else: