added `build_collection` collection detail

pull/264/head
meisnate12 4 years ago
parent 5faf2f9b86
commit 0c67bfb731

@ -1,4 +1,4 @@
import glob, logging, os, re import logging, os, re
from datetime import datetime, timedelta from datetime import datetime, timedelta
from modules import anidb, anilist, imdb, letterboxd, mal, plex, radarr, sonarr, tautulli, tmdb, trakttv, tvdb, util from modules import anidb, anilist, imdb, letterboxd, mal, plex, radarr, sonarr, tautulli, tmdb, trakttv, tvdb, util
from modules.util import Failed from modules.util import Failed
@ -645,10 +645,8 @@ class CollectionBuilder:
raise Failed(f"Collection Error: {method_name} attribute only works with normal collections") raise Failed(f"Collection Error: {method_name} attribute only works with normal collections")
elif method_name not in collectionless_details and self.collectionless: elif method_name not in collectionless_details and self.collectionless:
raise Failed(f"Collection Error: {method_name} attribute does not work for Collectionless collection") raise Failed(f"Collection Error: {method_name} attribute does not work for Collectionless collection")
elif self.smart_url and method_name in all_builders: elif self.smart_url and (method_name in all_builders or method_name in smart_url_collection_invalid):
raise Failed(f"Collection Error: {method_name} builder not allowed when using smart_filter") raise Failed(f"Collection Error: {method_name} builder not allowed when using smart_filter")
elif self.smart_url and method_name in smart_url_collection_invalid:
raise Failed(f"Collection Error: {method_name} detail not allowed when using smart_url")
elif method_name == "summary": elif method_name == "summary":
self.summaries[method_name] = method_data self.summaries[method_name] = method_data
elif method_name == "tmdb_summary": elif method_name == "tmdb_summary":
@ -1249,6 +1247,14 @@ class CollectionBuilder:
self.details["collection_mode"] = "hide" self.details["collection_mode"] = "hide"
self.sync = True self.sync = True
self.build_collection = True
if "build_collection" in methods:
if not self.data[methods["build_collection"]]:
logger.warning(f"Collection Warning: build_collection attribute is blank defaulting to true")
else:
self.build_collection = util.get_bool("build_collection", self.data[methods["build_collection"]])
if self.build_collection:
try: try:
self.obj = library.get_collection(self.name) self.obj = library.get_collection(self.name)
collection_smart = library.smart(self.obj) collection_smart = library.smart(self.obj)
@ -1264,6 +1270,9 @@ class CollectionBuilder:
if self.sync and self.obj: if self.sync and self.obj:
for item in library.get_collection_items(self.obj, self.smart_label_collection): for item in library.get_collection_items(self.obj, self.smart_label_collection):
self.plex_map[item.ratingKey] = item self.plex_map[item.ratingKey] = item
else:
self.sync = False
self.run_again = False
def collect_rating_keys(self, movie_map, show_map): def collect_rating_keys(self, movie_map, show_map):
def add_rating_keys(keys): def add_rating_keys(keys):

@ -220,7 +220,6 @@ def compile_list(data):
else: else:
return data return data
def get_list(data, lower=False, split=True, int_list=False): def get_list(data, lower=False, split=True, int_list=False):
if isinstance(data, list): return data if isinstance(data, list): return data
elif isinstance(data, dict): return [data] elif isinstance(data, dict): return [data]

@ -375,14 +375,15 @@ def run_collection(config, library, metadata, requested_collections, is_test, re
builder.collect_rating_keys(movie_map, show_map) builder.collect_rating_keys(movie_map, show_map)
logger.info("") logger.info("")
if len(builder.rating_keys) > 0: if len(builder.rating_keys) > 0 and builder.build_collection:
builder.add_to_collection(movie_map) builder.add_to_collection(movie_map)
if len(builder.missing_movies) > 0 or len(builder.missing_shows) > 0: if len(builder.missing_movies) > 0 or len(builder.missing_shows) > 0:
builder.run_missing() builder.run_missing()
if builder.sync and len(builder.rating_keys) > 0: if builder.sync and len(builder.rating_keys) > 0 and builder.build_collection:
builder.sync_collection() builder.sync_collection()
logger.info("") logger.info("")
if builder.build_collection:
builder.update_details() builder.update_details()
if builder.run_again and (len(builder.run_again_movies) > 0 or len(builder.run_again_shows) > 0): if builder.run_again and (len(builder.run_again_movies) > 0 or len(builder.run_again_shows) > 0):

Loading…
Cancel
Save