#336 added released_missing_only to settings

pull/351/head
meisnate12 3 years ago
parent 74db60bf17
commit ed8d7696d7

@ -148,6 +148,7 @@ class CollectionBuilder:
"show_filtered": self.library.show_filtered,
"show_missing": self.library.show_missing,
"save_missing": self.library.save_missing,
"released_missing_only": self.library.released_missing_only,
"item_assets": False
}
self.item_details = {}
@ -155,6 +156,8 @@ class CollectionBuilder:
self.sonarr_options = {}
self.missing_movies = []
self.missing_shows = []
self.filtered_missing_movies = []
self.filtered_missing_shows = []
self.builders = []
self.filters = []
self.rating_keys = []
@ -1013,14 +1016,36 @@ class CollectionBuilder:
for movie_id in movie_ids:
if movie_id in self.library.movie_map:
add_rating_keys(self.library.movie_map[movie_id])
elif movie_id not in self.missing_movies:
elif movie_id not in self.missing_movies and movie_id not in self.filtered_missing_movies:
filter_missing = False
if self.details["released_missing_only"]:
try:
movie = self.config.TMDb.get_movie(movie_id)
if util.validate_date(movie.release_date, "") > self.current_time:
filter_missing = True
except Failed:
pass
if filter_missing:
self.filtered_missing_movies.append(movie_id)
else:
self.missing_movies.append(movie_id)
if len(show_ids) > 0:
items_found_inside += len(show_ids)
for show_id in show_ids:
if show_id in self.library.show_map:
add_rating_keys(self.library.show_map[show_id])
elif show_id not in self.missing_shows:
elif show_id not in self.missing_shows and show_id not in self.filtered_missing_shows:
filter_missing = False
if self.details["released_missing_only"]:
try:
show = self.config.TMDb.get_show(show_id)
if util.validate_date(show.first_air_date, "") > self.current_time:
filter_missing = True
except Failed:
pass
if filter_missing:
self.filtered_missing_shows.append(show_id)
else:
self.missing_shows.append(show_id)
return items_found_inside
for method, value in self.builders:
@ -1329,14 +1354,13 @@ class CollectionBuilder:
def check_filters(self, current, display):
if self.filters:
util.print_return(f"Filtering {display} {current.title}")
current_date = datetime.now()
for filter_method, filter_data in self.filters:
filter_attr, modifier, filter_final = self._split(filter_method)
filter_actual = filter_translation[filter_attr] if filter_attr in filter_translation else filter_attr
if filter_attr in ["release", "added", "last_played"] and modifier != ".regex":
current_data = getattr(current, filter_actual)
if modifier in ["", ".not"]:
threshold_date = current_date - timedelta(days=filter_data)
threshold_date = self.current_time - timedelta(days=filter_data)
if (modifier == "" and (current_data is None or current_data < threshold_date)) \
or (modifier == ".not" and current_data and current_data >= threshold_date):
return False
@ -1405,15 +1429,15 @@ class CollectionBuilder:
if item_date is None:
return False
elif filter_data == "day":
if item_date.month != current_date.month or item_date.day != current_date.day:
if item_date.month != self.current_time.month or item_date.day != self.current_time.day:
return False
elif filter_data == "month":
if item_date.month != current_date.month:
if item_date.month != self.current_time.month:
return False
else:
date_match = False
for i in range(filter_data):
check_date = current_date - timedelta(days=i)
check_date = self.current_time - timedelta(days=i)
if item_date.month == check_date.month and item_date.day == check_date.day:
date_match = True
if date_match is False:

