added `title` search #88

pull/83/head
meisnate12 4 years ago
parent dfcf5ed624
commit 716d5d4837

@ -304,6 +304,8 @@ class CollectionBuilder:
else: else:
final_values.append(value) final_values.append(value)
self.methods.append(("plex_search", [[(method_name, final_values)]])) self.methods.append(("plex_search", [[(method_name, final_values)]]))
elif method_name == "title":
self.methods.append(("plex_search", [[(method_name, data[m])]]))
elif method_name in util.plex_searches: elif method_name in util.plex_searches:
self.methods.append(("plex_search", [[(method_name, util.get_list(data[m]))]])) self.methods.append(("plex_search", [[(method_name, util.get_list(data[m]))]]))
elif method_name == "plex_all": elif method_name == "plex_all":
@ -420,6 +422,9 @@ class CollectionBuilder:
if len(years) > 0: if len(years) > 0:
used.append(util.remove_not(search)) used.append(util.remove_not(search))
searches.append((search, util.get_int_list(data[m][s], util.remove_not(search)))) searches.append((search, util.get_int_list(data[m][s], util.remove_not(search))))
elif search == "title":
used.append(util.remove_not(search))
searches.append((search, data[m][s]))
elif search in util.plex_searches: elif search in util.plex_searches:
used.append(util.remove_not(search)) used.append(util.remove_not(search))
searches.append((search, util.get_list(data[m][s]))) searches.append((search, util.get_list(data[m][s])))
@ -644,17 +649,32 @@ class CollectionBuilder:
items_found += len(items) items_found += len(items)
elif method == "plex_search": elif method == "plex_search":
search_terms = {} search_terms = {}
for i, attr_pair in enumerate(value): title_search = None
search_list = attr_pair[1] has_processed = False
final_method = attr_pair[0][:-4] + "!" if attr_pair[0][-4:] == ".not" else attr_pair[0] for search_method, search_data in value:
if search_method == "title":
title_search = search_data
logger.info(f"Processing {pretty}: title({title_search})")
has_processed = True
for search_method, search_list in value:
if search_method != "title":
final_method = search_method[:-4] + "!" if search_method[-4:] == ".not" else search_method
if self.library.is_show: if self.library.is_show:
final_method = "show." + final_method final_method = "show." + final_method
search_terms[final_method] = search_list search_terms[final_method] = search_list
ors = "" ors = ""
for o, param in enumerate(attr_pair[1]): for o, param in enumerate(search_list):
or_des = " OR " if o > 0 else f"{attr_pair[0]}(" or_des = " OR " if o > 0 else f"{search_method}("
ors += f"{or_des}{param}" ors += f"{or_des}{param}"
logger.info(f"\t\t AND {ors})" if i > 0 else f"Processing {pretty}: {ors})") if title_search or has_processed:
logger.info(f"\t\t AND {ors})")
else:
logger.info(f"Processing {pretty}: {ors})")
has_processed = True
if title_search:
items = self.library.Plex.search(title_search, **search_terms)
else:
items = self.library.Plex.search(**search_terms) items = self.library.Plex.search(**search_terms)
items_found += len(items) items_found += len(items)
elif method == "plex_collectionless": elif method == "plex_collectionless":

@ -309,6 +309,7 @@ plex_searches = [
"genre", #"genre.not", "genre", #"genre.not",
"producer", #"producer.not", "producer", #"producer.not",
"studio", #"studio.not", "studio", #"studio.not",
"title",
"writer", #"writer.not" "writer", #"writer.not"
"year" #"year.not", "year" #"year.not",
] ]

Loading…
Cancel
Save