|
|
|
@ -6,7 +6,6 @@ try:
|
|
|
|
|
from modules.builder import CollectionBuilder
|
|
|
|
|
from modules.config import Config
|
|
|
|
|
from modules.util import Failed
|
|
|
|
|
from plexapi.exceptions import BadRequest
|
|
|
|
|
except ModuleNotFoundError:
|
|
|
|
|
print("Error: Requirements are not installed")
|
|
|
|
|
sys.exit(0)
|
|
|
|
@ -77,10 +76,8 @@ def fmt_filter(record):
|
|
|
|
|
|
|
|
|
|
file_handler = logging.handlers.TimedRotatingFileHandler(os.path.join(default_dir, "logs", "meta.log"), when="midnight", backupCount=10, encoding="utf-8")
|
|
|
|
|
file_handler.addFilter(fmt_filter)
|
|
|
|
|
file_handler.setFormatter(logging.Formatter("[%(asctime)s] %(filename)-27s %(levelname)-10s | %(message)-100s |"))
|
|
|
|
|
|
|
|
|
|
cmd_handler = logging.StreamHandler()
|
|
|
|
|
cmd_handler.setFormatter(logging.Formatter("| %(message)-100s |"))
|
|
|
|
|
cmd_handler.setLevel(logging.DEBUG if test or debug else logging.INFO)
|
|
|
|
|
|
|
|
|
|
logger.addHandler(cmd_handler)
|
|
|
|
@ -214,12 +211,8 @@ def map_guids(config, library):
|
|
|
|
|
items = library.Plex.all()
|
|
|
|
|
for i, item in enumerate(items, 1):
|
|
|
|
|
length = util.print_return(length, f"Processing: {i}/{len(items)} {item.title}")
|
|
|
|
|
try:
|
|
|
|
|
id_type, main_id = config.Convert.get_id(item, library, length)
|
|
|
|
|
except BadRequest:
|
|
|
|
|
util.print_stacktrace()
|
|
|
|
|
util.print_end(length, f"Mapping Error: | {item.guid} for {item.title} not found")
|
|
|
|
|
continue
|
|
|
|
|
if main_id:
|
|
|
|
|
if not isinstance(main_id, list):
|
|
|
|
|
main_id = [main_id]
|
|
|
|
|
if id_type == "movie":
|
|
|
|
@ -332,6 +325,7 @@ def mass_metadata(config, library, movie_map, show_map):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def run_collection(config, library, metadata, requested_collections, is_test, resume_from, movie_map, show_map):
|
|
|
|
|
logger.info("")
|
|
|
|
|
for mapping_name, collection_attrs in requested_collections.items():
|
|
|
|
|
if is_test and ("test" not in collection_attrs or collection_attrs["test"] is not True):
|
|
|
|
|
no_template_test = True
|
|
|
|
@ -347,7 +341,7 @@ def run_collection(config, library, metadata, requested_collections, is_test, re
|
|
|
|
|
no_template_test = False
|
|
|
|
|
if no_template_test:
|
|
|
|
|
continue
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
|
|
if resume_from and resume_from != mapping_name:
|
|
|
|
|
continue
|
|
|
|
|
elif resume_from == mapping_name:
|
|
|
|
@ -355,7 +349,7 @@ def run_collection(config, library, metadata, requested_collections, is_test, re
|
|
|
|
|
logger.info("")
|
|
|
|
|
util.separator(f"Resuming Collections")
|
|
|
|
|
|
|
|
|
|
logger.info("")
|
|
|
|
|
try:
|
|
|
|
|
util.separator(f"{mapping_name} Collection")
|
|
|
|
|
logger.info("")
|
|
|
|
|
|
|
|
|
@ -364,6 +358,7 @@ def run_collection(config, library, metadata, requested_collections, is_test, re
|
|
|
|
|
if len(builder.schedule) > 0:
|
|
|
|
|
util.print_multiline(builder.schedule, info=True)
|
|
|
|
|
|
|
|
|
|
if not builder.smart_url:
|
|
|
|
|
logger.info("")
|
|
|
|
|
logger.info(f"Sync Mode: {'sync' if builder.sync else 'append'}")
|
|
|
|
|
|
|
|
|
@ -372,7 +367,6 @@ def run_collection(config, library, metadata, requested_collections, is_test, re
|
|
|
|
|
for filter_key, filter_value in builder.filters:
|
|
|
|
|
logger.info(f"Collection Filter {filter_key}: {filter_value}")
|
|
|
|
|
|
|
|
|
|
if not builder.smart_url:
|
|
|
|
|
builder.collect_rating_keys(movie_map, show_map)
|
|
|
|
|
logger.info("")
|
|
|
|
|
if len(builder.rating_keys) > 0:
|
|
|
|
@ -394,6 +388,7 @@ def run_collection(config, library, metadata, requested_collections, is_test, re
|
|
|
|
|
except Exception as e:
|
|
|
|
|
util.print_stacktrace()
|
|
|
|
|
logger.error(f"Unknown Error: {e}")
|
|
|
|
|
logger.info("")
|
|
|
|
|
return resume_from
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|