fixes #142 and other bugs

pull/144/head
meisnate12 4 years ago
parent 63f901fb03
commit 7da12bc33c

@ -85,6 +85,7 @@ class CollectionBuilder:
optional.append(str(template["optional"])) optional.append(str(template["optional"]))
else: else:
raise Failed("Collection Error: template sub-attribute optional is blank") raise Failed("Collection Error: template sub-attribute optional is blank")
for method_name, attr_data in template.items(): for method_name, attr_data in template.items():
if method_name not in self.data and method_name not in ["default", "optional"]: if method_name not in self.data and method_name not in ["default", "optional"]:
if attr_data: if attr_data:
@ -108,30 +109,31 @@ class CollectionBuilder:
except ValueError: return txt except ValueError: return txt
try: try:
if isinstance(attr_data, dict): if isinstance(attr_data, dict):
discover_name = {} final_data = {}
for sm in attr_data: for sm in attr_data:
if isinstance(attr_data[sm], list): if isinstance(attr_data[sm], list):
temp_list = [] temp_list = []
for li in attr_data[sm]: for li in attr_data[sm]:
temp_list.append(replace_txt(li)) temp_list.append(replace_txt(li))
discover_name[sm] = temp_list final_data[sm] = temp_list
else: else:
discover_name[sm] = replace_txt(attr_data[sm]) final_data[sm] = replace_txt(attr_data[sm])
elif isinstance(attr_data, list): elif isinstance(attr_data, list):
discover_name = [] final_data = []
for li in attr_data: for li in attr_data:
if isinstance(li, dict): if isinstance(li, dict):
temp_dict = {} temp_dict = {}
for sm in li: for sm in li:
temp_dict[sm] = replace_txt(li[sm]) temp_dict[sm] = replace_txt(li[sm])
discover_name.append(temp_dict) final_data.append(temp_dict)
else: else:
discover_name.append(replace_txt(li)) final_data.append(replace_txt(li))
else: else:
discover_name = replace_txt(attr_data) final_data = replace_txt(attr_data)
except Failed: except Failed:
continue continue
self.data[method_name] = discover_name self.data[method_name] = final_data
methods[method_name.lower()] = method_name
else: else:
raise Failed(f"Collection Error: template attribute {method_name} is blank") raise Failed(f"Collection Error: template attribute {method_name} is blank")
@ -509,7 +511,7 @@ class CollectionBuilder:
self.methods.append((method_name, [searches])) self.methods.append((method_name, [searches]))
elif method_name == "tmdb_discover": elif method_name == "tmdb_discover":
new_dictionary = {"limit": 100} new_dictionary = {"limit": 100}
for discover_name, discover_data in method_data: for discover_name, discover_data in method_data.items():
discover_final = discover_name.lower() discover_final = discover_name.lower()
if discover_data: if discover_data:
if (self.library.is_movie and discover_final in util.discover_movie) or (self.library.is_show and discover_final in util.discover_tv): if (self.library.is_movie and discover_final in util.discover_movie) or (self.library.is_show and discover_final in util.discover_tv):
@ -806,7 +808,7 @@ class CollectionBuilder:
has_processed = False has_processed = False
search_limit = None search_limit = None
search_sort = None search_sort = None
for search_method, search_data in value: for search_method, search_data in value.items():
if search_method == "limit": if search_method == "limit":
search_limit = search_data search_limit = search_data
elif search_method == "sort_by": elif search_method == "sort_by":

@ -428,7 +428,6 @@ class Config:
try: try:
builder = CollectionBuilder(self, library, mapping_name, collection_attrs) builder = CollectionBuilder(self, library, mapping_name, collection_attrs)
except Failed as ef: except Failed as ef:
util.print_stacktrace()
util.print_multiline(ef, error=True) util.print_multiline(ef, error=True)
continue continue
except Exception as ee: except Exception as ee:

@ -99,10 +99,10 @@ class PlexAPI:
search_choices = self.get_search_choices(final_search, key=final_search.endswith("Language")) search_choices = self.get_search_choices(final_search, key=final_search.endswith("Language"))
valid_list = [] valid_list = []
for value in util.get_list(data): for value in util.get_list(data):
if str(value).lower in search_choices: if str(value).lower() in search_choices:
valid_list.append(search_choices[str(value).lower]) valid_list.append(search_choices[str(value).lower()])
else: else:
raise Failed(f"Plex Error: No {search_name}: {value} found") raise Failed(f"Plex Error: {search_name}: {value} not found")
return valid_list return valid_list
def get_all_collections(self): def get_all_collections(self):

Loading…
Cancel
Save