itsToggle / plex_debrid

Plex torrent streaming through Debrid Services
1.52k stars 133 forks source link

{Optional}{Feature Request} Auto-deletion of movies and episodes after specified time #106

Closed ghost closed 2 years ago

ghost commented 2 years ago

Hi there, I am not sure how many people actually requires this but as of now after using you script for more than a three weeks, I just expanded my library by more than 34TB but the only issue is that if by any chance the played episodes and movies gets deleted lets say after 1 day, 1 week or 1 month automatically after setting up settings likewise would be great. This way the overhead of keeping track of vast library can be eliminated by the server as well as I as a user can see content seamlessly. This is a feature request and this can by default will be disabled to everyone to avoid any unwanted behaviour for majority of the people

itsToggle commented 2 years ago

Sounds like a cool idea! I'll add this in the coming weeks. There are a few existing scripts for something like this already (PlexCleaner and Cleanarr) but they seem outdated :)

ghost commented 2 years ago

Yes that is true. We can use those scripts if they are working fine but as your fork does have capacity to delete torrents then it would be yet another reason why people would want to use your fork instead of official rclone. Not a marketing thing but I guess adding up this script will give us a better way to manage server. There are several reasons why I came up with this idea of auto-deletion.

  1. My library when exceeded 34 TB then there are several episodes for which I got no file found error or almost 5 minutes delay to start next episode.(I suspect the refreshment of links through your script took place here and hence at least that episode played well) But deleting the watched episode after watching them would make the space for the latest episodes and the series or movies can be played without any delays.
  2. There are hardly some shows which I go and watch again but movies are one time thing.
  3. Having latest episodes ready to watch which Plex would require minimum efforts to search would be yet another performance enhanement.
itsToggle commented 2 years ago

You are right, when you have a large library like yours the script will constantly refresh your unrestricted links - sadly, that's a limitation on realdebrids part: They only allow us to fetch 100 links per request, so to check all your ~10.000 links, plex_debrid will need to make 100 requests to the realdebrid API which will definitely take a few seconds. Luckily I've written my rclone for so this is only done if the total number of torrents changes (like when you add a new torrent). This sadly can't be avoided. Currently, my rclone fork will re-unrestrict all missing links at once. This usually works fine, but when you have a library of your size this will constantly happen and it will take a lot of time. I could change the behavior to only unrestrict the currently requested files. This would slow down rclone for smaller libraries, but will significantly speed it up for large libraries like yours.

Aside from these limitations, you can try to increase the dir-cache-time to 60s or so. You could also limit the size of the virtual filesystem by adding the tag "--vfs-max-cache-size 50G" (this will limit it to 50GB) perhaps that will improve performance.

I'm currently on holidays, but I'll add the auto delete feature and (hopefully) some rclone improvements in a week or two :)

ghost commented 2 years ago

Yes, now to avoid congestion I have removed all public trakt list and most probably will reduce the content library in coming days. But yes auto deletion would help auto-arrange the library and size of it. Please do enjoy your holidays as to achieve ideal media system there is a long way ahead! But for sure we will achieve it.

itsToggle commented 2 years ago

Hey, this isn't an update on progress or anything, I just had a thought about your library size which I wanted to share: Since plex_debrid can download movies and shows almost instantaniously, why pre-download so much stuff? You can simply browse the discover part of plex (or trakt) and watch anything that sounds interesting right away. It's much easier to maintain a library that really only contains things you or your home users want to watch :) Just an idea, I will still add the auto delete feature :)

ghost commented 2 years ago

Hey you know what? This do make more sense. I should treat it as VOD service. But yes that is also true that more we use this service more content will be accumulated over time and this auto deletion feature will save future scenarios of library crossing said limits. I do appreciate your thought and from now on I will ask my home users to put only shows they are intended to watch in coming days or the movies for that matter. This give me one additional thought of auto-deletion, if we can have flexible rules just like scraping one as,

  1. Delete a file created before n number of days
  2. Delete a file after marked as watched after n number of days and

This will give us more granular control over the deletion process and people can avoid larger libraries created over time as more and more data, movies and shows will be collected.

ghost commented 2 years ago

Hey there adding the additional observation which I am experiencing right now. So if we add any TV show to the watchlist and if that TV show does have many other similar named TV shows or movies available then the script will fetch that content as well. Meanwhile user will only watch the required content he wished for and will ignore the other files. In this case, if list auto removal is only turned on for movies and not TV shows, meaning after successful content fetch if script is only deleting Movies from the list and not TV shows then the script will again add up the rest, similar named shows again when user deletes them. Meanwhile, the user who was interested to watch series A had his series watched completely and now he wishes to delete series A along with Series B,C,D and F which are almost identical to the series A name, then the script will scrape the sources again and this way user will keep seeing the similarly named show even after deleting unwatched similar named shows. Bit confusing but let me know whether you understood this or not? I can then try better explaining it.

itsToggle commented 2 years ago

Hey, sorry for the late response. The behavior of downloading similary titled tv shows is now dealt with.

itsToggle commented 2 years ago

Hi, autodeletion can be integrated with rclone filtering! No need to actually write any sort of script for this. Check out https://rclone.org/filtering/ for some more information on filtering your remote :) You will need rclone_rd for this to work, since the webdav can't delete torrents.

You could for example add the tag "--max-age 30d" (which will exclude any files older than 30 days). If you then add the tag "--delete-excluded", any torrents older than this will be deleted :)

Be sure to check some of the dates of your torrents before implementing this, and pick a reasonable amount of time.

ghost commented 2 years ago

This does work with your rclone version, right? I am using your version for ARM-based 64-bit architecture.

itsToggle commented 2 years ago

Yes, any command that works with the official rclone version also works with my fork :)

ghost commented 2 years ago

That is great!! Thanks, and I will do it.

Edit: I have changed the period to 45 days, as some files are yet to be watched... But I will soon change it to 30 or maybe less than that. The only issue I faced was during the deletion of a single episode from a bundle which is a zip file. So will monitor and come to an ideal period for it.