[1] fix multiple minor issues

pull/998/head
meisnate12 2 years ago
parent bf4b11c689
commit 9d5969abfb

@ -1 +1 @@
1.17.3 1.17.3-develop1

@ -257,7 +257,7 @@ class CollectionBuilder:
logger.warning(f"Collection Warning: {level_attr} attribute will run as builder_level") logger.warning(f"Collection Warning: {level_attr} attribute will run as builder_level")
break break
if level and not self.library.is_movie and not self.playlist: if level and not self.playlist and not self.library.is_movie:
logger.debug("") logger.debug("")
logger.debug("Validating Method: builder_level") logger.debug("Validating Method: builder_level")
if level is None: if level is None:
@ -1788,6 +1788,7 @@ class CollectionBuilder:
def build_url_arg(arg, mod=None, arg_s=None, mod_s=None): def build_url_arg(arg, mod=None, arg_s=None, mod_s=None):
arg_key = plex.search_translation[attr] if attr in plex.search_translation else attr arg_key = plex.search_translation[attr] if attr in plex.search_translation else attr
arg_key = f"{sort_type}.label" if arg_key == "label" and sort_type in ["season", "episode", "album", "track"] else arg_key
arg_key = plex.show_translation[arg_key] if self.library.is_show and arg_key in plex.show_translation else arg_key arg_key = plex.show_translation[arg_key] if self.library.is_show and arg_key in plex.show_translation else arg_key
if mod is None: if mod is None:
mod = plex.modifier_translation[modifier] if modifier in plex.modifier_translation else modifier mod = plex.modifier_translation[modifier] if modifier in plex.modifier_translation else modifier

@ -104,7 +104,10 @@ class Mdblist:
if self.config.trace_mode: if self.config.trace_mode:
logger.debug(f"ID: {key}") logger.debug(f"ID: {key}")
logger.debug(f"Params: {params}") logger.debug(f"Params: {params}")
response = self.config.get_json(api_url, params=params) try:
response = self.config.get_json(api_url, params=params)
except JSONDecodeError:
raise Failed("Mdblist Error: JSON Decoding Failed")
if "response" in response and response["response"] is False: if "response" in response and response["response"] is False:
if response["error"] == "API Limit Reached!": if response["error"] == "API Limit Reached!":
self.limit = True self.limit = True

