mpv-autosub
mpv-autosub copied to clipboard
Peerflix
Referencing: https://github.com/noctuid/mpv-peerflix-hook/issues/3
-
peerflix
does not display the file title properly (usuallyhttp://localhost:8888
or magnet link inmpv-peerflix-hook
's case), thus making it impossible forautosub
to download subs for said file. -
--force-media-title
can be used to mitigate this, butautosub
does not seem to use this forced media title. which outside of this use case, can be very helpful with other files and their subs. -
peerflix
/mpv-peerflix-hook
store the file in/tmp/torrent-stream
, but mpv useshttp://localhost:NNNN
to stream the file, how can one include these inlocal includes
array to automatically get subs?
to test:
mpv --force-media-title="the lighthouse 2019" 'magnet:?xt=urn:btih:B764661DE937E0463C9B7CD39EE10F949E507F8D&tr=http%3A%2F%2Fbt4.t-ru.org%2Fann%3Fmagnet&dn=%D0%9C%D0%B0%D1%8F%D0%BA%20%2F%20The%20Lighthouse%20(%D0%A0%D0%BE%D0%B1%D0%B5%D1%80%D1%82%20%D0%AD%D0%B3%D0%B3%D0%B5%D1%80%D1%81%20%2F%20Robert%20Eggers)%20%5B2019%2C%20%D0%A1%D0%A8%D0%90%2C%20%D1%83%D0%B6%D0%B0%D1%81%D1%8B%2C%20%D1%84%D1%8D%D0%BD%D1%82%D0%B5%D0%B7%D0%B8%2C%20%D0%B4%D1%80%D0%B0%D0%BC%D0%B0%2C%20%D0%B4%D0%B5%D1%82%D0%B5%D0%BA%D1%82%D0%B8%D0%B2%2C%20WEB-DLRip%5D%20MVO%20(HDRezka%20Studio)'
set local settings = {... remove_files = false ...}
in mpv-peerflix-hook
to not have to wait everytime while testing 😊.
Yeah, I can't change path
for a video, so either mpv would have to allow that or this plugin would need to also look at the media title.
The problem is that autosub is not intended to be used with the command line. Most users will simply start playback from a file explorer, so requiring them to set the media-title from the command line is a no-go.
I'm not familiar with peerflix or the torrenting use case, so let me know if there's anything I can do to help.
so requiring them to set the media-title from the command line is a no-go.
That would not be a requirement in the least, but rather a plus. You may stream a normal URL (by drag and drop) and the file name would be in Russian or complete gibberish, and subliminal
would not be able to retrieve correct subs. so, you're forced to change the name (this happens to me all the time).
so let me know if there's anything I can do to help.
The idea is to fall back to the file title (or prioritize it, if it exists, through configuration), as opposed to the file name (as it is defined in its path). namely this https://mpv.io/manual/master/#options-force-media-title.
I'm sure @noctuid would know the right Lua API to retrieve --force-media-title
.
$ mpv 'http://domain.stream/film/Маяк.2019.mkv'
# subliminal searches for english subtitles for Маяк.2019.mkv; fails.
$ mpv --force-media-title='the lighthouse (2019)' 'http://domain.stream/film/Маяк.2019.mkv'
# subliminal searches for english subtitles for the lighthouse (2019); successes.
Yeah, retrieving it is trivial: the media-title
property.
I remember using it at some point, but then reverting it because it didn't work in all cases ...
Yes, it does not always exist using some protocols. can its existence be checked and thus loaded conditionally?
If it does not exist it uses the filename instead: see https://mpv.io/manual/master/#command-interface-media-title.
I just checked the reverting commit, and it seems the reason was because the subtitle filename is then saved as the media-title, which prevents the subtitles from being picked up by MPV. Subliminal unfortunately does not have an option to set a custom subtitle filename.
Can Lua's OS package or something intervene? or since it's a bit of an edge case, force load subtitles to mpv
each time until a more ideal solution is found? I'll happily open an issue about this in subliminal
, but development seems a bit slow.
I guess it might be possible to do a check if media-title == filename, and if not to force load the media-title subtitles.
Checking if there are subs with the same name as the media-title
and load that to not have to download each time is a last resort.
If you’re using peerlix I suggest switching to the fork webtorrent-cli. No idea how, but it’s many times faster than any other torrent client for me. mpv-peerlix-hook should use it too, IMO.
Anyway, with webtorrent-cli --mpv
the filename
is set to the actual filename of the file being streamed, while directory
appears to be unset. Therefore, for autosub.lua
to work you have to set the relevant subliminal argument to a directory on your filesystem and pass that to the mpv option sub-file-paths
. The script works perfectly with torrent streams that way.
If you’re using peerlix I suggest switching to the fork webtorrent-cli. No idea how, but it’s many times faster than any other torrent client for me. mpv-peerlix-hook should use it too, IMO.
Thanks for saving me from peerflix. I've created an initial script for using it: webtorrent-peerflix-hook. It was a lot easier to write than the peerflix version (still needs work though).