pull/102/head
meisnate12 4 years ago
parent 1ec097a4ce
commit e0d1056e70

@ -130,13 +130,19 @@ class PlexAPI:
length = util.print_return(length, f"Filtering {(' ' * (max_length - len(str(i)))) + str(i)}/{total} {current.title}") length = util.print_return(length, f"Filtering {(' ' * (max_length - len(str(i)))) + str(i)}/{total} {current.title}")
for filter_method, filter_data in filters: for filter_method, filter_data in filters:
modifier = filter_method[-4:] modifier = filter_method[-4:]
method = util.filter_alias[filter_method[:-4]] if modifier in [".not", ".lte", ".gte"] else util.filter_alias[filter_method] method = filter_method[:-4] if modifier in [".not", ".lte", ".gte"] else filter_method
if method == "max_age": 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) threshold_date = datetime.now() - timedelta(days=filter_data)
if current.originallyAvailableAt is None or current.originallyAvailableAt < threshold_date: if current.originallyAvailableAt is None or current.originallyAvailableAt < threshold_date:
match = False match = False
break break
elif method == "original_language": elif method_name == "original_language":
movie = None movie = None
for key, value in movie_map.items(): for key, value in movie_map.items():
if current.ratingKey == value: 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): if (modifier == ".not" and movie.original_language in filter_data) or (modifier != ".not" and movie.original_language not in filter_data):
match = False match = False
break break
elif method == "audio_track_title": elif method_name == "audio_track_title":
jailbreak = False jailbreak = False
for media in current.media: for media in current.media:
for part in media.parts: for part in media.parts:
@ -168,7 +174,7 @@ class PlexAPI:
match = False match = False
break break
elif modifier in [".gte", ".lte"]: elif modifier in [".gte", ".lte"]:
if method == "vote_count": if method_name == "vote_count":
tmdb_item = None tmdb_item = None
for key, value in movie_map.items(): for key, value in movie_map.items():
if current.ratingKey == value: if current.ratingKey == value:
@ -182,20 +188,20 @@ class PlexAPI:
continue continue
attr = tmdb_item.vote_count attr = tmdb_item.vote_count
else: 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): if (modifier == ".lte" and attr > filter_data) or (modifier == ".gte" and attr < filter_data):
match = False match = False
break break
else: else:
attrs = [] 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: 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: for part in media.parts:
if method == "audio_language": attrs.extend([a.language for a in part.audioStreams()]) if method_name == "audio_language": attrs.extend([a.language for a in part.audioStreams()])
if method == "subtitle_language": attrs.extend([s.language for s in part.subtitleStreams()]) if method_name == "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_name in ["contentRating", "studio", "year", "rating", "originallyAvailableAt"]: attrs = [str(getattr(current, method_name))]
elif method in ["actors", "countries", "directors", "genres", "writers", "collections"]: attrs = [getattr(x, "tag") for x in getattr(current, method)] 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"): if (not list(set(filter_data) & set(attrs)) and modifier != ".not") or (list(set(filter_data) & set(attrs)) and modifier == ".not"):
match = False match = False

@ -36,23 +36,14 @@ method_alias = {
} }
filter_alias = { filter_alias = {
"actor": "actors", "actor": "actors",
"audio_language": "audio_language",
"audio_track_title": "audio_track_title",
"collection": "collections", "collection": "collections",
"content_rating": "contentRating", "content_rating": "contentRating",
"country": "countries", "country": "countries",
"director": "directors", "director": "directors",
"genre": "genres", "genre": "genres",
"max_age": "max_age",
"originally_available": "originallyAvailableAt", "originally_available": "originallyAvailableAt",
"original_language": "original_language",
"rating": "rating",
"studio": "studio",
"subtitle_language": "subtitle_language",
"tmdb_vote_count": "vote_count", "tmdb_vote_count": "vote_count",
"writer": "writers", "writer": "writers"
"video_resolution": "video_resolution",
"year": "year"
} }
days_alias = { days_alias = {
"monday": 0, "mon": 0, "m": 0, "monday": 0, "mon": 0, "m": 0,

Loading…
Cancel
Save