[9] Don't do the less check on smart collections (#2275)

pull/2299/head
Chaz Larson 1 month ago committed by GitHub Action
parent a94e9be1ea
commit 357def17fc

@ -14,4 +14,5 @@ Fixes an issue where Prime Video overlays/collections would not be built when th
Fixed the `cast` search option for the `imdb_search` builder Fixed the `cast` search option for the `imdb_search` builder
Fixes #2258 `imdb_list` sort was not being parsed correctly Fixes #2258 `imdb_list` sort was not being parsed correctly
Fixes `letterboxd_list` rating filter to use a 1-10 rating vs 1-100 to reflect how letterboxd ratings work on their website Fixes `letterboxd_list` rating filter to use a 1-10 rating vs 1-100 to reflect how letterboxd ratings work on their website
Fixes #2274 Enhance handling of smart collections in deletion
Fixed the `ids_to_anidb` lookup for anime movies and shows Fixed the `ids_to_anidb` lookup for anime movies and shows

@ -1 +1 @@
2.1.0-build8 2.1.0-build9

@ -83,6 +83,8 @@ You can create individual blocks of operations by using a list under `operations
<tr><td>`configured: true`</td><td>Collection must be Configured to be deleted<br>(collection is in the config file of the specific Kometa run)</td></tr> <tr><td>`configured: true`</td><td>Collection must be Configured to be deleted<br>(collection is in the config file of the specific Kometa run)</td></tr>
<tr><td>`configured: false`</td><td>Collection must be Unconfigured to be deleted<br>(collection is not in the config file of the specific Kometa run)</td></tr> <tr><td>`configured: false`</td><td>Collection must be Unconfigured to be deleted<br>(collection is not in the config file of the specific Kometa run)</td></tr>
<tr><td>`less: ###`</td><td>Collection must contain less than the given number of items to be deleted.<br>### is a Number greater than 0<br>Optional value which if undefined means collections will be deleted regardless of how many items they have</td></tr> <tr><td>`less: ###`</td><td>Collection must contain less than the given number of items to be deleted.<br>### is a Number greater than 0<br>Optional value which if undefined means collections will be deleted regardless of how many items they have</td></tr>
<tr><td>`ignore_empty_smart_collections: false`</td><td>Do not apply less check to empty smart collections<br>This allows retaining things like smart collections that show movies without subtitles or the like.</td></tr>
</table> </table>
**The collection does not need to be scheduled to be considered configured and only needs to be in the config file.** **The collection does not need to be scheduled to be considered configured and only needs to be in the config file.**

@ -2080,7 +2080,8 @@
"properties": { "properties": {
"configured": { "type": "boolean" }, "configured": { "type": "boolean" },
"managed": { "type": "boolean" }, "managed": { "type": "boolean" },
"less": { "type": "integer" } "less": { "type": "integer" },
"ignore_empty_smart_collections": { "type": "boolean" }
}, },
"required": [] "required": []
}, },

