clara-j / media_cleaner

Python script to delete watched content on Emby
31 stars 17 forks source link

not sure if issue or by design #23

Closed elvis0288 closed 3 years ago

elvis0288 commented 3 years ago

hello @terrelsa13,

so i was running the script and i deleted a whole season 1 of a tv show, when looking into my folders it looks like it did deleted the episodes but left the empty folder in my library: image is there a way to validate if that is the last episode on the folder so the folder is also deleted? also maybe check if that is the last show season to also delete the tv show main folder? on my example i have your honor with just season 1 folder on it but both empty.

terrelsa13 commented 3 years ago

@elvis0288 This script simply sends a delete request using the Library - Delete /Items/{itemId} API Service provided by Emby and Jellyfin (see image). The Emby and Jellyfin program then handle the actual deleting of files matching the requested item's ID. This script has no way to request related folders also be deleted. So what you are seeing is normal.

BUT, Emby/JF may run some kind of periodic cleanup task. I would expect during this clean up task Emby/JF are looking for empty directories and remove them??? Although, I could see the Emby/JF program maybe not cleaning empty directories to prevent having to constantly remake a seasonX folder. For instance, if the show takes a long break halfway thru the season the folder would be deleted, but then would need to be recreated once the season continued.

Screenshot_2021-05-12 Jellyfin API

terrelsa13 commented 3 years ago

@elvis0288 Almost forgot, I have a second repository with a basic Bash (shell) script that will delete folders smaller than a certain size (aka folders without video files). However because you are using Windows and not Linux, you will need to use one of the options out there in the Google-verse to run a linux based script in Windows. I have never used it, but I think there is a native Linux Subsystem built into Windows you can enable. If this is still true, you may be able to run said script. The other option is to use a program like Cygwin to run the script. Either way, Google will have to be your guide on getting it to work on a Windows machine.

Maybe one day I will convert that bash script into a Python script. But do not wait around for that to happen.

elvis0288 commented 3 years ago

that makes sense i thought your script was the one deleting from the pc and not jellyfin.. yeah i would guess this is why movies folders are been deleted and not tv shows.. i did find a program for windows call remove empty directories that do the trick. thank you so much for your help