#366 skip mapping for other video libraries

pull/368/head
meisnate12 3 years ago
parent a94806b2d4
commit 4da077b65e

@ -255,12 +255,17 @@ class Plex:
self.Plex = next((s for s in self.PlexServer.library.sections() if s.title == params["name"]), None) self.Plex = next((s for s in self.PlexServer.library.sections() if s.title == params["name"]), None)
if not self.Plex: if not self.Plex:
raise Failed(f"Plex Error: Plex Library {params['name']} not found") raise Failed(f"Plex Error: Plex Library {params['name']} not found")
if self.Plex.type not in ["movie", "show"]: if self.Plex.type in ["movie", "show"]:
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.agent = self.Plex.agent self.agent = self.Plex.agent
self.is_movie = self.Plex.type == "movie" self.is_movie = self.type == "Movie"
self.is_show = self.Plex.type == "show" self.is_show = self.type == "Show"
self.is_other = self.agent == "com.plexapp.agents.none"
if self.is_other:
self.type = "Video"
self.collections = [] self.collections = []
self.metadatas = [] self.metadatas = []
@ -365,7 +370,7 @@ class Plex:
return self.PlexServer.fetchItem(data) return self.PlexServer.fetchItem(data)
def get_all(self): def get_all(self):
logger.info(f"Loading All {'Movie' if self.is_movie else 'Show'}s from Library: {self.name}") logger.info(f"Loading All {self.type}s from Library: {self.name}")
key = f"/library/sections/{self.Plex.key}/all?type={utils.searchType(self.Plex.TYPE)}" key = f"/library/sections/{self.Plex.key}/all?type={utils.searchType(self.Plex.TYPE)}"
container_start = 0 container_start = 0
container_size = plexapi.X_PLEX_CONTAINER_SIZE container_size = plexapi.X_PLEX_CONTAINER_SIZE
@ -374,7 +379,7 @@ class Plex:
results.extend(self.fetchItems(key, container_start, container_size)) results.extend(self.fetchItems(key, container_start, container_size))
util.print_return(f"Loaded: {container_start}/{self.Plex._totalViewSize}") util.print_return(f"Loaded: {container_start}/{self.Plex._totalViewSize}")
container_start += container_size container_start += container_size
logger.info(util.adjust_space(f"Loaded {self.Plex._totalViewSize} {'Movies' if self.is_movie else 'Shows'}")) logger.info(util.adjust_space(f"Loaded {self.Plex._totalViewSize} {self.type}s"))
return results return results
@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)
@ -629,10 +634,9 @@ class Plex:
return valid_collections return valid_collections
def get_rating_keys(self, method, data): def get_rating_keys(self, method, data):
media_type = "Movie" if self.is_movie else "Show"
items = [] items = []
if method == "plex_all": if method == "plex_all":
logger.info(f"Processing Plex All {media_type}s") logger.info(f"Processing Plex All {self.type}s")
items = self.get_all() items = self.get_all()
elif method == "plex_search": elif method == "plex_search":
util.print_multiline(data[1], info=True) util.print_multiline(data[1], info=True)
@ -673,7 +677,7 @@ class Plex:
break break
if add_item: if add_item:
items.append(item) items.append(item)
logger.info(util.adjust_space(f"Processed {len(all_items)} {'Movies' if self.is_movie else 'Shows'}")) logger.info(util.adjust_space(f"Processed {len(all_items)} {self.type}s"))
else: else:
raise Failed(f"Plex Error: Method {method} not supported") raise Failed(f"Plex Error: Method {method} not supported")
if len(items) > 0: if len(items) > 0:
@ -720,7 +724,7 @@ class Plex:
def map_guids(self): def map_guids(self):
items = self.get_all() items = self.get_all()
logger.info(f"Mapping {'Movie' if self.is_movie else 'Show'} Library: {self.name}") logger.info(f"Mapping {self.type} Library: {self.name}")
logger.info("") logger.info("")
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}")
@ -736,7 +740,7 @@ class Plex:
if imdb_id: if imdb_id:
util.add_dict_list(imdb_id, item.ratingKey, self.imdb_map) util.add_dict_list(imdb_id, item.ratingKey, self.imdb_map)
logger.info("") logger.info("")
logger.info(util.adjust_space(f"Processed {len(items)} {'Movies' if self.is_movie else 'Shows'}")) logger.info(util.adjust_space(f"Processed {len(items)} {self.type}s"))
return items return items
def get_tmdb_from_map(self, item): def get_tmdb_from_map(self, item):

@ -144,12 +144,14 @@ def update_libraries(config):
os.environ["PLEXAPI_PLEXAPI_TIMEOUT"] = str(library.timeout) os.environ["PLEXAPI_PLEXAPI_TIMEOUT"] = str(library.timeout)
logger.info("") logger.info("")
util.separator(f"{library.name} Library") util.separator(f"{library.name} Library")
items = None
if not library.is_other:
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("")
items = library.map_guids() items = 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, items) mass_metadata(config, library, items=items)
for metadata in library.metadata_files: for metadata in library.metadata_files:
logger.info("") logger.info("")
util.separator(f"Running Metadata File\n{metadata.path}") util.separator(f"Running Metadata File\n{metadata.path}")
@ -198,7 +200,7 @@ def update_libraries(config):
if library.assets_for_all and not collection_only: if library.assets_for_all and not collection_only:
logger.info("") logger.info("")
util.separator(f"All {'Movies' if library.is_movie else 'Shows'} Assets Check for {library.name} Library", space=False, border=False) util.separator(f"All {library.type}s Assets Check for {library.name} Library", space=False, border=False)
logger.info("") logger.info("")
for col in unmanaged_collections: for col in unmanaged_collections:
poster, background = library.find_collection_assets(col, create=library.create_asset_folders) poster, background = library.find_collection_assets(col, create=library.create_asset_folders)
@ -257,10 +259,12 @@ def update_libraries(config):
if library.optimize: if library.optimize:
library.query(library.PlexServer.library.optimize) library.query(library.PlexServer.library.optimize)
def mass_metadata(config, library, items): def mass_metadata(config, library, items=None):
logger.info("") logger.info("")
util.separator(f"Mass Editing {'Movie' if library.is_movie else 'Show'} Library: {library.name}") util.separator(f"Mass Editing {library.type} Library: {library.name}")
logger.info("") logger.info("")
if items is None:
items = library.get_all()
if library.split_duplicates: if library.split_duplicates:
items = library.search(**{"duplicate": True}) items = library.search(**{"duplicate": True})
for item in items: for item in items:

Loading…
Cancel
Save