mirror of
https://github.com/meisnate12/Plex-Meta-Manager
synced 2024-11-21 20:13:05 +00:00
[25] rework logic around collection deletion (#2147)
This commit is contained in:
parent
5047c7a408
commit
8db89bab47
4 changed files with 31 additions and 14 deletions
|
@ -1,8 +1,9 @@
|
|||
# Requirements Update (requirements will need to be reinstalled)
|
||||
Added tenacity requirement at 8.4.2
|
||||
Update pillow requirement to 10.4.0
|
||||
Update PlexAPI requirement to 4.15.14
|
||||
Update psutil requirement to 6.0.0
|
||||
Update setuptools requirement to 70.1.1
|
||||
Update setuptools requirement to 70.2.0
|
||||
|
||||
# Removed Features
|
||||
|
||||
|
@ -16,6 +17,7 @@ Added [`letterboxd_user_lists`](https://kometa.wiki/en/latest/files/dynamic_type
|
|||
# Bug Fixes
|
||||
Fixed multiple anime `int()` Errors
|
||||
Fixed #2100 `verify_ssl` wasn't working when downloading images
|
||||
Fixed an issue with `delete_collections` where items were being deleted if they only matched one criteria vs all criteria
|
||||
Fixed `imdb_watchlist`
|
||||
|
||||
Various other Minor Fixes
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
2.0.2-build24
|
||||
2.0.2-build25
|
||||
|
|
|
@ -64,6 +64,29 @@ class Operations:
|
|||
logger.debug(f"Item Operation: {self.library.items_library_operation}")
|
||||
logger.debug("")
|
||||
|
||||
def should_be_deleted(col_in, labels_in, configured_in, managed_in, less_in):
|
||||
if all((x is None for x in [configured_in, managed_in, less_in])):
|
||||
return False
|
||||
|
||||
less_check = True
|
||||
if less_in is not None:
|
||||
less_check = col_in.childCount < less_in
|
||||
logger.trace(f"{col_in.title} - collection size: {col_in.childCount} < less: {less_in}, DELETE: {less_check}")
|
||||
|
||||
managed_check = True
|
||||
if managed_in is not None:
|
||||
is_managed = "PMM" in labels_in or "Kometa" in labels_in
|
||||
managed_check = managed_in == is_managed
|
||||
logger.trace(f"{col_in.title} - collection managed: {is_managed} vs managed: {managed_in}, DELETE: {managed_check}")
|
||||
|
||||
configured_check = True
|
||||
if configured_in is not None:
|
||||
is_configured = col_in.title in self.library.collections
|
||||
configured_check = configured_in == is_configured
|
||||
logger.trace(f"{col_in.title} - collection configured: {is_configured} vs configured: {configured_in}, DELETE: {configured_check}")
|
||||
|
||||
return all((less_check, managed_check, configured_check))
|
||||
|
||||
if self.library.split_duplicates:
|
||||
items = self.library.search(**{"duplicate": True})
|
||||
for item in items:
|
||||
|
@ -1055,16 +1078,8 @@ class Operations:
|
|||
logger.ghost(f"Reading Collection: {i}/{len(all_collections)} {col.title}")
|
||||
col = self.library.reload(col, force=True)
|
||||
labels = [la.tag for la in self.library.item_labels(col)]
|
||||
if (less is not None or managed is not None or configured is not None) \
|
||||
and (less is None or col.childCount < less) \
|
||||
and (managed is None
|
||||
or (managed is True and "PMM" in labels)
|
||||
or (managed is True and "Kometa" in labels)
|
||||
or (managed is False and "PMM" not in labels)
|
||||
or (managed is False and "Kometa" not in labels)) \
|
||||
and (configured is None
|
||||
or (configured is True and col.title in self.library.collections)
|
||||
or (configured is False and col.title not in self.library.collections)):
|
||||
|
||||
if should_be_deleted(col, labels, configured, managed, less):
|
||||
try:
|
||||
self.library.delete(col)
|
||||
logger.info(f"{col.title} Deleted")
|
||||
|
|
|
@ -3,7 +3,7 @@ GitPython==3.1.43
|
|||
lxml==5.2.2
|
||||
num2words==0.5.13
|
||||
pathvalidate==3.2.0
|
||||
pillow==10.3.0
|
||||
pillow==10.4.0
|
||||
PlexAPI==4.15.14
|
||||
psutil==6.0.0
|
||||
python-dotenv==1.0.1
|
||||
|
@ -12,5 +12,5 @@ requests==2.32.3
|
|||
tenacity==8.4.2
|
||||
ruamel.yaml==0.18.6
|
||||
schedule==1.2.2
|
||||
setuptools==70.1.1
|
||||
setuptools==70.2.0
|
||||
tmdbapis==1.2.16
|
Loading…
Reference in a new issue