[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

@ -69,7 +69,7 @@ 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)` |
@ -77,6 +77,7 @@ The scheduling options are:
| 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` |
| 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)]` | | 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.

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

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

Loading…
Cancel
Save