shemanaev / jellyfin-plugin-media-cleaner

Automatically delete played media files after specified amount of time.
MIT License
71 stars 1 forks source link

[Feature]: Add option to delete folders that are empty after cleaning #7

Closed blackwind closed 1 year ago

blackwind commented 1 year ago

Describe the feature you'd like added

Very straightforward request here, just an option to delete folders that are now empty after cleaning. I feel like this should just be part of the default cleaning procedure, but I'm suggesting an option just in case that isn't agreeable for other users of the plugin.

Additional context

No response

shemanaev commented 1 year ago

Jellyfin does a pretty good job on content removal, like for /movies/Movie (2020)/Movie.mkv it will remove empty Movie (2020) folder also. Same for series. Mind sharing some specific folder layouts it doesn't handle?

blackwind commented 1 year ago

My layout is really simple, TV Shows/Temp/My Great TV Show with no season folders. I'll admit, I cleaned up the empty show folders myself after verifying Media Cleaner deleted the files, I didn't wait for Jellyfin itself to take action. Is there a particular scheduled task that handles empty folders that I can test? If Jellyfin handles this on its own, all the better.

shemanaev commented 1 year ago

It should remove empty show folder in process of cleanup. The problem is I can't replicate that behaviour: show folder gets removed even with seasons subfolders. Maybe you have the logs like this?

[17:35:25] [INF] [6] Emby.Server.Implementations.Library.LibraryManager: Removing item, Type: Episode, Name: XXX, Path: /media/XXX/E1.mkv, Id: e9604876-8516-51ba-ae26-eb0d5c9d458f
[17:35:25] [DBG] [6] Emby.Server.Implementations.Library.LibraryManager: Deleting metadata path, Type: Episode, Name: Summer Sucks, Path: /data/jellyfin/metadata/library/e9/e9604876851651baae26eb0d5c9d458f, Id: e9604876-8516-51ba-ae26-eb0d5c9d458f
[17:35:25] [INF] [6] Emby.Server.Implementations.Library.LibraryManager: Deleting item path, Type: Episode, Name: XXX, Path: /media/XXX/E1.mkv, Id: e9604876-8516-51ba-ae26-eb0d5c9d458f
blackwind commented 1 year ago

I see those, minus the "Deleting item path" one, but then I see this:

[2022-09-29 20:40:15.653 -06:00] [INF] [17] Emby.Server.Implementations.Library.LibraryManager: Removing item, Type: "Season", Name: "Season 4", Path: "", Id: f477e1a6-ba10-8bf0-507d-e3bf624abe47
[2022-09-29 20:40:17.087 -06:00] [INF] [17] Jellyfin.Plugin.Tvdb.Providers.TvdbMissingEpisodeProvider: Creating Season "Season 4" entry for "What We Do in the Shadows"
[2022-09-29 20:40:17.427 -06:00] [INF] [18] Jellyfin.Plugin.Tvdb.Providers.TvdbMissingEpisodeProvider: Creating virtual episode "What We Do in the Shadows" 4x1
[2022-09-29 20:40:17.812 -06:00] [INF] [18] Jellyfin.Plugin.Tvdb.Providers.TvdbMissingEpisodeProvider: Creating virtual episode "What We Do in the Shadows" 4x2
[2022-09-29 20:40:18.090 -06:00] [INF] [18] Jellyfin.Plugin.Tvdb.Providers.TvdbMissingEpisodeProvider: Creating virtual episode "What We Do in the Shadows" 4x3
[2022-09-29 20:40:18.532 -06:00] [INF] [18] Jellyfin.Plugin.Tvdb.Providers.TvdbMissingEpisodeProvider: Creating virtual episode "What We Do in the Shadows" 4x4
[2022-09-29 20:40:18.768 -06:00] [INF] [18] Jellyfin.Plugin.Tvdb.Providers.TvdbMissingEpisodeProvider: Creating virtual episode "What We Do in the Shadows" 4x5
[2022-09-29 20:40:19.135 -06:00] [INF] [18] Jellyfin.Plugin.Tvdb.Providers.TvdbMissingEpisodeProvider: Creating virtual episode "What We Do in the Shadows" 4x6
[2022-09-29 20:40:19.543 -06:00] [INF] [18] Jellyfin.Plugin.Tvdb.Providers.TvdbMissingEpisodeProvider: Creating virtual episode "What We Do in the Shadows" 4x7
[2022-09-29 20:40:19.942 -06:00] [INF] [18] Jellyfin.Plugin.Tvdb.Providers.TvdbMissingEpisodeProvider: Creating virtual episode "What We Do in the Shadows" 4x8
[2022-09-29 20:40:20.033 -06:00] [INF] [34] Jellyfin.Plugin.KodiSyncQueue.EntryPoints.LibrarySyncNotification: Started library sync
[2022-09-29 20:40:20.277 -06:00] [INF] [18] Jellyfin.Plugin.Tvdb.Providers.TvdbMissingEpisodeProvider: Creating virtual episode "What We Do in the Shadows" 4x9
[2022-09-29 20:40:20.630 -06:00] [INF] [18] Jellyfin.Plugin.Tvdb.Providers.TvdbMissingEpisodeProvider: Creating virtual episode "What We Do in the Shadows" 4x10
[2022-09-29 20:40:21.139 -06:00] [INF] [17] Emby.Server.Implementations.ScheduledTasks.TaskManager: "Played media cleanup" Completed after 1 minute(s) and 22 seconds

It seems like the "Missing Episode Fetcher" being enabled in my library under TV metadata downloaders might be the culprit. Once the season is deleted, it gets immediately recreated in metadata form, so that might be why the folder is kept. I've turned off the Fetcher and will report back the next time Media Cleaner deletes a season.

blackwind commented 1 year ago

Working as expected now, cheers!