Open
Description
The cached thumbnails directory can grow to several hundreds of MBs or even GBs very fast. It is currently recommended to manually keep it clean, but I think this script could handle it itself.
I have a quick, dirty solution that works for me on GNU/Linux by deleting a video thumbnail directory on "end-file":
diff --git a/src/thumbnailer_shared.lua b/src/thumbnailer_shared.lua
index 37390e7..f53d774 100644
--- a/src/thumbnailer_shared.lua
+++ b/src/thumbnailer_shared.lua
@@ -71,6 +71,13 @@ function Thumbnailer:on_start_file()
self:clear_state()
end
+function Thumbnailer:on_end_file()
+ local path = self.state.thumbnail_directory
+ if path and path_exists(path) then
+ os.execute('rm -r "'..path..'"')
+ end
+end
+
function Thumbnailer:on_video_change(params)
-- Gather a new state when we get proper video-dec-params and our state is empty
if params then
@@ -503,3 +510,4 @@ function Thumbnailer:start_worker_jobs()
end
mp.register_event("start-file", function() Thumbnailer:on_start_file() end)
+mp.register_event("end-file", function() Thumbnailer:on_end_file() end)
but as I said it's quick and dirty, it doesn't work on Windows and probably other stuff I didn't think about. Since keeping the cache could also have its benefits, it might be a good idea to have this controlled by an option.