Skip to content

Instantly share code, notes, and snippets.

@mathiasvr
Forked from selsta/autosub.lua
Last active December 3, 2018 00:46
Show Gist options
  • Save mathiasvr/8e6585fd8fb5765cb3d1bdd57427daf9 to your computer and use it in GitHub Desktop.
Save mathiasvr/8e6585fd8fb5765cb3d1bdd57427daf9 to your computer and use it in GitHub Desktop.
Automatically download subtitles in mpv using subliminal.
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