|
|
|
@ -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
|
|
|
|
|