@ -344,7 +344,8 @@ libraries:
delete_collections: delete_collections:
configured: false # False - Collection must be an Unconfigured Collection to be deleted (collection is not in the config file of the specific Kometa run). configured: false # False - Collection must be an Unconfigured Collection to be deleted (collection is not in the config file of the specific Kometa run).
managed: false # False - Collection must be an Unmanaged Collection to be deleted (the collection does not have the Kometa label) managed: false # False - Collection must be an Unmanaged Collection to be deleted (the collection does not have the Kometa label)
less: 99999 # Effectively all collections regardless of teh number of items in the collection less: 99999 # Effectively all collections regardless of the number of items in the collection
ignore_empty_smart_collections: true # Don't do the less check on empty smart collections
mass_user_rating_update: mdb_tomatoes # Update user ratings with mdb_tomatoes mass_user_rating_update: mdb_tomatoes # Update user ratings with mdb_tomatoes
mass_critic_rating_update: imdb # Update critic ratings with imdb mass_critic_rating_update: imdb # Update critic ratings with imdb
mass_audience_rating_update: tmdb # Update audience ratings with tmdb mass_audience_rating_update: tmdb # Update audience ratings with tmdb
@ -758,7 +759,8 @@ libraries:
delete_collections: delete_collections:
configured: false # False - Collection must be an Unconfigured Collection to be deleted (collection is not in the config file of the specific Kometa run). configured: false # False - Collection must be an Unconfigured Collection to be deleted (collection is not in the config file of the specific Kometa run).
managed: false # False - Collection must be an Unmanaged Collection to be deleted (the collection does not have the Kometa label) managed: false # False - Collection must be an Unmanaged Collection to be deleted (the collection does not have the Kometa label)
less: 99999 # Effectively all collections regardless of teh number of items in the collection less: 99999 # Effectively all collections regardless of the number of items in the collection
ignore_empty_smart_collections: true # Don't do the less check on empty smart collections
mass_user_rating_update: mdb_tomatoes # Update user ratings with mdb_tomatoes mass_user_rating_update: mdb_tomatoes # Update user ratings with mdb_tomatoes
mass_critic_rating_update: imdb # Update critic ratings with imdb mass_critic_rating_update: imdb # Update critic ratings with imdb
mass_audience_rating_update: tmdb # Update audience ratings with tmdb mass_audience_rating_update: tmdb # Update audience ratings with tmdb
@ -859,8 +861,8 @@ webhooks: # Can be individually specif
version: (redacted) version: (redacted)
delete: (redacted) delete: (redacted)
plex: # Can be individually specified per library as well; REQUIRED for the script to run plex: # Can be individually specified per library as well; REQUIRED for the script to run
url: (redacted) url: http://10.10.10.10:1234
token: (redacted) token: THIS_IS_A_FAKE_TOKEN
timeout: 60 timeout: 60
clean_bundles: true clean_bundles: true
empty_trash: true empty_trash: true
@ -873,19 +875,19 @@ tmdb: # REQUIRED for the script to
region: CA # Upper case ISO 3166-1 Code region: CA # Upper case ISO 3166-1 Code
cache_expiration: 60 cache_expiration: 60
tautulli: # Can be individually specified per library as well tautulli: # Can be individually specified per library as well
url: (redacted) url: http://10.10.10.10:1234
apikey: (redacted) apikey: THIS_IS_A_FAKE_TOKEN
omdb: omdb:
apikey: (redacted) apikey: THIS_IS_A_FAKE_TOKEN
cache_expiration: 60 cache_expiration: 60
mdblist: mdblist:
apikey: (redacted) apikey: THIS_IS_A_FAKE_TOKEN
cache_expiration: 60 cache_expiration: 60
notifiarr: notifiarr:
apikey: (redacted) apikey: THIS_IS_A_FAKE_TOKEN
radarr: # Can be individually specified per library as well radarr: # Can be individually specified per library as well
url: (redacted) url: http://10.10.10.10:1234
token: (redacted) token: THIS_IS_A_FAKE_TOKEN
root_folder_path: /data/media/movies root_folder_path: /data/media/movies
monitor: true monitor: true
availability: announced availability: announced
@ -900,8 +902,8 @@ radarr: # Can be individually specified
ignore_cache: false ignore_cache: false
monitor_existing: false monitor_existing: false
sonarr: # Can be individually specified per library as well sonarr: # Can be individually specified per library as well
url: (redacted) url: http://10.10.10.10:1234
token: (redacted) token: THIS_IS_A_FAKE_TOKEN
root_folder_path: /data/media/tv root_folder_path: /data/media/tv
monitor: all monitor: all
quality_profile: Any quality_profile: Any
@ -920,7 +922,7 @@ sonarr: # Can be individually specified
monitor_existing: false monitor_existing: false
anidb: anidb:
client: (redacted) client: (redacted)
version: (redacted) version: 1234
language: en language: en
cache_expiration: 60 cache_expiration: 60
username: (redacted) username: (redacted)

