diff --git a/modules/plex.py b/modules/plex.py index 2ed72f8f..db727552 100644 --- a/modules/plex.py +++ b/modules/plex.py @@ -130,13 +130,19 @@ class PlexAPI: length = util.print_return(length, f"Filtering {(' ' * (max_length - len(str(i)))) + str(i)}/{total} {current.title}") for filter_method, filter_data in filters: modifier = filter_method[-4:] - method = util.filter_alias[filter_method[:-4]] if modifier in [".not", ".lte", ".gte"] else util.filter_alias[filter_method] - if method == "max_age": + method = filter_method[:-4] if modifier in [".not", ".lte", ".gte"] else filter_method + if method in util.method_alias: + method_name = util.method_alias[method] + logger.warning(f"Collection Warning: {method} attribute will run as {method_name}") + else: + method_name = method + method_name = util.filter_alias[filter_method[:-4]] if modifier in [".not", ".lte", ".gte"] else util.filter_alias[filter_method] + if method_name == "max_age": threshold_date = datetime.now() - timedelta(days=filter_data) if current.originallyAvailableAt is None or current.originallyAvailableAt < threshold_date: match = False break - elif method == "original_language": + elif method_name == "original_language": movie = None for key, value in movie_map.items(): if current.ratingKey == value: @@ -151,7 +157,7 @@ class PlexAPI: if (modifier == ".not" and movie.original_language in filter_data) or (modifier != ".not" and movie.original_language not in filter_data): match = False break - elif method == "audio_track_title": + elif method_name == "audio_track_title": jailbreak = False for media in current.media: for part in media.parts: @@ -168,7 +174,7 @@ class PlexAPI: match = False break elif modifier in [".gte", ".lte"]: - if method == "vote_count": + if method_name == "vote_count": tmdb_item = None for key, value in movie_map.items(): if current.ratingKey == value: @@ -182,20 +188,20 @@ class PlexAPI: continue attr = tmdb_item.vote_count else: - attr = getattr(current, method) / 60000 if method == "duration" else getattr(current, method) + attr = getattr(current, method_name) / 60000 if method_name == "duration" else getattr(current, method_name) if (modifier == ".lte" and attr > filter_data) or (modifier == ".gte" and attr < filter_data): match = False break else: attrs = [] - if method in ["video_resolution", "audio_language", "subtitle_language"]: + if method_name in ["video_resolution", "audio_language", "subtitle_language"]: for media in current.media: - if method == "video_resolution": attrs.extend([media.videoResolution]) + if method_name == "video_resolution": attrs.extend([media.videoResolution]) for part in media.parts: - if method == "audio_language": attrs.extend([a.language for a in part.audioStreams()]) - if method == "subtitle_language": attrs.extend([s.language for s in part.subtitleStreams()]) - elif method in ["contentRating", "studio", "year", "rating", "originallyAvailableAt"]: attrs = [str(getattr(current, method))] - elif method in ["actors", "countries", "directors", "genres", "writers", "collections"]: attrs = [getattr(x, "tag") for x in getattr(current, method)] + if method_name == "audio_language": attrs.extend([a.language for a in part.audioStreams()]) + if method_name == "subtitle_language": attrs.extend([s.language for s in part.subtitleStreams()]) + elif method_name in ["contentRating", "studio", "year", "rating", "originallyAvailableAt"]: attrs = [str(getattr(current, method_name))] + elif method_name in ["actors", "countries", "directors", "genres", "writers", "collections"]: attrs = [getattr(x, "tag") for x in getattr(current, method_name)] if (not list(set(filter_data) & set(attrs)) and modifier != ".not") or (list(set(filter_data) & set(attrs)) and modifier == ".not"): match = False diff --git a/modules/util.py b/modules/util.py index 471f2067..43af4252 100644 --- a/modules/util.py +++ b/modules/util.py @@ -36,23 +36,14 @@ method_alias = { } filter_alias = { "actor": "actors", - "audio_language": "audio_language", - "audio_track_title": "audio_track_title", "collection": "collections", "content_rating": "contentRating", "country": "countries", "director": "directors", "genre": "genres", - "max_age": "max_age", "originally_available": "originallyAvailableAt", - "original_language": "original_language", - "rating": "rating", - "studio": "studio", - "subtitle_language": "subtitle_language", "tmdb_vote_count": "vote_count", - "writer": "writers", - "video_resolution": "video_resolution", - "year": "year" + "writer": "writers" } days_alias = { "monday": 0, "mon": 0, "m": 0,