Seperate check_skip_logic, append reasons
This commit is contained in:
@@ -11,49 +11,82 @@ def check_skip_logic(
|
|||||||
whitelist_library,
|
whitelist_library,
|
||||||
blacklist_library_type,
|
blacklist_library_type,
|
||||||
whitelist_library_type,
|
whitelist_library_type,
|
||||||
library_mapping,
|
library_mapping=None,
|
||||||
):
|
):
|
||||||
skip_reason = None
|
skip_reason = None
|
||||||
|
|
||||||
if isinstance(library_type, (list, tuple, set)):
|
|
||||||
for library_type_item in library_type:
|
|
||||||
if library_type_item.lower() in blacklist_library_type:
|
|
||||||
skip_reason = "is blacklist_library_type"
|
|
||||||
else:
|
|
||||||
if library_type.lower() in blacklist_library_type:
|
|
||||||
skip_reason = "is blacklist_library_type"
|
|
||||||
|
|
||||||
if library_title.lower() in [x.lower() for x in blacklist_library]:
|
|
||||||
skip_reason = "is blacklist_library"
|
|
||||||
|
|
||||||
library_other = None
|
library_other = None
|
||||||
if library_mapping:
|
if library_mapping:
|
||||||
library_other = search_mapping(library_mapping, library_title)
|
library_other = search_mapping(library_mapping, library_title)
|
||||||
|
|
||||||
|
skip_reason_black = check_blacklist_logic(library_title, library_type, blacklist_library, blacklist_library_type, library_mapping, library_other)
|
||||||
|
skip_reason_white = check_whitelist_logic(library_title, library_type, whitelist_library, whitelist_library_type, library_mapping, library_other)
|
||||||
|
|
||||||
|
# Combine skip reasons
|
||||||
|
if skip_reason_black:
|
||||||
|
skip_reason = skip_reason_black
|
||||||
|
|
||||||
|
if skip_reason_white:
|
||||||
|
if skip_reason:
|
||||||
|
skip_reason = skip_reason + " and " + skip_reason_white
|
||||||
|
else:
|
||||||
|
skip_reason = skip_reason_white
|
||||||
|
|
||||||
|
return skip_reason
|
||||||
|
|
||||||
|
def check_blacklist_logic(library_title, library_type, blacklist_library, blacklist_library_type, library_mapping=None, library_other=None):
|
||||||
|
skip_reason = None
|
||||||
|
if isinstance(library_type, (list, tuple, set)):
|
||||||
|
for library_type_item in library_type:
|
||||||
|
if library_type_item.lower() in blacklist_library_type:
|
||||||
|
skip_reason = "is in blacklist_library_type"
|
||||||
|
else:
|
||||||
|
if library_type.lower() in blacklist_library_type:
|
||||||
|
skip_reason = "is in blacklist_library_type"
|
||||||
|
|
||||||
|
if library_title.lower() in [x.lower() for x in blacklist_library]:
|
||||||
|
if skip_reason:
|
||||||
|
skip_reason = skip_reason + " and " + "is in blacklist_library"
|
||||||
|
else:
|
||||||
|
skip_reason = "is in blacklist_library"
|
||||||
|
|
||||||
|
|
||||||
if library_other:
|
if library_other:
|
||||||
if library_other.lower() in [x.lower() for x in blacklist_library]:
|
if library_other.lower() in [x.lower() for x in blacklist_library]:
|
||||||
skip_reason = "is blacklist_library"
|
if skip_reason:
|
||||||
|
skip_reason = skip_reason + " and " + "is in blacklist_library"
|
||||||
|
else:
|
||||||
|
skip_reason = "is in blacklist_library"
|
||||||
|
|
||||||
|
return skip_reason
|
||||||
|
|
||||||
|
def check_whitelist_logic(library_title, library_type, whitelist_library, whitelist_library_type, library_mapping=None, library_other=None):
|
||||||
|
skip_reason = None
|
||||||
if len(whitelist_library_type) > 0:
|
if len(whitelist_library_type) > 0:
|
||||||
if isinstance(library_type, (list, tuple, set)):
|
if isinstance(library_type, (list, tuple, set)):
|
||||||
for library_type_item in library_type:
|
for library_type_item in library_type:
|
||||||
if library_type_item.lower() not in whitelist_library_type:
|
if library_type_item.lower() not in whitelist_library_type:
|
||||||
skip_reason = "is not whitelist_library_type"
|
skip_reason = "is not in whitelist_library_type"
|
||||||
else:
|
else:
|
||||||
if library_type.lower() not in whitelist_library_type:
|
if library_type.lower() not in whitelist_library_type:
|
||||||
skip_reason = "is not whitelist_library_type"
|
skip_reason = "is not in whitelist_library_type"
|
||||||
|
|
||||||
# if whitelist is not empty and library is not in whitelist
|
# if whitelist is not empty and library is not in whitelist
|
||||||
if len(whitelist_library) > 0:
|
if len(whitelist_library) > 0:
|
||||||
if library_title.lower() not in [x.lower() for x in whitelist_library]:
|
if library_title.lower() not in [x.lower() for x in whitelist_library]:
|
||||||
skip_reason = "is not whitelist_library"
|
if skip_reason:
|
||||||
|
skip_reason = skip_reason + " and " + "is not in whitelist_library"
|
||||||
|
else:
|
||||||
|
skip_reason = "is not in whitelist_library"
|
||||||
|
|
||||||
if library_other:
|
if library_other:
|
||||||
if library_other.lower() not in [x.lower() for x in whitelist_library]:
|
if library_other.lower() not in [x.lower() for x in whitelist_library]:
|
||||||
skip_reason = "is not whitelist_library"
|
if skip_reason:
|
||||||
|
skip_reason = skip_reason + " and " + "is not in whitelist_library"
|
||||||
|
else:
|
||||||
|
skip_reason = "is not in whitelist_library"
|
||||||
|
|
||||||
return skip_reason
|
return skip_reason
|
||||||
|
|
||||||
|
|
||||||
def generate_library_guids_dict(user_list: dict):
|
def generate_library_guids_dict(user_list: dict):
|
||||||
show_output_dict = {}
|
show_output_dict = {}
|
||||||
episode_output_dict = {}
|
episode_output_dict = {}
|
||||||
|
|||||||
@@ -138,10 +138,10 @@ def cleanup_watched(
|
|||||||
return modified_watched_list_1
|
return modified_watched_list_1
|
||||||
|
|
||||||
|
|
||||||
def get_other(watched_list_2, object_1, object_2):
|
def get_other(watched_list, object_1, object_2):
|
||||||
if object_1 in watched_list_2:
|
if object_1 in watched_list:
|
||||||
return object_1
|
return object_1
|
||||||
elif object_2 in watched_list_2:
|
elif object_2 in watched_list:
|
||||||
return object_2
|
return object_2
|
||||||
else:
|
else:
|
||||||
logger(f"{object_1} and {object_2} not found in watched list 2", 1)
|
logger(f"{object_1} and {object_2} not found in watched list 2", 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user