@ -182,7 +182,8 @@ class Config:
"show_unmanaged": check_for_attribute(self.data, "show_unmanaged", parent="settings", var_type="bool", default=True),
"show_filtered": check_for_attribute(self.data, "show_filtered", parent="settings", var_type="bool", default=False),
"show_missing": check_for_attribute(self.data, "show_missing", parent="settings", var_type="bool", default=True),
"save_missing": check_for_attribute(self.data, "save_missing", parent="settings", var_type="bool", default=True)
"save_missing": check_for_attribute(self.data, "save_missing", parent="settings", var_type="bool", default=True),
"released_missing_only": check_for_attribute(self.data, "released_missing_only", parent="settings", var_type="bool", default=False)
}
if self.general["cache"]:
util.separator()
@ -326,14 +327,11 @@ class Config:
if self.requested_libraries and library_name not in self.requested_libraries:
continue
util.separator()
params = {}
params["mapping_name"] = str(library_name)
if lib and "library_name" in lib and lib["library_name"]:
params["name"] = str(lib["library_name"])
display_name = f"{params['name']} ({params['mapping_name']})"
else:
params["name"] = params["mapping_name"]
display_name = params["mapping_name"]
params = {
"mapping_name": str(library_name),
"name": str(lib["library_name"]) if lib and "library_name" in lib and lib["library_name"] else str(library_name)
}
display_name = f"{params['name']} ({params['mapping_name']})" if lib and "library_name" in lib and lib["library_name"] else params["mapping_name"]
util.separator(f"{display_name} Configuration")
logger.info("")
@ -343,40 +341,14 @@ class Config:
if params["asset_directory"] is None:
logger.warning("Config Warning: Assets will not be used asset_directory attribute must be set under config or under this specific Library")
if lib and "settings" in lib and lib["settings"] and "asset_folders" in lib["settings"]:
params["asset_folders"] = check_for_attribute(lib, "asset_folders", parent="settings", var_type="bool", default=self.general["asset_folders"], do_print=False, save=False)
else:
params["asset_folders"] = check_for_attribute(lib, "asset_folders", var_type="bool", default=self.general["asset_folders"], do_print=False, save=False)
if lib and "settings" in lib and lib["settings"] and "assets_for_all" in lib["settings"]:
params["assets_for_all"] = check_for_attribute(lib, "assets_for_all", parent="settings", var_type="bool", default=self.general["assets_for_all"], do_print=False, save=False)
else:
params["assets_for_all"] = check_for_attribute(lib, "assets_for_all", var_type="bool", default=self.general["assets_for_all"], do_print=False, save=False)
if lib and "settings" in lib and lib["settings"] and "sync_mode" in lib["settings"]:
params["sync_mode"] = check_for_attribute(lib, "sync_mode", parent="settings", test_list=sync_modes, default=self.general["sync_mode"], do_print=False, save=False)
else:
params["sync_mode"] = check_for_attribute(lib, "sync_mode", test_list=sync_modes, default=self.general["sync_mode"], do_print=False, save=False)
if lib and "settings" in lib and lib["settings"] and "show_unmanaged" in lib["settings"]:
params["show_unmanaged"] = check_for_attribute(lib, "show_unmanaged", parent="settings", var_type="bool", default=self.general["show_unmanaged"], do_print=False, save=False)
else:
params["show_unmanaged"] = check_for_attribute(lib, "show_unmanaged", var_type="bool", default=self.general["show_unmanaged"], do_print=False, save=False)
if lib and "settings" in lib and lib["settings"] and "show_filtered" in lib["settings"]:
params["show_filtered"] = check_for_attribute(lib, "show_filtered", parent="settings", var_type="bool", default=self.general["show_filtered"], do_print=False, save=False)
else:
params["show_filtered"] = check_for_attribute(lib, "show_filtered", var_type="bool", default=self.general["show_filtered"], do_print=False, save=False)
if lib and "settings" in lib and lib["settings"] and "show_missing" in lib["settings"]:
params["show_missing"] = check_for_attribute(lib, "show_missing", parent="settings", var_type="bool", default=self.general["show_missing"], do_print=False, save=False)
else:
params["show_missing"] = check_for_attribute(lib, "show_missing", var_type="bool", default=self.general["show_missing"], do_print=False, save=False)
if lib and "settings" in lib and lib["settings"] and "save_missing" in lib["settings"]:
params["save_missing"] = check_for_attribute(lib, "save_missing", parent="settings", var_type="bool", default=self.general["save_missing"], do_print=False, save=False)
else:
params["save_missing"] = check_for_attribute(lib, "save_missing", var_type="bool", default=self.general["save_missing"], do_print=False, save=False)
params["released_missing_only"] = check_for_attribute(lib, "released_missing_only", parent="settings", var_type="bool", default=self.general["released_missing_only"], do_print=False, save=False)
if lib and "mass_genre_update" in lib and lib["mass_genre_update"]:
params["mass_genre_update"] = check_for_attribute(lib, "mass_genre_update", test_list=mass_update_options, default_is_none=True, save=False)

@ -279,6 +279,7 @@ class Plex:
self.show_filtered = params["show_filtered"]
self.show_missing = params["show_missing"]
self.save_missing = params["save_missing"]
self.released_missing_only = params["released_missing_only"]
self.mass_genre_update = params["mass_genre_update"]
self.mass_audience_rating_update = params["mass_audience_rating_update"]
self.mass_critic_rating_update = params["mass_critic_rating_update"]

@ -105,7 +105,7 @@ def start(config_path, is_test=False, time_scheduled=None, requested_collections
logger.info(util.centered("| __/| | __/> < | | | | __/ || (_| | | | | | (_| | | | | (_| | (_| | __/ | "))
logger.info(util.centered("|_| |_|\\___/_/\\_\\ |_| |_|\\___|\\__\\__,_| |_| |_|\\__,_|_| |_|\\__,_|\\__, |\\___|_| "))
logger.info(util.centered(" |___/ "))
logger.info(util.centered(" Version: 1.11.3-beta2 "))
logger.info(util.centered(" Version: 1.11.3-beta3 "))
if time_scheduled: start_type = f"{time_scheduled} "
elif is_test: start_type = "Test "
elif requested_collections: start_type = "Collections "

Loading…
Cancel
Save