-
-
Save mathiasvr/8e6585fd8fb5765cb3d1bdd57427daf9 to your computer and use it in GitHub Desktop.
Automatically download subtitles in mpv using subliminal.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local utils = require 'mp.utils' | |
function load_sub_fn() | |
log("info", "Searching for subtitles") | |
local t = {args = {"subliminal", "download", "-s", "-l", "en", mp.get_property("path")}} | |
local res = utils.subprocess(t) | |
if res.status == 0 and res.stdout:find("0 error") then | |
mp.commandv("rescan_external_files", "reselect") | |
log("info", "Subtitles downloaded") | |
else | |
log("warn", "Subtitle download failed") | |
end | |
end | |
function log(lvl, msg) | |
mp.msg.log(lvl, msg) | |
mp.osd_message(msg) | |
end | |
mp.add_key_binding("b", "auto_load_subs", load_sub_fn) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment