small fixes

pull/264/head
meisnate12 4 years ago
parent d7c0bc6820
commit 4e40669381

@ -325,6 +325,7 @@ class Config:
else: else:
params["name"] = str(library_name) params["name"] = str(library_name)
logger.info(f"Connecting to {params['name']} Library...") logger.info(f"Connecting to {params['name']} Library...")
params["mapping_name"] = str(library_name)
params["asset_directory"] = check_for_attribute(lib, "asset_directory", parent="settings", var_type="list_path", default=self.general["asset_directory"], default_is_none=True, save=False) params["asset_directory"] = check_for_attribute(lib, "asset_directory", parent="settings", var_type="list_path", default=self.general["asset_directory"], default_is_none=True, save=False)
if params["asset_directory"] is None: if params["asset_directory"] is None:

@ -2,6 +2,7 @@ import logging, re, requests
from lxml import html from lxml import html
from modules import util from modules import util
from modules.util import Failed from modules.util import Failed
from plexapi.exceptions import BadRequest
from retrying import retry from retrying import retry
logger = logging.getLogger("Plex Meta Manager") logger = logging.getLogger("Plex Meta Manager")
@ -356,7 +357,9 @@ class Convert:
return "movie", tmdb_id return "movie", tmdb_id
else: else:
raise Failed(f"No ID to convert") raise Failed(f"No ID to convert")
except Failed as e: except Failed as e:
util.print_end(length, f"Mapping Error | {item.guid:<46} | {e} for {item.title}") util.print_end(length, f"Mapping Error | {item.guid:<46} | {e} for {item.title}")
except BadRequest:
util.print_stacktrace()
util.print_end(length, f"Mapping Error: | {item.guid} for {item.title} not found")
return None, None return None, None

@ -396,7 +396,11 @@ class PlexAPI:
@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_plex) @retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_plex)
def get_guids(self, item): def get_guids(self, item):
item.reload(includeOnDeck=False, includeRelated=False, includeReviews=False) item.reload(checkFiles=False, includeAllConcerts=False, includeBandwidths=False, includeChapters=False,
includeChildren=False, includeConcerts=False, includeExternalMedia=False, inclueExtras=False,
includeFields='', includeGeolocation=False, includeLoudnessRamps=False, includeMarkers=False,
includeOnDeck=False, includePopularLeaves=False, includePreferences=False, includeRelated=False,
includeRelatedCount=0, includeReviews=False, includeStations=False)
return item.guids return item.guids
@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_plex) @retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_plex)

@ -366,16 +366,22 @@ def centered(text, do_print=True):
return final_text return final_text
def separator(text=None): def separator(text=None):
logger.handlers[0].setFormatter(logging.Formatter(f"%(message)-{screen_width - 2}s")) for handler in logger.handlers:
logger.handlers[1].setFormatter(logging.Formatter(f"[%(asctime)s] %(filename)-27s %(levelname)-10s %(message)-{screen_width - 2}s")) apply_formatter(handler, border=False)
logger.info(f"|{separating_character * screen_width}|") logger.info(f"|{separating_character * screen_width}|")
if text: if text:
text_list = text.split("\n") text_list = text.split("\n")
for t in text_list: for t in text_list:
logger.info(f"| {centered(t, do_print=False)} |") logger.info(f"| {centered(t, do_print=False)} |")
logger.info(f"|{separating_character * screen_width}|") logger.info(f"|{separating_character * screen_width}|")
logger.handlers[0].setFormatter(logging.Formatter(f"| %(message)-{screen_width - 2}s |")) for handler in logger.handlers:
logger.handlers[1].setFormatter(logging.Formatter(f"[%(asctime)s] %(filename)-27s %(levelname)-10s | %(message)-{screen_width - 2}s |")) apply_formatter(handler)
def apply_formatter(handler, border=True):
text = f"| %(message)-{screen_width - 2}s |" if border else f"%(message)-{screen_width - 2}s"
if not isinstance(handler, logging.StreamHandler):
text = f"[%(asctime)s] %(filename)-27s %(levelname)-10s {text}"
handler.setFormatter(logging.Formatter(text))
def print_return(length, text): def print_return(length, text):
print(adjust_space(length, f"| {text}"), end="\r") print(adjust_space(length, f"| {text}"), end="\r")

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

Loading…
Cancel
Save