Skip to content

Commit 80aaaa8

Browse files
committed
Add deleting only collections that contains a substring
1 parent 489bd36 commit 80aaaa8

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

Plex/.env.example

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ POSTER_DEPTH=20 # grab this many posters [0 grabs a
3131
KEEP_JUNK=0 # keep files that script would normally delete [incorrect filetypes, mainly]
3232
FIND_OVERLAID_IMAGES=0 # check all downloaded images for overlays
3333
# RETAIN_OVERLAID_IMAGES=0 # keep images that have an overlay EXIF tag [this will override the following two]
34-
RETAIN_KOMETA_OVERLAID_IMAGES=0 # keep images that have the Kometa overlay EXIF tag
35-
RETAIN_TCM_OVERLAID_IMAGES=0 # keep images that have the TCM overlay EXIF tag
34+
RETAIN_KOMETA_OVERLAID_IMAGES=0 # keep images that have the Kometa overlay EXIF tag
35+
RETAIN_TCM_OVERLAID_IMAGES=0 # keep images that have the TCM overlay EXIF tag
3636

3737
## where-to-put-it
3838
USE_ASSET_NAMING=1 # should grab-all-posters name images to match Kometa's Asset Directory requirements?
3939
USE_ASSET_FOLDERS=1 # should those Kometa-Asset-Directory names use asset folders?
4040
USE_ASSET_SUBFOLDERS=0 # create asset folders in subfolders ["Collections", "Other", or [0-9, A-Z]] ]
4141
ASSETS_BY_LIBRARIES=1 # should those Kometa-Asset-Directory images be sorted into library folders?
4242
ASSET_DIR=assets # top-level directory for those Kometa-Asset-Directory images
43-
# if asset-directory naming is on, the next three are ignored
43+
# if asset-directory naming is on, the next three are ignored
4444
POSTER_DIR=extracted_posters # put downloaded posters here
4545
CURRENT_POSTER_DIR=current_posters # put downloaded current posters and artwork here
4646
POSTER_CONSOLIDATE=0 # if false, posters are separated into folders by library
@@ -86,6 +86,7 @@ ONLY_COLLECTION_MEMBERS=0
8686

8787
# DELETE_COLLECTION ENV VARS
8888
KEEP_COLLECTIONS=bing,bang # List of collections to keep
89+
# DELETE_COLLECTIONS_CONTAINING="- Saga" # Substring; if a collection's title contains this string, it will be deleted
8990

9091
# REMATCH-ITEMS ENV VARS
9192
UNMATCHED_ONLY=1 # If 1, only rematch things that are currently unmatched

Plex/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ ONLY_COLLECTION_MEMBERS=0
113113

114114
# DELETE_COLLECTION ENV VARS
115115
KEEP_COLLECTIONS=bing,bang # List of collections to keep
116+
# DELETE_COLLECTIONS_CONTAINING="- Saga" # Substring; if a collection's title contains this string, it will be deleted
116117

117118
# REMATCH-ITEMS ENV VARS
118119
UNMATCHED_ONLY=1 # If 1, only rematch things that are currently unmatched
@@ -778,8 +779,12 @@ This script will simply delete all collections from the libraries specified in t
778779

779780
Script-specific variables in .env:
780781
```shell
781-
KEEP_COLLECTIONS=bing,bang # comma-separated list of collections to keep
782+
KEEP_COLLECTIONS=bing,bang # comma-separated list of collections to keep
783+
# DELETE_COLLECTIONS_CONTAINING="- Saga" # Substring; if a collection's title contains this string, it will be deleted
782784
```
785+
786+
If `DELETE_COLLECTIONS_CONTAINING` is not empty, then only collections containing that substring will be deleted.
787+
783788
****
784789
### Usage
785790
1. setup as above

Plex/delete-collections.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
LIBRARY_NAMES = os.getenv("LIBRARY_NAMES")
3434
DELAY = int(os.getenv("DELAY"))
3535
KEEP_COLLECTIONS = os.getenv("KEEP_COLLECTIONS")
36+
DELETE_COLLECTIONS_CONTAINING = os.getenv("DELETE_COLLECTIONS_CONTAINING")
3637

3738
if not DELAY:
3839
DELAY = 0
@@ -80,8 +81,9 @@ def get_sort_text(argument):
8081
if title in keeper_array:
8182
bar.text = f"-> keeping: {title}"
8283
else:
83-
bar.text = f"-> deleting: {title}"
84-
item.delete()
84+
if (DELETE_COLLECTIONS_CONTAINING and title.find(DELETE_COLLECTIONS_CONTAINING) > -1) or not DELETE_COLLECTIONS_CONTAINING:
85+
bar.text = f"-> deleting: {title}"
86+
item.delete()
8587

8688
bar()
8789

0 commit comments

Comments
 (0)