@ -388,6 +388,7 @@ libraries:
managed: false managed: false
configured: true configured: true
less: 123 less: 123
ignore_empty_smart_collections: true
Anime: Anime:
collection_files: collection_files:

@ -964,6 +964,7 @@ class ConfigFile:
"managed": check_for_attribute(input_dict, "managed", var_type="bool", default_is_none=True, save=False), "managed": check_for_attribute(input_dict, "managed", var_type="bool", default_is_none=True, save=False),
"configured": check_for_attribute(input_dict, "configured", var_type="bool", default_is_none=True, save=False), "configured": check_for_attribute(input_dict, "configured", var_type="bool", default_is_none=True, save=False),
"less": check_for_attribute(input_dict, "less", var_type="int", default_is_none=True, save=False, int_min=1), "less": check_for_attribute(input_dict, "less", var_type="int", default_is_none=True, save=False, int_min=1),
"ignore_empty_smart_collections": check_for_attribute(input_dict, "ignore_empty_smart_collections", var_type="bool", default=True, save=False),
} }
elif op == "mass_collection_content_rating_update": elif op == "mass_collection_content_rating_update":
section_final[op] = { section_final[op] = {

@ -64,14 +64,19 @@ class Operations:
logger.debug(f"Item Operation: {self.library.items_library_operation}") logger.debug(f"Item Operation: {self.library.items_library_operation}")
logger.debug("") logger.debug("")
def should_be_deleted(col_in, labels_in, configured_in, managed_in, less_in): def should_be_deleted(col_in, labels_in, configured_in, managed_in, less_in, ignore_smart_in):
if all((x is None for x in [configured_in, managed_in, less_in])): if all((x is None for x in [configured_in, managed_in, less_in])):
return False return False
less_check = True less_check = not ignore_smart_in if col_in.smart else True
if less_in is not None: if less_in is not None:
less_check = col_in.childCount < less_in if less_check:
logger.trace(f"{col_in.title} - collection size: {col_in.childCount} < less: {less_in}, DELETE: {less_check}") col_count = col_in.childCount if col_in.childCount is not None else 0
less_check = col_count < less_in
logger.trace(f"{col_in.title} - collection size: {col_count} < less: {less_in}, DELETE: {less_check}")
else:
logger.trace(f"{col_in.title} - skipping size check: smart - {col_in.smart}, ignore_smart - {ignore_smart_in}")
managed_check = True managed_check = True
if managed_in is not None: if managed_in is not None:
@ -1071,6 +1076,7 @@ class Operations:
less = self.library.delete_collections["less"] if self.library.delete_collections and self.library.delete_collections["less"] is not None else None less = self.library.delete_collections["less"] if self.library.delete_collections and self.library.delete_collections["less"] is not None else None
managed = self.library.delete_collections["managed"] if self.library.delete_collections else None managed = self.library.delete_collections["managed"] if self.library.delete_collections else None
configured = self.library.delete_collections["configured"] if self.library.delete_collections else None configured = self.library.delete_collections["configured"] if self.library.delete_collections else None
ignore_smart = self.library.delete_collections["ignore_empty_smart_collections"] if self.library.delete_collections else True
unmanaged_collections = [] unmanaged_collections = []
unconfigured_collections = [] unconfigured_collections = []
all_collections = self.library.get_all_collections() all_collections = self.library.get_all_collections()
@ -1079,7 +1085,7 @@ class Operations:
col = self.library.reload(col, force=True) col = self.library.reload(col, force=True)
labels = [la.tag for la in self.library.item_labels(col)] labels = [la.tag for la in self.library.item_labels(col)]
if should_be_deleted(col, labels, configured, managed, less): if should_be_deleted(col, labels, configured, managed, less, ignore_smart):
try: try:
self.library.delete(col) self.library.delete(col)
logger.info(f"{col.title} Deleted") logger.info(f"{col.title} Deleted")

Loading…
Cancel
Save