[16] add delete_collections_named

pull/1269/head
meisnate12 2 years ago
parent 6f01c3c064
commit b9b7f90e59

@ -1 +1 @@
1.18.2-develop15 1.18.2-develop16

@ -28,6 +28,8 @@ collections:
collection_order: release.desc collection_order: release.desc
- name: translation - name: translation
translation_key: golden_best translation_key: golden_best
delete_collections_named:
- Golden Globe Best Motion Pictures
tmdb_list: tmdb_list:
- 8191011 # Drama - 8191011 # Drama
- 8191022 # Musical or Comedy - 8191022 # Musical or Comedy

@ -34,3 +34,4 @@ All the following attributes serve various functions as how the definition funct
| `default_percent` | **Description:** Used to declare the default percent for `episodes`, `seasons`, `tracks`, and `albums` [special filters](../filters.md#special-filters). Default is 50.<br>**Values:** Integer between 1 and 100 | | `default_percent` | **Description:** Used to declare the default percent for `episodes`, `seasons`, `tracks`, and `albums` [special filters](../filters.md#special-filters). Default is 50.<br>**Values:** Integer between 1 and 100 |
| `ignore_blank_results` | **Description:** Used to not have Errors resulting from blank results from builders.<br>**Default:** `false`<br>**Values:** `true` or `false` | | `ignore_blank_results` | **Description:** Used to not have Errors resulting from blank results from builders.<br>**Default:** `false`<br>**Values:** `true` or `false` |
| `only_run_on_create` | **Description:** Used to only run the collection definition if the collection doesn't already exist.<br>**Default:** `false`<br>**Values:** `true` or `false` | | `only_run_on_create` | **Description:** Used to only run the collection definition if the collection doesn't already exist.<br>**Default:** `false`<br>**Values:** `true` or `false` |
| `delete_collections_named` | **Description:** Used to delete any collections in your plex named one of the given collections.<br>**Values:** List of Collection Names to delete |

@ -42,7 +42,7 @@ ignored_details = [
"smart_filter", "smart_label", "smart_url", "run_again", "schedule", "sync_mode", "template", "variables", "test", "suppress_overlays", "smart_filter", "smart_label", "smart_url", "run_again", "schedule", "sync_mode", "template", "variables", "test", "suppress_overlays",
"delete_not_scheduled", "tmdb_person", "build_collection", "collection_order", "builder_level", "overlay", "delete_not_scheduled", "tmdb_person", "build_collection", "collection_order", "builder_level", "overlay",
"validate_builders", "libraries", "sync_to_users", "exclude_users", "collection_name", "playlist_name", "name", "validate_builders", "libraries", "sync_to_users", "exclude_users", "collection_name", "playlist_name", "name",
"blank_collection", "allowed_library_types", "delete_playlist", "ignore_blank_results", "only_run_on_create" "blank_collection", "allowed_library_types", "delete_playlist", "ignore_blank_results", "only_run_on_create", "delete_collections_named"
] ]
details = [ details = [
"ignore_ids", "ignore_imdb_ids", "server_preroll", "changes_webhooks", "collection_filtering", "collection_mode", "limit", "url_theme", "ignore_ids", "ignore_imdb_ids", "server_preroll", "changes_webhooks", "collection_filtering", "collection_mode", "limit", "url_theme",
@ -502,6 +502,19 @@ class CollectionBuilder:
logger.debug(f"Value: {data[methods['delete_not_scheduled']]}") logger.debug(f"Value: {data[methods['delete_not_scheduled']]}")
self.details["delete_not_scheduled"] = util.parse(self.Type, "delete_not_scheduled", self.data, datatype="bool", methods=methods, default=False) self.details["delete_not_scheduled"] = util.parse(self.Type, "delete_not_scheduled", self.data, datatype="bool", methods=methods, default=False)
if "delete_collections_named" in methods and not self.overlay and not self.playlist:
logger.debug("")
logger.debug("Validating Method: delete_collections_named")
logger.debug(f"Value: {data[methods['delete_collections_named']]}")
for del_col in util.parse(self.Type, "delete_collections_named", self.data, datatype="strlist", methods=methods):
try:
del_obj = self.library.get_collection(del_col, force_search=True)
self.library.delete(del_obj)
logger.info(f"Collection: {del_obj.title} deleted")
except Failed as e:
if str(e).startswith("Plex Error: Failed to delete"):
logger.error(e)
if "schedule" in methods and not self.config.requested_collections and not self.overlay: if "schedule" in methods and not self.config.requested_collections and not self.overlay:
logger.debug("") logger.debug("")
logger.debug("Validating Method: schedule") logger.debug("Validating Method: schedule")

@ -843,7 +843,7 @@ class Plex(Library):
except NotFound: except NotFound:
raise Failed(f"Plex Error: Playlist {title} not found") raise Failed(f"Plex Error: Playlist {title} not found")
def get_collection(self, data, force_search=False): def get_collection(self, data, force_search=False, debug=True):
if isinstance(data, Collection): if isinstance(data, Collection):
return data return data
elif isinstance(data, int) and not force_search: elif isinstance(data, int) and not force_search:
@ -853,6 +853,7 @@ class Plex(Library):
for d in cols: for d in cols:
if d.title == data: if d.title == data:
return d return d
if debug:
logger.debug("") logger.debug("")
for d in cols: for d in cols:
logger.debug(f"Found: {d.title}") logger.debug(f"Found: {d.title}")

Loading…
Cancel
Save