[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 = [ ignored_details = [
"smart_filter", "smart_label", "smart_url", "run_again", "schedule", "sync_mode", "template", "test", "suppress_overlays", "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", "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 = [ details = [
"ignore_ids", "ignore_imdb_ids", "server_preroll", "changes_webhooks", "collection_filtering", "collection_mode", "limit", "url_theme", "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] self.data[attr] = new_attributes[attr]
methods[attr.lower()] = 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.suppress_overlays = []
self.overlay_group = None self.overlay_group = None
self.overlay_weight = None self.overlay_weight = None
@ -315,21 +331,18 @@ class CollectionBuilder:
self.sync_to_users = None self.sync_to_users = None
self.valid_users = [] self.valid_users = []
if self.playlist: if self.playlist:
if "libraries" in methods: if "libraries" not in methods:
raise Failed("Playlist Error: libraries attribute is required")
logger.debug("") logger.debug("")
logger.debug("Validating Method: libraries") logger.debug("Validating Method: libraries")
if not self.data[methods["libraries"]]: if not self.data[methods["libraries"]]:
raise Failed(f"{self.Type} Error: libraries attribute is blank") raise Failed(f"{self.Type} Error: libraries attribute is blank")
else:
logger.debug(f"Value: {self.data[methods['libraries']]}") logger.debug(f"Value: {self.data[methods['libraries']]}")
for pl_library in util.get_list(self.data[methods["libraries"]]): for pl_library in util.get_list(self.data[methods["libraries"]]):
if str(pl_library) in config.library_map: if str(pl_library) not in config.library_map:
self.libraries.append(config.library_map[pl_library])
else:
raise Failed(f"Playlist Error: Library: {pl_library} not defined") raise Failed(f"Playlist Error: Library: {pl_library} not defined")
self.libraries.append(config.library_map[pl_library])
self.library = self.libraries[0] self.library = self.libraries[0]
else:
raise Failed("Playlist Error: libraries attribute is required")
if "sync_to_users" in methods or "sync_to_user" in methods: 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 ''}" 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 self.valid_users = plex_users
else: else:
for user in util.get_list(self.sync_to_users): for user in util.get_list(self.sync_to_users):
if user in plex_users: if user not in plex_users:
self.valid_users.append(user)
else:
raise Failed(f"Playlist Error: User: {user} not found in plex\nOptions: {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: if "delete_playlist" in methods:
logger.debug("") logger.debug("")

@ -2,7 +2,7 @@ import os, re, time
from datetime import datetime from datetime import datetime
from modules import util from modules import util
from modules.builder import CollectionBuilder from modules.builder import CollectionBuilder
from modules.util import Failed from modules.util import Failed, NotScheduled
from plexapi.audio import Album from plexapi.audio import Album
from plexapi.exceptions import BadRequest from plexapi.exceptions import BadRequest
from plexapi.video import Movie, Show, Season, Episode from plexapi.video import Movie, Show, Season, Episode
@ -230,6 +230,8 @@ class Overlays:
if added_titles: 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.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}") 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: except Failed as e:
logger.error(e) logger.error(e)

@ -19,6 +19,7 @@ from xml.etree.ElementTree import ParseError
logger = util.logger logger = util.logger
builders = ["plex_all", "plex_pilots", "plex_collectionless", "plex_search"] builders = ["plex_all", "plex_pilots", "plex_collectionless", "plex_search"]
library_types = ["movie", "show", "artist"]
search_translation = { search_translation = {
"episode_title": "episode.title", "episode_title": "episode.title",
"network": "show.network", "network": "show.network",
@ -409,11 +410,10 @@ class Plex(Library):
break break
if not self.Plex: if not self.Plex:
raise Failed(f"Plex Error: Plex Library '{params['name']}' not found. Options: {library_names}") raise Failed(f"Plex Error: Plex Library '{params['name']}' not found. Options: {library_names}")
if self.Plex.type in ["movie", "show", "artist"]: if self.Plex.type not in library_types:
self.type = self.Plex.type.capitalize()
else:
raise Failed(f"Plex Error: Plex Library must be a Movies or TV Shows library") raise Failed(f"Plex Error: Plex Library must be a Movies or TV Shows library")
self.type = self.Plex.type.capitalize()
self._users = [] self._users = []
self._all_items = [] self._all_items = []
self.agent = self.Plex.agent 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}") logger.error(f"Schedule Error: failed to parse {attribute}: {schedule}")
continue continue
try: 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 all_check += 1
except NotScheduled: except NotScheduled as e:
schedule_str += str(e)
continue continue
elif run_time.startswith(("day", "daily")): elif run_time.startswith(("day", "daily")):
all_check += 1 all_check += 1
@ -551,7 +553,7 @@ def schedule_check(attribute, data, current_time, run_hour, is_all=False):
if run_time.startswith("hour"): if run_time.startswith("hour"):
try: try:
if 0 <= int(param) <= 23: 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): if run_hour == int(param):
all_check += 1 all_check += 1
else: else:
@ -608,11 +610,14 @@ def schedule_check(attribute, data, current_time, run_hour, is_all=False):
all_check += 1 all_check += 1
else: else:
logger.error(f"Schedule Error: {display}") 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 (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:
raise NotScheduled(schedule_str) raise NotScheduled(schedule_str)
return schedule_str
def check_int(value, datatype="int", minimum=1, maximum=None): def check_int(value, datatype="int", minimum=1, maximum=None):
try: try:

@ -653,6 +653,8 @@ def run_collection(config, library, metadata, requested_collections):
if str(e).endswith("and was deleted"): if str(e).endswith("and was deleted"):
library.stats["deleted"] += 1 library.stats["deleted"] += 1
library.status[mapping_name]["status"] = "Deleted Not Scheduled" 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: else:
library.status[mapping_name]["status"] = "Not Scheduled" library.status[mapping_name]["status"] = "Not Scheduled"
except Failed as e: except Failed as e:

Loading…
Cancel
Save