mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-10 06:54:21 +00:00
[14] #831 utilize cache more
This commit is contained in:
parent
182f977a91
commit
a66ccc1a8f
6 changed files with 39 additions and 33 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
1.16.5-develop13
|
||||
1.16.5-develop14
|
||||
|
|
|
@ -354,6 +354,8 @@ class CollectionBuilder:
|
|||
"changes_webhooks": self.library.changes_webhooks,
|
||||
"cache_builders": 0
|
||||
}
|
||||
if self.library.mass_collection_mode:
|
||||
self.details["collection_mode"] = self.library.mass_collection_mode
|
||||
self.item_details = {}
|
||||
self.radarr_details = {}
|
||||
self.sonarr_details = {}
|
||||
|
@ -885,10 +887,10 @@ class CollectionBuilder:
|
|||
elif method_name == "tmdb_region":
|
||||
self.tmdb_region = util.parse(self.Type, method_name, method_data, options=self.config.TMDb.iso_3166_1)
|
||||
elif method_name == "collection_mode":
|
||||
if method_data and str(method_data).lower() in plex.collection_mode_options:
|
||||
self.details[method_name] = plex.collection_mode_options[str(method_data).lower()]
|
||||
else:
|
||||
logger.error(f"Config Error: {method_data} collection_mode invalid\n\tdefault (Library default)\n\thide (Hide Collection)\n\thide_items (Hide Items in this Collection)\n\tshow_items (Show this Collection and its Items)")
|
||||
try:
|
||||
self.details[method_name] = util.check_collection_mode(method_data)
|
||||
except Failed as e:
|
||||
logger.error(e)
|
||||
elif method_name == "collection_filtering":
|
||||
if method_data and str(method_data).lower() in plex.collection_filtering_options:
|
||||
self.details[method_name] = str(method_data).lower()
|
||||
|
@ -2023,7 +2025,6 @@ class CollectionBuilder:
|
|||
total = len(items)
|
||||
spacing = len(str(total)) * 2 + 1
|
||||
for i, item in enumerate(items, 1):
|
||||
self.library.reload(item)
|
||||
number_text = f"{i}/{total}"
|
||||
logger.info(f"{number_text:>{spacing}} | {self.name} {self.Type} | - | {util.item_title(item)}")
|
||||
if self.playlist:
|
||||
|
@ -2409,15 +2410,15 @@ class CollectionBuilder:
|
|||
path = path.replace(self.library.Sonarr.plex_path, self.library.Sonarr.sonarr_path)
|
||||
path = path[:-1] if path.endswith(('/', '\\')) else path
|
||||
tvdb_paths.append((self.library.show_rating_key_map[item.ratingKey], path))
|
||||
advance_edits = {}
|
||||
if hasattr(item, "preferences"):
|
||||
if any([mn in plex.item_advance_keys for mn in self.item_details]) and hasattr(item, "preferences"):
|
||||
advance_edits = {}
|
||||
prefs = [p.id for p in item.preferences()]
|
||||
for method_name, method_data in self.item_details.items():
|
||||
if method_name in plex.item_advance_keys:
|
||||
key, options = plex.item_advance_keys[method_name]
|
||||
if key in prefs and getattr(item, key) != options[method_data]:
|
||||
advance_edits[key] = options[method_data]
|
||||
self.library.edit_item(item, item.title, self.collection_level.capitalize(), advance_edits, advanced=True)
|
||||
self.library.edit_item(item, item.title, self.collection_level.capitalize(), advance_edits, advanced=True)
|
||||
|
||||
if "item_tmdb_season_titles" in self.item_details and item.ratingKey in self.library.show_rating_key_map:
|
||||
try:
|
||||
|
|
|
@ -32,6 +32,7 @@ class Library(ABC):
|
|||
self.mal_map = {}
|
||||
self.movie_rating_key_map = {}
|
||||
self.show_rating_key_map = {}
|
||||
self.cached_items = {}
|
||||
self.run_again = []
|
||||
self.overlays_old = []
|
||||
self.type = ""
|
||||
|
@ -296,9 +297,17 @@ class Library(ABC):
|
|||
except yaml.scanner.ScannerError as e:
|
||||
logger.error(f"YAML Error: {util.tab_new_lines(e)}")
|
||||
|
||||
def map_guids(self):
|
||||
def cache_items(self):
|
||||
logger.info("")
|
||||
logger.separator(f"Caching {self.name} Library Items", space=False, border=False)
|
||||
logger.info("")
|
||||
items = self.get_all()
|
||||
logger.info(f"Mapping {self.type} Library: {self.name}")
|
||||
for item in items:
|
||||
self.cached_items[item.ratingKey] = item
|
||||
return items
|
||||
|
||||
def map_guids(self, items):
|
||||
logger.info(f"Mapping {self.type} Library: {self.name}", space=False, border=False)
|
||||
logger.info("")
|
||||
for i, item in enumerate(items, 1):
|
||||
logger.ghost(f"Processing: {i}/{len(items)} {item.title}")
|
||||
|
@ -315,4 +324,3 @@ class Library(ABC):
|
|||
util.add_dict_list(imdb_id, item.ratingKey, self.imdb_map)
|
||||
logger.info("")
|
||||
logger.info(f"Processed {len(items)} {self.type}s")
|
||||
return items
|
||||
|
|
|
@ -56,7 +56,7 @@ class Operations:
|
|||
logger.info(f"{len(tracks)} Tracks Processed; {num_edited} Blank Track Titles Updated")
|
||||
|
||||
if self.library.items_library_operation:
|
||||
items = self.library.get_all(load=True)
|
||||
items = self.library.get_all()
|
||||
radarr_adds = []
|
||||
sonarr_adds = []
|
||||
trakt_ratings = self.config.Trakt.user_ratings(self.library.is_movie) if self.library.mass_trakt_rating_update else []
|
||||
|
@ -67,11 +67,6 @@ class Operations:
|
|||
reverse_anidb[v] = k
|
||||
|
||||
for i, item in enumerate(items, 1):
|
||||
try:
|
||||
self.library.reload(item)
|
||||
except Failed as e:
|
||||
logger.error(e)
|
||||
continue
|
||||
logger.ghost(f"Processing: {i}/{len(items)} {item.title}")
|
||||
if self.library.assets_for_all:
|
||||
self.library.update_asset2(item)
|
||||
|
@ -356,12 +351,6 @@ class Operations:
|
|||
logger.info(f"{col.title} Deleted")
|
||||
elif col.title not in self.library.collections:
|
||||
unmanaged_collections.append(col)
|
||||
if self.library.mass_collection_mode:
|
||||
logger.info("")
|
||||
logger.separator(f"Mass Collection Mode for {self.library.name} Library", space=False, border=False)
|
||||
logger.info("")
|
||||
for col in self.library.get_all_collections():
|
||||
self.library.collection_mode_query(col, self.library.mass_collection_mode)
|
||||
|
||||
if self.library.show_unmanaged and len(unmanaged_collections) > 0:
|
||||
logger.info("")
|
||||
|
@ -382,6 +371,12 @@ class Operations:
|
|||
logger.info("")
|
||||
for col in unmanaged_collections:
|
||||
self.library.update_asset2(col)
|
||||
if self.library.mass_collection_mode:
|
||||
logger.info("")
|
||||
logger.separator(f"Unmanaged Mass Collection Mode for {self.library.name} Library", space=False, border=False)
|
||||
logger.info("")
|
||||
for col in unmanaged_collections:
|
||||
self.library.collection_mode_query(col, self.library.mass_collection_mode)
|
||||
|
||||
if self.library.metadata_backup:
|
||||
logger.info("")
|
||||
|
|
|
@ -357,7 +357,6 @@ class Plex(Library):
|
|||
|
||||
self._users = []
|
||||
self._all_items = []
|
||||
self.cached_items = {}
|
||||
self.agent = self.Plex.agent
|
||||
self.is_movie = self.type == "Movie"
|
||||
self.is_show = self.type == "Show"
|
||||
|
|
|
@ -220,12 +220,6 @@ def update_libraries(config):
|
|||
logger.info("")
|
||||
logger.separator(f"{library.name} Library")
|
||||
|
||||
if config.library_first and not config.test_mode and not collection_only:
|
||||
if not overlays_only and library.library_operation:
|
||||
library.Operations.run_operations()
|
||||
if not operations_only and (library.overlay_files or library.remove_overlays):
|
||||
library.Overlays.run_overlays()
|
||||
|
||||
logger.debug("")
|
||||
logger.debug(f"Mapping Name: {library.original_mapping_name}")
|
||||
logger.debug(f"Folder Name: {library.mapping_name}")
|
||||
|
@ -259,11 +253,20 @@ def update_libraries(config):
|
|||
for collection in library.get_all_collections():
|
||||
logger.info(f"Collection {collection.title} Deleted")
|
||||
library.query(collection.delete)
|
||||
if not library.is_other and not library.is_music and not operations_only and (library.metadata_files or library.overlay_files or library.remove_overlays):
|
||||
|
||||
temp_items = library.cache_items()
|
||||
if not library.is_other and not library.is_music:
|
||||
logger.info("")
|
||||
logger.separator(f"Mapping {library.name} Library", space=False, border=False)
|
||||
logger.info("")
|
||||
library.map_guids()
|
||||
library.map_guids(temp_items)
|
||||
|
||||
if config.library_first and not config.test_mode and not collection_only:
|
||||
if not overlays_only and library.library_operation:
|
||||
library.Operations.run_operations()
|
||||
if not operations_only and (library.overlay_files or library.remove_overlays):
|
||||
library.Overlays.run_overlays()
|
||||
|
||||
for metadata in library.metadata_files:
|
||||
metadata_name = metadata.get_file_name()
|
||||
if config.requested_metadata_files and metadata_name not in config.requested_metadata_files:
|
||||
|
|
Loading…
Reference in a new issue