mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-22 12:33:10 +00:00
[1] fix multiple minor issues
This commit is contained in:
parent
bf4b11c689
commit
9d5969abfb
6 changed files with 37 additions and 39 deletions
2
VERSION
2
VERSION
|
@ -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")
|
||||
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("Validating Method: builder_level")
|
||||
if level is None:
|
||||
|
@ -1788,6 +1788,7 @@ class CollectionBuilder:
|
|||
|
||||
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 = 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
|
||||
if mod is None:
|
||||
mod = plex.modifier_translation[modifier] if modifier in plex.modifier_translation else modifier
|
||||
|
|
|
@ -104,7 +104,10 @@ class Mdblist:
|
|||
if self.config.trace_mode:
|
||||
logger.debug(f"ID: {key}")
|
||||
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["error"] == "API Limit Reached!":
|
||||
self.limit = True
|
||||
|
|
|
@ -165,43 +165,33 @@ class DataFile:
|
|||
for key, value in variables.copy().items():
|
||||
variables[f"{key}_encoded"] = requests.utils.quote(str(value))
|
||||
|
||||
def replace_var(input_item, search_dict):
|
||||
return_item = input_item
|
||||
for rk, rv in search_dict.items():
|
||||
if f"<<{rk}>>" in return_item:
|
||||
return_item = return_item.replace(f"<<{rk}>>", str(rv))
|
||||
return return_item
|
||||
|
||||
ini_default = {}
|
||||
default = {}
|
||||
def add_default(d_key, d_value):
|
||||
for v_key, v_value in variables.items():
|
||||
if f"<<{v_key}>>" in str(d_value):
|
||||
d_value = str(d_value).replace(f"<<{v_key}>>", str(v_value))
|
||||
default[d_key] = d_value
|
||||
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
|
||||
|
||||
if "default" in template:
|
||||
if not template["default"]:
|
||||
raise Failed(f"{self.data_type} Error: template sub-attribute default is blank")
|
||||
if not isinstance(template["default"], dict):
|
||||
raise Failed(f"{self.data_type} Error: template sub-attribute default is not a dictionary")
|
||||
for dv in template["default"]:
|
||||
final_key = dv
|
||||
for k, v in variables.items():
|
||||
if f"<<{k}>>" in final_key:
|
||||
final_key = final_key.replace(f"<<{k}>>", str(v))
|
||||
if final_key not in optional:
|
||||
final_value = template["default"][dv]
|
||||
add_default(final_key, final_value)
|
||||
ini_default[replace_var(dv, variables)] = replace_var(template["default"][dv], variables)
|
||||
for dkey, dvalue in ini_default.items():
|
||||
final_key = replace_var(dkey, ini_default)
|
||||
final_value = replace_var(dvalue, ini_default)
|
||||
if final_key not in optional:
|
||||
default[final_key] = final_value
|
||||
default[f"{final_key}_encoded"] = requests.utils.quote(str(final_value))
|
||||
|
||||
if "optional" in template:
|
||||
if template["optional"]:
|
||||
for op in util.get_list(template["optional"]):
|
||||
for k, v in variables.items():
|
||||
if f"<<{k}>>" in op:
|
||||
op = op.replace(f"<<{k}>>", str(v))
|
||||
op = replace_var(op, variables)
|
||||
if op not in default:
|
||||
optional.append(str(op))
|
||||
optional.append(f"{op}_encoded")
|
||||
|
@ -221,7 +211,7 @@ class DataFile:
|
|||
logger.debug(f"Conditional: {con_key}")
|
||||
if not isinstance(con_value, dict):
|
||||
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:
|
||||
logger.debug(f"Variable: {final_key}")
|
||||
if final_key in variables:
|
||||
|
@ -243,11 +233,11 @@ class DataFile:
|
|||
for var_key, var_value in condition.items():
|
||||
if var_key == "value":
|
||||
continue
|
||||
var_key = small_var_check(var_key)
|
||||
var_value = small_var_check(var_value)
|
||||
var_key = replace_var(replace_var(var_key, variables), default)
|
||||
var_value = replace_var(replace_var(var_value, variables), default)
|
||||
if var_key in variables:
|
||||
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):
|
||||
logger.debug(f'Condition {i} Failed: {var_key} "{variables[var_key]}" not in {var_value}')
|
||||
else:
|
||||
|
@ -256,7 +246,7 @@ class DataFile:
|
|||
break
|
||||
elif var_key in default:
|
||||
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):
|
||||
logger.debug(f'Condition {i} Failed: {var_key} "{default[var_key]}" not in {var_value}')
|
||||
else:
|
||||
|
|
|
@ -151,6 +151,10 @@ class Trakt:
|
|||
response = self.config.get(f"{base_url}/users/settings", headers=headers)
|
||||
if response.status_code == 423:
|
||||
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
|
||||
|
||||
def _refresh(self):
|
||||
|
|
|
@ -324,11 +324,11 @@ def item_title(item):
|
|||
else:
|
||||
return f"{item.parentTitle} Season {item.index}: {item.title}"
|
||||
elif isinstance(item, Episode):
|
||||
text = f"{item.grandparentTitle} S{item.parentIndex:02}E{item.index:02}"
|
||||
if f"Season {item.parentIndex}" == item.parentTitle:
|
||||
return f"{text}: {item.title}"
|
||||
else:
|
||||
return f"{text}: {item.parentTitle}: {item.title}"
|
||||
season = item.parentIndex if item.parentIndex else 0
|
||||
episode = item.index if item.index else 0
|
||||
show_title = item.grandparentTitle if item.grandparentTitle else ""
|
||||
season_title = f"{item.parentTitle}: " if item.parentTitle and f"Season {season}" == item.parentTitle else ""
|
||||
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:
|
||||
return f"{item.title} ({item.year})"
|
||||
elif isinstance(item, Album):
|
||||
|
|
Loading…
Reference in a new issue