Add "on delete" trigger to Connections

This is a copy paste of the issue I created on github originally, so I’m copying it here as I cannot seem to find a definitive answer on where Feature requests go. Close whichever you see fit

Describe the problem
My overarching problem is that I’d like to keep only n amount of episodes on the disk (both sonarr and download client). TO be more precise, I only want the last episodes of shows like The Daily show. From what I’ve seen, this was a requested feature for quite some time (#314 and all its duplicates) however no progress has been made on this for at least 7 years from what I can tell.

Currently I have to manually delete the files first in the sonarr directory (either through plex, manually or from sonarr itself) and then manually in the torrent client, which can be quite time consuming.

Describe any solutions you think might work
What I have been told only now is that Plex can handle this deletion behaviour on its own through the advanced settings. When the episode is deleted by Plex, Sonarr will pick this up and–if it is set to do so–unmonitor these episodes.
These events are visible in the history.

What I propose is to add an “on delete” to the “Connection settings”.


This way, anyone could make their own script to tell their download client to delete the episodes as well, seeing as the hash is passed to the scripts/webhooks.

Another option would be to build this option straight into sonarr by adding an advanced option to “Delete torrent data from client when episode is removed and unmonitored.” Either this could be for all shows, or a toggle for specific shows.

Honestly, even the option to “Remove data from torrent client” either by adding another column with checkboxes to this menu or just one single checkbox for all the ones that are being processed would already help speed my use case up. And I am fairly sure this would apply to a lot of people who are keeping up to date with any daily shows.

Please help us automatically delete episodes in one way or another :frowning:

Hi,

same demand here, I’d like an option built in Sonarr to automatically delete episodes after they are viewed in Plex. The option that already exists in Plex to do that is not good enough because it doesn’t impact what happens in Sonarr afterwards (un-monitoring episodes for exemple). If Sonarr can be in charge of this, everything would be cleaner.

So in addition to your “on delete” option, I propose a “on viewed” option as well.

Thx.

Pretty sure this is sonarr monitoring a file system, not plex directly :slight_smile:

Im afraid this would never happen. You are asking sonarr to not only keep track of its own system but now keep track of plex too? The webhooks are shit in plex and very unreliable for a system to actually delete files. I would never do this in sonarr as what happens in plex is not related to sonarr in any way.

You should handle this with plex webhooks and hope for the best that it gets deleted when it should. You can not rely on media.stop from plex because it only sends by physically stopping it. When an episode plays through to the end there is no media.stop to trigger a check if it was played all the way.

You would literally have to process every episode every time a webhook triggers to determine what has been played fully vs what has been a partial play (if you want to make sure no accidental deletes are done). This simply isn’t realistic beyond a “it would be nice if…”