[68] #914 Added `non_existing` schedule option

pull/949/head
meisnate12 3 years ago
parent daba086324
commit 31c5fbe1e4

@ -1 +1 @@
1.17.0-develop67
1.17.0-develop68

@ -68,16 +68,17 @@ 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 comma separated scheduling options inside its brackets be meet in order to run | all[Options] | `all[weekly(sunday), hourly(17)]` |
| 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` |
| Non Existing | Updates if it doesn't exist | non_existing | `non_existing` |
| 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).

@ -1,7 +1,7 @@
import os, re, time
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.util import Failed, NotScheduled, NotScheduledRange, Overlay, Deleted
from modules.util import Failed, NonExisting, NotScheduled, NotScheduledRange, Overlay, Deleted
from plexapi.audio import Artist, Album, Track
from plexapi.exceptions import BadRequest, NotFound
from plexapi.video import Movie, Show, Season, Episode
@ -368,6 +368,7 @@ class CollectionBuilder:
self.collection_poster = None
self.collection_background = None
self.exists = False
self.non_existing = False
self.created = False
self.deleted = False
@ -396,6 +397,8 @@ class CollectionBuilder:
err = None
try:
util.schedule_check("schedule", self.data[methods["schedule"]], self.current_time, self.config.run_hour)
except NonExisting as e:
self.non_existing = str(e)
except NotScheduledRange as e:
err = e
except NotScheduled as e:
@ -771,6 +774,9 @@ class CollectionBuilder:
self.obj = None
self.sync = False
self.run_again = False
if self.non_existing is not False and self.obj:
raise NotScheduled(self.non_existing)
logger.info("")
logger.info("Validation Successful")

@ -24,6 +24,9 @@ class Failed(Exception):
class Deleted(Exception):
pass
class NonExisting(Exception):
pass
class NotScheduled(Exception):
pass
@ -526,6 +529,7 @@ def check_day(_m, _d):
def schedule_check(attribute, data, current_time, run_hour, is_all=False):
range_collection = False
non_existing = False
all_check = 0
schedules_run = 0
next_month = current_time.replace(day=28) + timedelta(days=4)
@ -553,6 +557,9 @@ def schedule_check(attribute, data, current_time, run_hour, is_all=False):
continue
elif run_time.startswith(("day", "daily")):
all_check += 1
elif run_time.startswith("non_existing"):
all_check += 1
non_existing = True
elif run_time == "never":
schedule_str += f"\nNever scheduled to run"
elif run_time.startswith(("hour", "week", "month", "year", "range")):
@ -624,7 +631,9 @@ def schedule_check(attribute, data, current_time, run_hour, is_all=False):
if is_all:
schedule_str.replace("\n", "\n\t")
if (all_check == 0 and not is_all) or (is_all and schedules_run != all_check):
if range_collection:
if non_existing:
raise NonExisting(schedule_str)
elif range_collection:
raise NotScheduledRange(schedule_str)
else:
raise NotScheduled(schedule_str)

Loading…
Cancel
Save