mpv
mpv copied to clipboard
Subtitles: Add support for `directory_mode=recursive`
Current behavior:
sub-auto=fuzzy does not search for more than one directory.
Expected Behavior:
sub-auto=fuzzy will search for more than one directory.
The same way directory_mode=recursive was added to autoload.lua,
I would love to have the option to add subtitle files from recursive directories.
Yes, there's already a solution to what I ask for, called fuzzydir.lua, but it's slow and not builtin mpv.
it's slow
Why does this need to be faster than a Lua script?
not builtin mpv.
Why does such a non-standard use case need to be built in? You're not supposed to put subtitles in a different directory from the file.
There's the existing --sub-file-paths option actually. I presume it only looks at top level directories but I guess in theory it could look recursively. Seems really fringe though (why wouldn't you just put subtitles in one directory?)
Why does such a non-standard use case need to be built in?
Well, I see your point, but there are some cases (example: subtitles from https://animetosho.org/), where if you download a batch of subtitles they are scattered each episode has it's own directory.
--- TV Show S01
---- S01E01
---- Subs
----- S01E01
------ track4_eng.ass
I hope it was easy to understand it.
why wouldn't you just put subtitles in one directory?
Because that's sometimes how you download them and it's a hassle to move and rename each file.
I still don't understand why this is so performance critical that fuzzydir.lua isn't fast enough.
Mmmm, it's not critical, just nice to have, that's all
Well, I see your point, but there are some cases (example: subtitles from https://animetosho.org/), where if you download a batch of subtitles they are scattered each episode has it's own directory.
--- TV Show S01 ---- S01E01 ---- Subs ----- S01E01 ------ track4_eng.ass
https://github.com/mpv-player/mpv/issues/9767#issuecomment-1022207724
This doesn't include subtitles already in the main directory of Subs.
The fact that it doesn't find subs already in the Subs folder and only in the filename folder only makes my feature suggestion of adding recursive directory to subtitles even more needed and better.
Just set sub-file-paths to whatever you want.
mp.add_hook('on_load', 10, function ()
mp.set_property('sub-file-paths', 'Subs;Subs/' .. mp.get_property('filename/no-ext'))
end)
Fine, I'll bite, sure... But let's make it even more problematic - what about if the second directory ISN'T the same filename?
Then just use fuzzydir.lua.
it's not perfect, it seems to have solved the problem with a long launch with the developer, but my friend has a new version of the script that starts more in time, in total there are two options with the script, the old version of the script that runs for a long time if the files are on online disks, and the new version that runs everywhere quickly, but some users have problems with a long launch and it is unclear why. There are still unresolved issues with this script.
There is another caveat that can happen.
fuzzydir.lua seems to work to load the subs in the subfolders, and also english only if set.
Problem is sometimes the folders can contain multiple _English.srt subtitles. Some containing more details than others. That can confuse the players when choose the right sub.
An example that I have here.
--- TV Show S01
---- S01E01.mp4
---- S01E02.mp4
---- S01E03.mp4
---- Subs
----- S01E01
------ 31_English.srt
------ 32_English.srt
----- S01E02
------ 29_English.srt
------ 30_English.srt
----- S01E03
------ 32_English.srt
------ 33_English.srt
There is no number pattern, it seems.
And it doesnt seem to load only the subs with the same name of the subfolder per episode. It loads all the srt, from all the subfolders.
audio-file-paths=**
sub-file-paths=**
max_search_depth=2
How to fix / make it work with that?
Maybe prioritize the bigger srt or prefix number in the folder if with the same name.
Edit:
Found this and it solves the problem.
https://github.com/mpv-player/mpv/issues/9767#issuecomment-1437767199