@ -165,43 +165,33 @@ class DataFile:
for key, value in variables.copy().items(): for key, value in variables.copy().items():
variables[f"{key}_encoded"] = requests.utils.quote(str(value)) variables[f"{key}_encoded"] = requests.utils.quote(str(value))
default = {} def replace_var(input_item, search_dict):
def add_default(d_key, d_value): return_item = input_item
for v_key, v_value in variables.items(): for rk, rv in search_dict.items():
if f"<<{v_key}>>" in str(d_value): if f"<<{rk}>>" in return_item:
d_value = str(d_value).replace(f"<<{v_key}>>", str(v_value)) return_item = return_item.replace(f"<<{rk}>>", str(rv))
default[d_key] = d_value return return_item
default[f"{d_key}_encoded"] = requests.utils.quote(str(d_value))
def small_var_check(var_check):
for var_k, var_v in variables.items():
if f"<<{var_k}>>" in str(var_check):
var_check = str(var_check).replace(f"<<{var_k}>>", str(var_v))
for var_k, var_v in default.items():
if f"<<{var_k}>>" in str(var_check):
var_check = str(var_check).replace(f"<<{var_k}>>", str(var_v))
return var_check
ini_default = {}
default = {}
if "default" in template: if "default" in template:
if not template["default"]: if not template["default"]:
raise Failed(f"{self.data_type} Error: template sub-attribute default is blank") raise Failed(f"{self.data_type} Error: template sub-attribute default is blank")
if not isinstance(template["default"], dict): if not isinstance(template["default"], dict):
raise Failed(f"{self.data_type} Error: template sub-attribute default is not a dictionary") raise Failed(f"{self.data_type} Error: template sub-attribute default is not a dictionary")
for dv in template["default"]: for dv in template["default"]:
final_key = dv ini_default[replace_var(dv, variables)] = replace_var(template["default"][dv], variables)
for k, v in variables.items(): for dkey, dvalue in ini_default.items():
if f"<<{k}>>" in final_key: final_key = replace_var(dkey, ini_default)
final_key = final_key.replace(f"<<{k}>>", str(v)) final_value = replace_var(dvalue, ini_default)
if final_key not in optional: if final_key not in optional:
final_value = template["default"][dv] default[final_key] = final_value
add_default(final_key, final_value) default[f"{final_key}_encoded"] = requests.utils.quote(str(final_value))
if "optional" in template: if "optional" in template:
if template["optional"]: if template["optional"]:
for op in util.get_list(template["optional"]): for op in util.get_list(template["optional"]):
for k, v in variables.items(): op = replace_var(op, variables)
if f"<<{k}>>" in op:
op = op.replace(f"<<{k}>>", str(v))
if op not in default: if op not in default:
optional.append(str(op)) optional.append(str(op))
optional.append(f"{op}_encoded") optional.append(f"{op}_encoded")
@ -221,7 +211,7 @@ class DataFile:
logger.debug(f"Conditional: {con_key}") logger.debug(f"Conditional: {con_key}")
if not isinstance(con_value, dict): if not isinstance(con_value, dict):
raise Failed(f"{self.data_type} Error: template sub-attribute conditionals is not a dictionary") raise Failed(f"{self.data_type} Error: template sub-attribute conditionals is not a dictionary")
final_key = small_var_check(con_key) final_key = replace_var(replace_var(con_key, variables), default)
if final_key != con_key: if final_key != con_key:
logger.debug(f"Variable: {final_key}") logger.debug(f"Variable: {final_key}")
if final_key in variables: if final_key in variables:
@ -243,11 +233,11 @@ class DataFile:
for var_key, var_value in condition.items(): for var_key, var_value in condition.items():
if var_key == "value": if var_key == "value":
continue continue
var_key = small_var_check(var_key) var_key = replace_var(replace_var(var_key, variables), default)
var_value = small_var_check(var_value) var_value = replace_var(replace_var(var_value, variables), default)
if var_key in variables: if var_key in variables:
if (isinstance(var_value, list) and variables[var_key] not in var_value) or \ if (isinstance(var_value, list) and variables[var_key] not in var_value) or \
(not isinstance(var_value, list) and variables[var_key] != var_value): (not isinstance(var_value, list) and variables[var_key] != var_value):
if isinstance(var_value, list): if isinstance(var_value, list):
logger.debug(f'Condition {i} Failed: {var_key} "{variables[var_key]}" not in {var_value}') logger.debug(f'Condition {i} Failed: {var_key} "{variables[var_key]}" not in {var_value}')
else: else:
@ -256,7 +246,7 @@ class DataFile:
break break
elif var_key in default: elif var_key in default:
if (isinstance(var_value, list) and default[var_key] not in var_value) or \ if (isinstance(var_value, list) and default[var_key] not in var_value) or \
(not isinstance(var_value, list) and default[var_key] != var_value): (not isinstance(var_value, list) and default[var_key] != var_value):
if isinstance(var_value, list): if isinstance(var_value, list):
logger.debug(f'Condition {i} Failed: {var_key} "{default[var_key]}" not in {var_value}') logger.debug(f'Condition {i} Failed: {var_key} "{default[var_key]}" not in {var_value}')
else: else:

@ -151,6 +151,10 @@ class Trakt:
response = self.config.get(f"{base_url}/users/settings", headers=headers) response = self.config.get(f"{base_url}/users/settings", headers=headers)
if response.status_code == 423: if response.status_code == 423:
raise Failed("Trakt Error: Account is Locked please Contact Trakt Support") raise Failed("Trakt Error: Account is Locked please Contact Trakt Support")
if self.config.trace_mode:
logger.debug(f"Trakt Error Code: {response.status_code}")
logger.debug(f"Trakt Error Reason: {response.reason}")
logger.debug(f"Trakt Error JSON: {response.json()}")
return response.status_code == 200 return response.status_code == 200
def _refresh(self): def _refresh(self):

@ -324,11 +324,11 @@ def item_title(item):
else: else:
return f"{item.parentTitle} Season {item.index}: {item.title}" return f"{item.parentTitle} Season {item.index}: {item.title}"
elif isinstance(item, Episode): elif isinstance(item, Episode):
text = f"{item.grandparentTitle} S{item.parentIndex:02}E{item.index:02}" season = item.parentIndex if item.parentIndex else 0
if f"Season {item.parentIndex}" == item.parentTitle: episode = item.index if item.index else 0
return f"{text}: {item.title}" show_title = item.grandparentTitle if item.grandparentTitle else ""
else: season_title = f"{item.parentTitle}: " if item.parentTitle and f"Season {season}" == item.parentTitle else ""
return f"{text}: {item.parentTitle}: {item.title}" return f"{show_title} S{season:02}E{episode:02}: {season_title}{item.title if item.title else ''}"
elif isinstance(item, Movie) and item.year: elif isinstance(item, Movie) and item.year:
return f"{item.title} ({item.year})" return f"{item.title} ({item.year})"
elif isinstance(item, Album): elif isinstance(item, Album):

Loading…
Cancel
Save