Skip to content

Commit

Permalink
Merge pull request #326 from meisnate12/develop
Browse files Browse the repository at this point in the history
v1.11.2
  • Loading branch information
meisnate12 authored Jul 8, 2021
2 parents b740b85 + a427e76 commit f2e4d7a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 41 deletions.
88 changes: 54 additions & 34 deletions modules/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"trakt_watched",
"trakt_collected"
]
smart_collection_invalid = ["collection_mode", "collection_order"]
smart_collection_invalid = ["collection_order"]
smart_url_collection_invalid = [
"run_again", "sync_mode", "show_filtered", "show_missing", "save_missing", "smart_label",
"radarr_add", "radarr_folder", "radarr_monitor", "radarr_availability",
Expand Down Expand Up @@ -1098,35 +1098,57 @@ def get_int(parent, int_method, data_in, methods_in, default_in, minimum=1, maxi
logger.info("Validation Successful")

def collect_rating_keys(self):
filtered_keys = {}
name = self.obj.title if self.obj else self.name
def add_rating_keys(keys):
if not isinstance(keys, list):
keys = [keys]
self.rating_keys.extend([key for key in keys if key not in self.rating_keys])
total = len(keys)
max_length = len(str(total))
if self.filters and self.details["show_filtered"] is True:
logger.info("")
logger.info("Filtering Builder:")
for i, key in enumerate(keys, 1):
if key not in self.rating_keys:
if key in filtered_keys:
if self.details["show_filtered"] is True:
logger.info(f"{name} Collection | X | {filtered_keys[key]}")
else:
try:
current = self.fetch_item(key)
except Failed as e:
logger.error(e)
continue
current_title = f"{current.title} ({current.year})" if current.year else current.title
if self.check_filters(current, f"{(' ' * (max_length - len(str(i))))}{i}/{total}"):
self.rating_keys.append(key)
else:
if key not in filtered_keys:
filtered_keys[key] = current_title
if self.details["show_filtered"] is True:
logger.info(f"{name} Collection | X | {current_title}")
def check_map(input_ids):
movie_ids, show_ids = input_ids
items_found_inside = 0
if len(movie_ids) > 0:
items_found_inside += len(movie_ids)
for movie_id in movie_ids:
if movie_id in self.library.movie_map:
add_rating_keys(self.library.movie_map[movie_id])
elif movie_id not in self.missing_movies:
self.missing_movies.append(movie_id)
if len(show_ids) > 0:
items_found_inside += len(show_ids)
for show_id in show_ids:
if show_id in self.library.show_map:
add_rating_keys(self.library.show_map[show_id])
elif show_id not in self.missing_shows:
self.missing_shows.append(show_id)
return items_found_inside
for method, values in self.methods:
logger.debug("")
logger.debug(f"Method: {method}")
logger.debug(f"Values: {values}")
for value in values:
def check_map(input_ids):
movie_ids, show_ids = input_ids
items_found_inside = 0
if len(movie_ids) > 0:
items_found_inside += len(movie_ids)
for movie_id in movie_ids:
if movie_id in self.library.movie_map:
add_rating_keys(self.library.movie_map[movie_id])
elif movie_id not in self.missing_movies:
self.missing_movies.append(movie_id)
if len(show_ids) > 0:
items_found_inside += len(show_ids)
for show_id in show_ids:
if show_id in self.library.show_map:
add_rating_keys(self.library.show_map[show_id])
elif show_id not in self.missing_shows:
self.missing_shows.append(show_id)
return items_found_inside
logger.debug("")
logger.debug(f"Value: {value}")
logger.debug(f"Builder: {method}: {value}")
logger.info("")
if "plex" in method: add_rating_keys(self.library.get_items(method, value))
elif "tautulli" in method: add_rating_keys(self.library.Tautulli.get_items(self.library, value))
Expand Down Expand Up @@ -1409,16 +1431,14 @@ def add_to_collection(self):
logger.error(e)
continue
current_title = f"{current.title} ({current.year})" if current.year else current.title
if self.check_filters(current, f"{(' ' * (max_length - len(str(i))))}{i}/{total}"):
logger.info(util.adjust_space(f"{name} Collection | {'=' if current in collection_items else '+'} | {current_title}"))
if current in collection_items:
self.plex_map[current.ratingKey] = None
elif self.smart_label_collection:
self.library.query_data(current.addLabel, name)
else:
self.library.query_data(current.addCollection, name)
elif self.details["show_filtered"] is True:
logger.info(f"{name} Collection | X | {current_title}")
current_operation = "=" if current in collection_items else "+"
logger.info(util.adjust_space(f"{name} Collection | {current_operation} | {current_title}"))
if current in collection_items:
self.plex_map[current.ratingKey] = None
elif self.smart_label_collection:
self.library.query_data(current.addLabel, name)
else:
self.library.query_data(current.addCollection, name)
media_type = f"{'Movie' if self.library.is_movie else 'Show'}{'s' if total > 1 else ''}"
util.print_end()
logger.info("")
Expand Down
3 changes: 0 additions & 3 deletions modules/plex.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ def fetchItem(self, data):

def get_all(self):
logger.info(f"Loading All {'Movie' if self.is_movie else 'Show'}s from Library: {self.name}")
logger.info("")
key = f"/library/sections/{self.Plex.key}/all?type={utils.searchType(self.Plex.TYPE)}"
container_start = 0
container_size = plexapi.X_PLEX_CONTAINER_SIZE
Expand All @@ -372,7 +371,6 @@ def get_all(self):
util.print_return(f"Loaded: {container_start}/{self.Plex._totalViewSize}")
container_start += container_size
logger.info(util.adjust_space(f"Loaded {self.Plex._totalViewSize} {'Movies' if self.is_movie else 'Shows'}"))
logger.info("")
return results

@retry(stop_max_attempt_number=6, wait_fixed=10000, retry_on_exception=util.retry_if_not_plex)
Expand Down Expand Up @@ -523,7 +521,6 @@ def _query(self, key, post=False, put=False):
if post: method = self.Plex._server._session.post
elif put: method = self.Plex._server._session.put
else: method = None
self.Plex._server.query(key, method=method)
return self.Plex._server.query(key, method=method)

def smart_label_url(self, title, sort):
Expand Down
9 changes: 5 additions & 4 deletions plex_meta_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def start(config_path, is_test=False, time_scheduled=None, requested_collections
logger.info(util.centered("| __/| | __/> < | | | | __/ || (_| | | | | | (_| | | | | (_| | (_| | __/ | "))
logger.info(util.centered("|_| |_|\\___/_/\\_\\ |_| |_|\\___|\\__\\__,_| |_| |_|\\__,_|_| |_|\\__,_|\\__, |\\___|_| "))
logger.info(util.centered(" |___/ "))
logger.info(util.centered(" Version: 1.11.0 "))
logger.info(util.centered(" Version: 1.11.2 "))
if time_scheduled: start_type = f"{time_scheduled} "
elif is_test: start_type = "Test "
elif requested_collections: start_type = "Collections "
Expand Down Expand Up @@ -449,9 +449,10 @@ def run_collection(config, library, metadata, requested_collections):
logger.info("")
builder.add_to_collection()
if len(builder.missing_movies) > 0 or len(builder.missing_shows) > 0:
logger.info("")
util.separator(f"Missing from Library", space=False, border=False)
logger.info("")
if builder.details["show_missing"] is True:
logger.info("")
util.separator(f"Missing from Library", space=False, border=False)
logger.info("")
builder.run_missing()
if builder.sync and len(builder.rating_keys) > 0 and builder.build_collection:
builder.sync_collection()
Expand Down

0 comments on commit f2e4d7a

Please sign in to comment.