2024-08-10, 12:52 PM
(This post was last modified: 2024-08-11, 10:28 AM by sjorge. Edited 6 times in total.)
(2024-05-03, 12:35 PM)TheDreadPirate Wrote: Yes and yes. Though if deleted in file explorer Jellyfin won't delete the subtitles until the next scan or if real time monitoring is enabled.
Sadly it doesn't look like they ever get cleaned up.
Code:
Aug 09 07:32:59 fqdn jellyfin[398659]: [07:32:59] [INF] ffmpeg subtitle extraction completed for /mm/Series/Rick and Morty (2013)/Rick and Morty - S07E05 - Unmortricken.mkv to /var/lib/jellyfin/data/subtitles/0/0e230db0-1f4f-93f3-f642-8b95ce07cb12.srt
...
Aug 10 14:43:23 fqdn jellyfin[398659]: [14:43:23] [INF] Removing item, Type: Series, Name: Rick and Morty, Path: /mm/Series/Rick and Morty (2013), Id: 2c6787f7-72aa-ef8d-588a-2ac214b2d1a0
One would expect the subtitles to be removed in this case. But it's still there.
Code:
root@node:~# ls -l /var/lib/jellyfin/data/subtitles/0/0e230db0-1f4f-93f3-f642-8b95ce07cb12.srt
-rw-r--r-- 1 jellyfin jellyfin 22685 Aug 9 07:32 /var/lib/jellyfin/data/subtitles/0/0e230db0-1f4f-93f3-f642-8b95ce07cb12.srt
Even after 2 additional 'Scan All Libraries' and the scheduled tasks
Subtitle Extract
(would not expect this to clean it up looking at the code) and Clean Cache Directory
(Most likely candidated) have run.I can also not find any reference in the code to where this gets cleaned up, just the
Subtitle Extract
task will call the function to extract subtitles, which will check they exist already first. And playback of an item requiring subs will also trigger the same call. But there is no delete happening everywhere, as far as I can see, there is also no reference to this in the database. I would have perhaps expected library.db -> mediastreams to have been updated with a complete Path field pointing to the cache, but this is also not the case.If I do every find a way to cleanup old files here, I'll edit this post but for now it seems to be very hard to do. Aside from nuking everything in that dir and running
Subtitle Extract
again which will then obviously not extract subtitles for the media that got removed.Edit: writing a script to do it is not going to be easy I tried something in python and typescript (the two languages I know but their date functions lack the required persision that C# has)
Edit 2:
Very much as-is as this is the first C# code I have written in over 10 years ...
https://gist.github.com/sjorge/db3661f5d...6cdc85eb4e
I made sure
subtitle extract
ran, dropped a .ignore, ran a scan all libraries
.Then ran the little program above, I'm not very happy with the code quality but it gets the job done.
Code:
sjorge@node:~$ sudo -u jellyfin /var/lib/jellyfin/.cron/jf_subtitle_cache_cleaner
Opening /var/lib/jellyfin/data/library.db ...
Looking up subtitle mediastreams ...
Detected 35085 valid subtitle cache paths.
Subtitle cache: purged=88, kept=35085
I guess this could be cleaned up and turned into a seperate scheduled task... not sure that would be acceptable though.
Edit 3: I filed an issue https://github.com/jellyfin/jellyfin-plu.../issues/35