terrelsa13 / MUMC

Multi-User Media Cleaner aka MUMC (pronounced Mew-Mick) will go through movies, tv episodes, audio tracks, and audiobooks in your Emby/Jellyfin libraries deleting media items you no longer want.
GNU General Public License v3.0
92 stars 6 forks source link

Delete tv show and season folder if empty #101

Closed mk89pwnz closed 5 months ago

mk89pwnz commented 6 months ago

Is it possible to make script do that? I tryed it ant it left them empty so emby still thinks those tv shows are there, also would it be able to add lib rescan after deleting the media?

terrelsa13 commented 6 months ago

Hi @mk89pwnz,

Delete tv show and season folder if empty Is it possible to make script do that?

You are not the first to ask if MUMC can delete folders. The short answer is, it cannot. The longer answer is there are a couple reasons why.

  1. There is no API endpoint Emby/Jellyfin offer to make a request to delete folders.
  2. The script will only delete using the API offered by Emby/Jellyfin. There is more risk than reward if MUMC bypassed the Emby/Jellyfin API and started deleting files directly through the OS file manager.

would it be able to add lib rescan after deleting the media?

Help me out with more details on what you are looking for here. Sounds like you want the Emby/Jellyfin server to perform a library scan after the script has run. I will try to explain why I am a little confused.

MUMC does not directly delete anything. The script sends a DELETE request for each media item to the Emby/Jellyfin server. The server decides if the DELETE request is possible (i.e. someone could be watching the media item). If the request is possible the server deletes it. If it is not possible the sever responds back to the script with an error. Because MUMC is requesting for the server to delete the media item, the server is aware the file has been deleted before it responds to MUMC that it has been deleted.

The sever updates the library database once it deletes the media item. I know this happens because if the script is immediately run again it does not try to delete the same media items twice, because the server no longer thinks they exist.

With that said, I don't understand what a library refresh would accomplish?

Let me know if I am misunderstanding your request for the library refresh.

terrelsa13 commented 6 months ago

@mk89pwnz My mistake! I did not mean to lock this conversation.

mk89pwnz commented 6 months ago

My problem is that even after deleting the files via script I still see those shows or movies in emby, they only disappear if I delete left folders manually.

terrelsa13 commented 6 months ago

This seems like the normal Emby/Jellyfin behavior when viewing from the server. My server does the same. When viewing from a client there should be an option to "hide watched content". Watched movies and tv series' with no remaining watched episodes will not be shown after the option is set on each client.

If this is something that you feel needs to be fixed; the best way is to post either to the Emby/Jellyfin github repos or on their forums and request to have "empty" media folders deleted on the server side. Another option is to ask them to add and API end point that allows deleting "empty" media (series, season, movie, album, etc...) folders.

terrelsa13 commented 6 months ago

@mk89pwnz I was wrong. You were right. Your feature request is 100% possible. Turns out Emby (and I am assuming Jellyfin) treats folders basically the same way it treats media items.

With that said, if you are still looking for a way to delete season and series folders, try out MUMC beta release v5.6.0_beta in the MUMC_dev branch which will query for empty season and series folders. If any are found, they will be deleted. Let me know how this works for you.

You can either add delete_empty_folders to mumc_config.yaml under advanced_settings:

advanced_settings:
  ...
  delete_empty_folders:
    episode:
      season: true
      series: true
  ...

Or run MUMC once, which will automatically add delete_empty_folders to mumc_config.yaml. Then open mumc_config.yaml in a text editor and set season: true and series: true.