[91] added `allowed_library_types`

pull/877/head
meisnate12 3 years ago
parent 0eaba3dd2c
commit da6d31c48b

@ -1 +1 @@
1.16.5-develop90
1.16.5-develop91

@ -39,7 +39,8 @@ string_details = ["sort_title", "content_rating", "name_mapping"]
ignored_details = [
"smart_filter", "smart_label", "smart_url", "run_again", "schedule", "sync_mode", "template", "test", "suppress_overlays",
"delete_not_scheduled", "tmdb_person", "build_collection", "collection_order", "collection_level", "overlay",
"validate_builders", "libraries", "sync_to_users", "collection_name", "playlist_name", "name", "blank_collection"
"validate_builders", "libraries", "sync_to_users", "collection_name", "playlist_name", "name", "blank_collection",
"allowed_library_types"
]
details = [
"ignore_ids", "ignore_imdb_ids", "server_preroll", "changes_webhooks", "collection_filtering", "collection_mode", "limit", "url_theme",
@ -216,6 +217,21 @@ class CollectionBuilder:
self.data[attr] = new_attributes[attr]
methods[attr.lower()] = attr
if "allowed_library_types" in methods and not self.playlist:
logger.debug("")
logger.debug("Validating Method: allowed_library_types")
if not self.data[methods["allowed_library_types"]]:
raise Failed(f"{self.Type} Error: allowed_library_types attribute is blank")
logger.debug(f"Value: {data[methods['allowed_library_types']]}")
found_type = False
for library_type in util.get_list(self.data[methods["allowed_library_types"]], lower=True):
if library_type not in plex.library_types:
raise Failed(f"{self.Type} Error: {library_type} is invalid. Options: {', '.join(plex.library_types)}")
elif library_type == self.library.Plex.type:
found_type = True
if not found_type:
raise NotScheduled(f"Skipped because allowed_library_types {self.data[methods['allowed_library_types']]} doesn't match the library type: {self.library.Plex.type}")
self.suppress_overlays = []
self.overlay_group = None
self.overlay_weight = None
@ -315,21 +331,18 @@ class CollectionBuilder:
self.sync_to_users = None
self.valid_users = []
if self.playlist:
if "libraries" in methods:
logger.debug("")
logger.debug("Validating Method: libraries")
if not self.data[methods["libraries"]]:
raise Failed(f"{self.Type} Error: libraries attribute is blank")
else:
logger.debug(f"Value: {self.data[methods['libraries']]}")
for pl_library in util.get_list(self.data[methods["libraries"]]):
if str(pl_library) in config.library_map:
self.libraries.append(config.library_map[pl_library])
else:
raise Failed(f"Playlist Error: Library: {pl_library} not defined")
self.library = self.libraries[0]
else:
if "libraries" not in methods:
raise Failed("Playlist Error: libraries attribute is required")
logger.debug("")
logger.debug("Validating Method: libraries")
if not self.data[methods["libraries"]]:
raise Failed(f"{self.Type} Error: libraries attribute is blank")
logger.debug(f"Value: {self.data[methods['libraries']]}")
for pl_library in util.get_list(self.data[methods["libraries"]]):
if str(pl_library) not in config.library_map:
raise Failed(f"Playlist Error: Library: {pl_library} not defined")
self.libraries.append(config.library_map[pl_library])
self.library = self.libraries[0]
if "sync_to_users" in methods or "sync_to_user" in methods:
s_attr = f"sync_to_user{'s' if 'sync_to_users' in methods else ''}"
@ -347,10 +360,9 @@ class CollectionBuilder:
self.valid_users = plex_users
else:
for user in util.get_list(self.sync_to_users):
if user in plex_users:
self.valid_users.append(user)
else:
if user not in plex_users:
raise Failed(f"Playlist Error: User: {user} not found in plex\nOptions: {plex_users}")
self.valid_users.append(user)
if "delete_playlist" in methods:
logger.debug("")

@ -2,7 +2,7 @@ import os, re, time
from datetime import datetime
from modules import util
from modules.builder import CollectionBuilder
from modules.util import Failed
from modules.util import Failed, NotScheduled
from plexapi.audio import Album
from plexapi.exceptions import BadRequest
from plexapi.video import Movie, Show, Season, Episode
@ -230,6 +230,8 @@ class Overlays:
if added_titles:
logger.debug(f"{len(added_titles)} Titles Found: {[self.get_item_sort_title(a, atr='title') for a in added_titles]}")
logger.info(f"{len(added_titles) if added_titles else 'No'} Items found for {builder.overlay}")
except NotScheduled as e:
logger.info(e)
except Failed as e:
logger.error(e)

@ -19,6 +19,7 @@ from xml.etree.ElementTree import ParseError
logger = util.logger
builders = ["plex_all", "plex_pilots", "plex_collectionless", "plex_search"]
library_types = ["movie", "show", "artist"]
search_translation = {
"episode_title": "episode.title",
"network": "show.network",
@ -409,11 +410,10 @@ class Plex(Library):
break
if not self.Plex:
raise Failed(f"Plex Error: Plex Library '{params['name']}' not found. Options: {library_names}")
if self.Plex.type in ["movie", "show", "artist"]:
self.type = self.Plex.type.capitalize()
else:
if self.Plex.type not in library_types:
raise Failed(f"Plex Error: Plex Library must be a Movies or TV Shows library")
self.type = self.Plex.type.capitalize()
self._users = []
self._all_items = []
self.agent = self.Plex.agent

@ -534,9 +534,11 @@ def schedule_check(attribute, data, current_time, run_hour, is_all=False):
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)
schedule_str += f"\nScheduled to meet all of these:\n\t"
schedule_str += schedule_check(attribute, match.group(1), current_time, run_hour, is_all=True)
all_check += 1
except NotScheduled:
except NotScheduled as e:
schedule_str += str(e)
continue
elif run_time.startswith(("day", "daily")):
all_check += 1
@ -551,7 +553,7 @@ def schedule_check(attribute, data, current_time, run_hour, is_all=False):
if run_time.startswith("hour"):
try:
if 0 <= int(param) <= 23:
schedule_str += f"\nScheduled to run only on the {make_ordinal(int(param))} hour"
schedule_str += f"\nScheduled to run on the {make_ordinal(int(param))} hour"
if run_hour == int(param):
all_check += 1
else:
@ -608,11 +610,14 @@ def schedule_check(attribute, data, current_time, run_hour, is_all=False):
all_check += 1
else:
logger.error(f"Schedule Error: {display}")
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:
raise NotScheduledRange(schedule_str)
else:
raise NotScheduled(schedule_str)
return schedule_str
def check_int(value, datatype="int", minimum=1, maximum=None):
try:

@ -653,6 +653,8 @@ def run_collection(config, library, metadata, requested_collections):
if str(e).endswith("and was deleted"):
library.stats["deleted"] += 1
library.status[mapping_name]["status"] = "Deleted Not Scheduled"
elif str(e).startswith("Skipped because allowed_library_types"):
library.status[mapping_name]["status"] = "Skipped Invalid Library Type"
else:
library.status[mapping_name]["status"] = "Not Scheduled"
except Failed as e:

Loading…
Cancel
Save