added config to plex and meta

pull/309/head
meisnate12 4 years ago
parent f8c825fff6
commit c9567cdd96

@ -449,7 +449,7 @@ class Config:
params["plex"]["clean_bundles"] = check_for_attribute(lib, "clean_bundles", parent="plex", var_type="bool", default=self.general["plex"]["clean_bundles"], save=False) params["plex"]["clean_bundles"] = check_for_attribute(lib, "clean_bundles", parent="plex", var_type="bool", default=self.general["plex"]["clean_bundles"], save=False)
params["plex"]["empty_trash"] = check_for_attribute(lib, "empty_trash", parent="plex", var_type="bool", default=self.general["plex"]["empty_trash"], save=False) params["plex"]["empty_trash"] = check_for_attribute(lib, "empty_trash", parent="plex", var_type="bool", default=self.general["plex"]["empty_trash"], save=False)
params["plex"]["optimize"] = check_for_attribute(lib, "optimize", parent="plex", var_type="bool", default=self.general["plex"]["optimize"], save=False) params["plex"]["optimize"] = check_for_attribute(lib, "optimize", parent="plex", var_type="bool", default=self.general["plex"]["optimize"], save=False)
library = PlexAPI(params) library = PlexAPI(self, params)
logger.info("") logger.info("")
logger.info(f"{display_name} Library Connection Successful") logger.info(f"{display_name} Library Connection Successful")
except Failed as e: except Failed as e:

@ -8,7 +8,8 @@ from ruamel import yaml
logger = logging.getLogger("Plex Meta Manager") logger = logging.getLogger("Plex Meta Manager")
class Metadata: class Metadata:
def __init__(self, library, file_type, path): def __init__(self, config, library, file_type, path):
self.config = config
self.library = library self.library = library
self.type = file_type self.type = file_type
self.path = path self.path = path

@ -260,7 +260,8 @@ sort_types = {
} }
class PlexAPI: class PlexAPI:
def __init__(self, params): def __init__(self, config, params):
self.config = config
try: try:
self.PlexServer = PlexServer(params["plex"]["url"], params["plex"]["token"], timeout=params["plex"]["timeout"]) self.PlexServer = PlexServer(params["plex"]["url"], params["plex"]["token"], timeout=params["plex"]["timeout"])
except Unauthorized: except Unauthorized:
@ -285,7 +286,7 @@ class PlexAPI:
self.metadata_files = [] self.metadata_files = []
for file_type, metadata_file in params["metadata_path"]: for file_type, metadata_file in params["metadata_path"]:
try: try:
meta_obj = Metadata(self, file_type, metadata_file) meta_obj = Metadata(config, self, file_type, metadata_file)
if meta_obj.collections: if meta_obj.collections:
self.collections.extend([c for c in meta_obj.collections]) self.collections.extend([c for c in meta_obj.collections])
if meta_obj.metadata: if meta_obj.metadata:
@ -603,7 +604,7 @@ class PlexAPI:
name = collection.title if isinstance(collection, Collections) else str(collection) name = collection.title if isinstance(collection, Collections) else str(collection)
return name, self.get_collection_items(collection, smart_label_collection) return name, self.get_collection_items(collection, smart_label_collection)
def map_guids(self, config): def map_guids(self):
logger.info(f"Loading {'Movie' if self.is_movie else 'Show'} Library: {self.name}") logger.info(f"Loading {'Movie' if self.is_movie else 'Show'} Library: {self.name}")
logger.info("") logger.info("")
items = self.Plex.all() items = self.Plex.all()
@ -612,7 +613,7 @@ class PlexAPI:
for i, item in enumerate(items, 1): for i, item in enumerate(items, 1):
util.print_return(f"Processing: {i}/{len(items)} {item.title}") util.print_return(f"Processing: {i}/{len(items)} {item.title}")
if item.ratingKey not in self.movie_rating_key_map and item.ratingKey not in self.show_rating_key_map: if item.ratingKey not in self.movie_rating_key_map and item.ratingKey not in self.show_rating_key_map:
id_type, main_id = config.Convert.get_id(item, self) id_type, main_id = self.config.Convert.get_id(item, self)
if main_id: if main_id:
if not isinstance(main_id, list): if not isinstance(main_id, list):
main_id = [main_id] main_id = [main_id]

@ -144,7 +144,7 @@ def update_libraries(config):
logger.info("") logger.info("")
util.separator(f"Mapping {library.name} Library", space=False, border=False) util.separator(f"Mapping {library.name} Library", space=False, border=False)
logger.info("") logger.info("")
library.map_guids(config) library.map_guids()
if not config.test_mode and not config.resume_from and not collection_only and library.mass_update: if not config.test_mode and not config.resume_from and not collection_only and library.mass_update:
mass_metadata(config, library) mass_metadata(config, library)
for metadata in library.metadata_files: for metadata in library.metadata_files:
@ -221,7 +221,7 @@ def update_libraries(config):
logger.info("") logger.info("")
util.separator(f"{library.name} Library Run Again") util.separator(f"{library.name} Library Run Again")
logger.info("") logger.info("")
library.map_guids(config) library.map_guids()
for builder in library.run_again: for builder in library.run_again:
logger.info("") logger.info("")
util.separator(f"{builder.name} Collection") util.separator(f"{builder.name} Collection")

Loading…
Cancel
Save