justfoolingaround / animdl

A highly efficient, fast, powerful and light-weight anime downloader and streamer for your favorite anime.
GNU General Public License v3.0
1.33k stars 109 forks source link

mpv: fix WebVTT subtitles #255

Open fishman opened 1 year ago

fishman commented 1 year ago

The subtitles are passed separated by ':' as a result it will consider https and // to be different files and therefore failing to load.

justfoolingaround commented 1 year ago

Good catch. However, can you please see an alternative (maybe a separator character changing argument for mpv)?

Else, I'd also have to include a proper URL parser so that : within the URL get auto changed into %3A. Not to mention even basic authorization may have issues, i.e. https://user:password@cdn.xyz.com/.../subtitles.vtt.

fishman commented 1 year ago

Why would you need a url parser? I have tried this and it works. Looking through the mpv man page, I'm not sure that the colon can be changed. The doc just says seperator is : for unix and ; for windows. I assume that that's a separator that comes from ffmpeg.

justfoolingaround commented 1 year ago

Why would you need a url parser?

There would be cases where there are : in the URL, i.e. http://cdn.xyz.com/0:/One Piece Red.vtt. Not an ignore-able case. Furthermore, the project is already aware of the Windows and UNIX differences. The part separators are conveniently put in a variable.

The changes I've considered right now would be to escape any ; on Windows and : on UNIX.

fishman commented 1 year ago

http://cdn.xyz.com/0:/One Piece Red.vtt - this case should work just fine. And semicolons are reserved and not normally allowed in URLs, so you don't really have to worry about the windows case. If it really doesn't work on windows, then making this fix unix only should be enough. python's popen parameters are below

mpv "https://tc-1.boocdn.net/_v6/b96c32be4a0bac39badfebe38db85f154a35bc042db22d64ef78f66cc4cb3ad107ad85b20a5948dbfa847c2e8006089446c20302bf9bf223cdeac49fdcc3f0b071c444d7295f077b5fe72dd973e71b7e3c64a6bdc9d09608c60478df18f5e10b8d81f1ff8c9f5969ca4fb88d63c56ba2b9f917b1daef3fe6628c25d12c5a0456/master.m3u8" --sub-files="https\://cc.zorores.com/64/c7/64c729be0eed4c52c25603fee3bc77a9/64c729be0eed4c52c25603fee3bc77a9.vtt."

justfoolingaround commented 1 year ago

Oof, this also does not account for other protocols other than https but I suppose that is fixable.

fishman commented 1 year ago

Of course it does, mpv doesn't care what protocol you use. mpv uses ":" as delimiter for options. It comes from ffmpeg. So it doesn't matter what protocol you use for the subs with mpv. The delimiter is ALWAYS ":".